2 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13 * or implied. See the License for the specific language governing
14 * permissions and limitations under the License.
16 import React from 'react';
17 import PropTypes from 'prop-types';
18 import i18n from 'nfvo-utils/i18n/i18n.js';
19 import {Tile, TileInfo, TileInfoLine, TileFooter, TileFooterCell, Button} from 'sdc-ui/lib/react';
21 import VSPOverlay from './VSPOverlay.jsx';
22 import {TooltipWrapper} from './Tooltip.jsx';
24 class VendorItem extends React.Component {
27 softwareProductList: PropTypes.array,
28 vendor: PropTypes.object,
29 shouldShowOverlay: PropTypes.bool,
30 onSelectVSP: PropTypes.func,
31 onVendorSelect: PropTypes.func,
32 onAddVSP: PropTypes.func,
33 onVSPButtonClick: PropTypes.func
37 let {vendor, onSelectVSP, shouldShowOverlay, onVendorSelect, onMigrate} = this.props;
38 let {softwareProductList = [], name} = vendor;
42 onClick={() => onVendorSelect(vendor)}>
43 <TileInfo align='center'>
44 <TileInfoLine type='title'>
45 <TooltipWrapper className='with-overlay' dataTestId='catalog-item-name'>{name}</TooltipWrapper>
49 btnType='outline-rounded'
51 onClick={e => this.handleVspCountClick(e)}
52 data-test-id='catalog-vsp-count'
53 disabled={!softwareProductList.length}>
54 {i18n('{length} VSPs', {length: softwareProductList.length})}
56 {shouldShowOverlay && softwareProductList.length > 0 &&
59 VSPList={softwareProductList}
60 onSelectVSP={onSelectVSP}
61 onSeeMore={() => onVendorSelect(vendor)} />
65 <TileFooter align='center'>
66 <TileFooterCell dataTestId='catalog-create-new-vsp-from-vendor'>
71 onClick={e => this.onCreateVspClick(e)}>
72 {i18n('Create new VSP')}
83 const {onAddVSP, vendor: {id}} = this.props;
87 handleVspCountClick(e){
90 const {onVSPButtonClick, vendor: {softwareProductList}} = this.props;
91 const hasVSP = Boolean(softwareProductList.length);
92 onVSPButtonClick(hasVSP);
97 export default VendorItem;