blob: 77289a3e081f146a95cf1a94bc7678281136b2ed [file] [log] [blame]
AviZi280f8012017-06-09 02:39:56 +03001/*!
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 */
16import React from 'react';
17import i18n from 'nfvo-utils/i18n/i18n.js';
18import Modal from 'nfvo-components/modal/Modal.jsx';
19import classNames from 'classnames';
20
21import EntitlementPoolsEditor from '../entitlementPools/EntitlementPoolsEditor.js';
22import FeatureGroupEditor from '../featureGroups/FeatureGroupEditor.js';
23import LicenseAgreementEditor from '../licenseAgreement/LicenseAgreementEditor.js';
24import LicenseKeyGroupsEditor from '../licenseKeyGroups/LicenseKeyGroupsEditor.js';
25import {overviewEditorHeaders, selectedButton} from './LicenseModelOverviewConstants.js';
26
27import SummaryView from './SummaryView.jsx';
28import VLMListView from './VLMListView.jsx';
29import ListButtons from './summary/ListButtons.jsx';
30
31
32const setModalClassName = (modalHeader) => {
33 switch (modalHeader) {
34 case overviewEditorHeaders.ENTITLEMENT_POOL:
35 return 'entitlement-pools-modal';
36 case overviewEditorHeaders.LICENSE_AGREEMENT:
37 return 'license-agreement-modal';
38 case overviewEditorHeaders.FEATURE_GROUP:
39 return 'feature-group-modal';
40 case overviewEditorHeaders.LICENSE_KEY_GROUP:
41 return 'license-key-groups-modal';
42 default:
43 return '';
44 }
45};
46
47class LicenseModelOverviewView extends React.Component {
48
49 static propTypes = {
50 isDisplayModal: React.PropTypes.bool,
51 isReadOnlyMode: React.PropTypes.bool,
52 licenseModelId: React.PropTypes.string,
53 licensingDataList: React.PropTypes.array,
ilanapc6a41de2017-11-07 11:54:10 +020054 orphanDataList: React.PropTypes.array,
AviZi280f8012017-06-09 02:39:56 +030055 modalHeader: React.PropTypes.string,
Avi Ziv61070c92017-07-26 17:37:57 +030056 selectedTab: React.PropTypes.string,
AviZi280f8012017-06-09 02:39:56 +030057 onTabSelect: React.PropTypes.func,
58 onCallVCAction: React.PropTypes.func,
59 onClose: React.PropTypes.func
60 };
61
62 render() {
ilanapc6a41de2017-11-07 11:54:10 +020063 let {isDisplayModal, modalHeader, licensingDataList, selectedTab, onTabSelect, orphanDataList} = this.props;
AviZi280f8012017-06-09 02:39:56 +030064 let selectedInUse = selectedTab !== selectedButton.NOT_IN_USE;
ilanapc6a41de2017-11-07 11:54:10 +020065 let dataList = selectedInUse ? licensingDataList : orphanDataList;
AviZi280f8012017-06-09 02:39:56 +030066 return(
67 <div className='license-model-overview'>
68 <SummaryView/>
69 <div className={classNames('overview-list-section ', !selectedInUse ? 'overview-list-orphans' : '' )}>
70 <div className='vlm-list-tab-panel'>
ilanapc6a41de2017-11-07 11:54:10 +020071 <ListButtons onTabSelect={onTabSelect}
72 selectedTab={selectedTab}
73 hasOrphans={orphanDataList.length > 0}
74 hasLicensing={licensingDataList.length > 0}/>
AviZi280f8012017-06-09 02:39:56 +030075 </div>
ilanapc6a41de2017-11-07 11:54:10 +020076 <VLMListView licensingDataList={dataList} showInUse={selectedInUse}/>
AviZi280f8012017-06-09 02:39:56 +030077 </div>
78 {
79 isDisplayModal &&
Avi Ziv61070c92017-07-26 17:37:57 +030080 <Modal show={isDisplayModal} bsSize='large' animation={true} className={classNames('onborading-modal license-model-modal', setModalClassName(modalHeader))}>
AviZi280f8012017-06-09 02:39:56 +030081 <Modal.Header>
82 <Modal.Title>{`${i18n('Create New ')}${i18n(modalHeader)}`}</Modal.Title>
83 </Modal.Header>
84 <Modal.Body>
85 {this.renderModalBody(modalHeader)}
86 </Modal.Body>
87 </Modal>
88 }
89 </div>
90 );
91 }
92
93 renderModalBody(modalHeader) {
94 let {licenseModelId, version} = this.props;
95 switch (modalHeader) {
96 case overviewEditorHeaders.ENTITLEMENT_POOL:
97 return <EntitlementPoolsEditor version={version} licenseModelId={licenseModelId} isReadOnlyMode={false}/>;
98 case overviewEditorHeaders.LICENSE_AGREEMENT:
99 return <LicenseAgreementEditor version={version} licenseModelId={licenseModelId} isReadOnlyMode={false}/>;
100 case overviewEditorHeaders.FEATURE_GROUP:
101 return <FeatureGroupEditor version={version} licenseModelId={licenseModelId} isReadOnlyMode={false}/>;
102 case overviewEditorHeaders.LICENSE_KEY_GROUP:
103 return <LicenseKeyGroupsEditor version={version} licenseModelId={licenseModelId} isReadOnlyMode={false}/>;
104 }
105 }
106}
107
108export default LicenseModelOverviewView;