Support 50 Characters for VSP Name
[sdc.git] / openecomp-ui / src / sdc-app / onboarding / onboard / CatalogItemDetails.jsx
1 /*
2  * Copyright © 2016-2018 European Support Limited
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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 or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 import React from 'react';
17 import PropTypes from 'prop-types';
18 import i18n from 'nfvo-utils/i18n/i18n.js';
19 import {
20     catalogItemTypes,
21     migrationStatusMapper
22 } from './onboardingCatalog/OnboardingCatalogConstants.js';
23 import {
24     Tile,
25     TileInfo,
26     TileInfoLine,
27     TileFooter,
28     TileFooterCell
29 } from 'onap-ui-react';
30 import { TooltipWrapper } from './onboardingCatalog/Tooltip.jsx';
31
32 const ITEM_TYPE_MAP = {
33     [catalogItemTypes.LICENSE_MODEL]: {
34         headerText: i18n('VLM'),
35         contentIconName: 'vlm',
36         color: 'purple'
37     },
38     [catalogItemTypes.SOFTWARE_PRODUCT]: {
39         headerText: i18n('VSP'),
40         contentIconName: 'vsp',
41         color: 'blue'
42     }
43 };
44
45 const CatalogItemDetails = ({
46     catalogItemData,
47     catalogItemTypeClass,
48     onSelect,
49     onMigrate
50 }) => {
51     let { vendorName, name, owner } = catalogItemData;
52     let { headerText, color, contentIconName } = ITEM_TYPE_MAP[
53         catalogItemTypeClass
54     ];
55
56     let onClick = e => {
57         e.stopPropagation();
58         e.preventDefault();
59         if (
60             catalogItemData.isOldVersion &&
61             catalogItemData.isOldVersion === migrationStatusMapper.OLD_VERSION
62         ) {
63             onMigrate({ softwareProduct: catalogItemData });
64         } else {
65             onSelect();
66         }
67     };
68
69     return (
70         <Tile
71             headerText={headerText}
72             headerColor={color}
73             iconName={contentIconName}
74             iconColor={color}
75             onClick={onClick}
76             dataTestId={catalogItemTypeClass}>
77             <TileInfo data-test-id="catalog-item-content">
78                 {vendorName && (
79                     <TileInfoLine type="supertitle">
80                         <TooltipWrapper
81                             className="with-overlay"
82                             tooltipClassName="tile-super-info"
83                             dataTestId="catalog-item-vendor-name">
84                             {vendorName}
85                         </TooltipWrapper>
86                     </TileInfoLine>
87                 )}
88                 <TileInfoLine type="title">
89                     <TooltipWrapper
90                         className="with-overlay"
91                         tooltipClassName="catalog-tile-tooltip"
92                         dataTestId="catalog-item-name">
93                         {name}
94                     </TooltipWrapper>
95                 </TileInfoLine>
96             </TileInfo>
97             <TileFooter>
98                 {owner && <TileFooterCell>Owner - {owner}</TileFooterCell>}
99             </TileFooter>
100         </Tile>
101     );
102 };
103
104 CatalogItemDetails.propTypes = {
105     catalogItemData: PropTypes.object,
106     catalogItemTypeClass: PropTypes.string,
107     onSelect: PropTypes.func,
108     onMigrate: PropTypes.func
109 };
110
111 export default CatalogItemDetails;