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 {catalogItemTypeClasses} from './OnboardingCatalogConstants.js';
18 import CatalogTile from '../CatalogTile.jsx';
19 import classnames from 'classnames';
20 import VSPOverlay from './VSPOverlay.jsx';
21 import i18n from 'nfvo-utils/i18n/i18n.js';
22 import SVGIcon from 'nfvo-components/icon/SVGIcon.jsx';
23 import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger.js';
24 import tooltip from './Tooltip.jsx';
27 class VendorItem extends React.Component {
30 softwareProductList: React.PropTypes.array,
31 vendor: React.PropTypes.object,
32 onSelectVSP: React.PropTypes.func,
33 shouldShowOverlay: React.PropTypes.boolm,
34 onVendorSelect: React.PropTypes.func,
35 onAddVSP: React.PropTypes.func,
36 onVSPIconClick: React.PropTypes.func,
41 let {vendor, onSelectVSP, shouldShowOverlay, onVendorSelect, onMigrate} = this.props;
42 let {softwareProductList = [], vendorName} = vendor;
45 catalogItemTypeClass={catalogItemTypeClasses.VENDOR}
46 onSelect={() => onVendorSelect(vendor)}>
47 <div className='catalog-tile-top'>
48 <div className='catalog-tile-icon vendor-type'>
49 <div className='icon'><SVGIcon name='vendor'/></div>
51 <OverlayTrigger placement='top' overlay={tooltip(vendorName)}>
52 <div className='catalog-tile-item-name'>{vendorName}</div>
55 className={classnames('catalog-tile-vsp-count', {active: shouldShowOverlay}, {clickable: softwareProductList.length})}
56 onClick={(event) => this.handleVspCountClick(event)}
57 data-test-id='catalog-vsp-count'>
58 {i18n(`${softwareProductList.length} VSPs`)}
60 <div className='catalog-tile-content' onClick={(event) => this.onCreateVspClick(event)} data-test-id='catalog-create-new-vsp-from-vendor'>
61 <div className='create-new-vsp-button'>
62 <SVGIcon name='plus'/> {i18n('Create new VSP')}
67 {shouldShowOverlay && softwareProductList.length > 0
68 && <VSPOverlay onMigrate={onMigrate} VSPList={softwareProductList} onSelectVSP={onSelectVSP} onSeeMore={() => onVendorSelect(vendor)}/>}
75 licenseModelToShow: vlm
79 onCreateVspClick(event) {
80 let {onAddVSP, vendor: {id}} = this.props;
81 event.stopPropagation();
82 event.preventDefault();
86 handleVspCountClick(e){
87 let {onVSPIconClick, vendor: {softwareProductList}} = this.props;
90 const hasVSP = Boolean(softwareProductList.length);
91 onVSPIconClick(hasVSP);
96 export default VendorItem;