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,
43 activeTabName: PropTypes.string
45 handleSeeMore = () => {
46 const { onVendorSelect, vendor, activeTabName } = this.props;
47 onVendorSelect(vendor, activeTabName);
50 let { vendor, onSelectVSP, shouldShowOverlay, onMigrate } = this.props;
51 let { softwareProductList = [], name } = vendor;
53 <Tile iconName="vendor" onClick={this.handleSeeMore}>
54 <TileInfo align="center">
55 <TileInfoLine type="title">
57 className="with-overlay"
58 dataTestId="catalog-item-name">
65 className="venodor-tile-btn"
66 onClick={this.handleVspCountClick}
67 data-test-id="catalog-vsp-count"
68 disabled={!softwareProductList.length}>
69 {`${softwareProductList.length.toString()} ${i18n(
74 softwareProductList.length > 0 && (
76 onClose={this.handleClickOutside}>
79 VSPList={softwareProductList}
80 onSelectVSP={onSelectVSP}
81 onSeeMore={this.handleSeeMore}
83 </ClickOutsideWrapper>
87 <TileFooter align="center">
88 <TileFooterCell dataTestId="catalog-create-new-vsp-from-vendor">
93 onClick={this.onCreateVspClick}>
94 {i18n('Create new VSP')}
102 onCreateVspClick = e => {
105 const { onAddVSP, vendor: { id } } = this.props;
108 handleClickOutside = () => {
109 const { onVSPButtonClick, vlm } = this.props;
110 onVSPButtonClick(false, vlm);
113 handleVspCountClick = e => {
118 vendor: { softwareProductList },
121 const hasVSP = Boolean(softwareProductList.length);
122 onVSPButtonClick(hasVSP, vlm);
126 export default VendorItem;