[SDC-29] Amdocs OnBoard 1707 initial commit.
[sdc.git] / openecomp-ui / src / sdc-app / onboarding / onboard / DetailsCatalogView.jsx
1 /*!
2  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
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
13  * or implied. See the License for the specific language governing
14  * permissions and limitations under the License.
15  */
16 import React from 'react';
17 import {catalogItemTypes, modalMapper, catalogItemTypeClasses} from './onboardingCatalog/OnboardingCatalogConstants.js';
18 import {filterCatalogItemsByType} from './onboardingCatalog/OnboardingCatalogUtils.js';
19 import CatalogList from './CatalogList.jsx';
20 import CatalogItemDetails from './CatalogItemDetails.jsx';
21
22 class DetailsCatalogView extends React.Component{
23
24         static propTypes = {
25                 VLMList: React.PropTypes.array,
26                 VSPList: React.PropTypes.array,
27                 onSelectVLM: React.PropTypes.func.isRequired,
28                 onSelectVSP: React.PropTypes.func.isRequired,
29                 onAddVLM: React.PropTypes.func.isRequired,
30                 onAddVSP: React.PropTypes.func.isRequired,
31                 filter: React.PropTypes.string.isRequired
32         };
33
34         renderCatalogItems(items, type, filter, onSelect, onMigrate, tileType){
35                 return filterCatalogItemsByType(items, type, filter).map(item =>
36                 <CatalogItemDetails
37                         key={item.id}
38                         catalogItemData={type === catalogItemTypes.LICENSE_MODEL ? {...item, name: item.vendorName} : item}
39                         catalogItemTypeClass={catalogItemTypeClasses[modalMapper[type]]}
40                         onMigrate={onMigrate}
41                         onSelect={() => onSelect(item)}
42                         tileType={tileType} />
43                 );
44         }
45
46         render() {
47                 let {VLMList, VSPList, onAddVSP, onAddVLM, onSelectVLM, onSelectVSP, filter = '', onMigrate, tileType} = this.props;
48                 return (
49                         <CatalogList onAddVLM={onAddVLM} onAddVSP={onAddVSP}>
50                                 {this.renderCatalogItems(VLMList, catalogItemTypes.LICENSE_MODEL, filter, onSelectVLM, onMigrate, tileType)}
51                                 {this.renderCatalogItems(VSPList, catalogItemTypes.SOFTWARE_PRODUCT, filter, onSelectVSP, onMigrate, tileType)}
52                         </CatalogList>
53                 );
54         }
55 }
56 export default DetailsCatalogView;