2 * Copyright © 2016-2018 European Support Limited
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.
17 import React from 'react';
18 import PropTypes from 'prop-types';
19 import i18n from 'nfvo-utils/i18n/i18n.js';
20 import ClickOutsideWrapper from 'nfvo-components/clickOutsideWrapper/ClickOutsideWrapper.jsx';
29 } from 'sdc-ui/lib/react';
31 import VSPOverlay from './VSPOverlay.jsx';
32 import { TooltipWrapper } from './Tooltip.jsx';
34 class VendorItem extends React.Component {
36 softwareProductList: PropTypes.array,
37 vendor: PropTypes.object,
38 shouldShowOverlay: PropTypes.bool,
39 onSelectVSP: PropTypes.func,
40 onVendorSelect: PropTypes.func,
41 onAddVSP: PropTypes.func,
42 onVSPButtonClick: PropTypes.func
53 let { softwareProductList = [], name } = vendor;
55 <Tile iconName="vendor" onClick={() => onVendorSelect(vendor)}>
56 <TileInfo align="center">
57 <TileInfoLine type="title">
59 className="with-overlay"
60 dataTestId="catalog-item-name">
67 className="venodor-tile-btn"
68 onClick={e => this.handleVspCountClick(e)}
69 data-test-id="catalog-vsp-count"
70 disabled={!softwareProductList.length}>
71 {i18n('{length} VSPs', {
72 length: softwareProductList.length
76 softwareProductList.length > 0 && (
78 onClose={this.handleClickOutside}>
81 VSPList={softwareProductList}
82 onSelectVSP={onSelectVSP}
83 onSeeMore={() => onVendorSelect(vendor)}
85 </ClickOutsideWrapper>
89 <TileFooter align="center">
90 <TileFooterCell dataTestId="catalog-create-new-vsp-from-vendor">
95 onClick={e => this.onCreateVspClick(e)}>
96 {i18n('Create new VSP')}
104 onCreateVspClick(e) {
107 const { onAddVSP, vendor: { id } } = this.props;
110 handleClickOutside = () => {
111 this.props.onVSPButtonClick(false);
114 handleVspCountClick(e) {
119 vendor: { softwareProductList }
121 const hasVSP = Boolean(softwareProductList.length);
122 onVSPButtonClick(hasVSP);
126 export default VendorItem;