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
44 handleSeeMore = () => {
45 const { onVendorSelect, vendor } = this.props;
46 onVendorSelect(vendor);
49 let { vendor, onSelectVSP, shouldShowOverlay, onMigrate } = this.props;
50 let { softwareProductList = [], name } = vendor;
52 <Tile iconName="vendor" onClick={this.handleSeeMore}>
53 <TileInfo align="center">
54 <TileInfoLine type="title">
56 className="with-overlay"
57 dataTestId="catalog-item-name">
64 className="venodor-tile-btn"
65 onClick={this.handleVspCountClick}
66 data-test-id="catalog-vsp-count"
67 disabled={!softwareProductList.length}>
68 {`${softwareProductList.length.toString()} ${i18n(
73 softwareProductList.length > 0 && (
75 onClose={this.handleClickOutside}>
78 VSPList={softwareProductList}
79 onSelectVSP={onSelectVSP}
80 onSeeMore={this.handleSeeMore}
82 </ClickOutsideWrapper>
86 <TileFooter align="center">
87 <TileFooterCell dataTestId="catalog-create-new-vsp-from-vendor">
92 onClick={this.onCreateVspClick}>
93 {i18n('Create new VSP')}
101 onCreateVspClick = e => {
104 const { onAddVSP, vendor: { id } } = this.props;
107 handleClickOutside = () => {
108 const { onVSPButtonClick, vlm } = this.props;
109 onVSPButtonClick(false, vlm);
112 handleVspCountClick = e => {
117 vendor: { softwareProductList },
120 const hasVSP = Boolean(softwareProductList.length);
121 onVSPButtonClick(hasVSP, vlm);
125 export default VendorItem;