blob: 15f6c2d1bb5d4776bf5e8bdf7437b23691e5e70d [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,
54 modalHeader: React.PropTypes.string,
Avi Ziv61070c92017-07-26 17:37:57 +030055 selectedTab: React.PropTypes.string,
AviZi280f8012017-06-09 02:39:56 +030056 onTabSelect: React.PropTypes.func,
57 onCallVCAction: React.PropTypes.func,
58 onClose: React.PropTypes.func
59 };
60
61 render() {
62 let {isDisplayModal, modalHeader, licensingDataList, selectedTab, onTabSelect} = this.props;
63 let selectedInUse = selectedTab !== selectedButton.NOT_IN_USE;
64
65 return(
66 <div className='license-model-overview'>
67 <SummaryView/>
68 <div className={classNames('overview-list-section ', !selectedInUse ? 'overview-list-orphans' : '' )}>
69 <div className='vlm-list-tab-panel'>
Avi Ziv61070c92017-07-26 17:37:57 +030070 <ListButtons onTabSelect={onTabSelect} selectedTab={selectedTab}/>
AviZi280f8012017-06-09 02:39:56 +030071 </div>
72 <VLMListView licensingDataList={licensingDataList} showInUse={selectedInUse}/>
73 </div>
74 {
75 isDisplayModal &&
Avi Ziv61070c92017-07-26 17:37:57 +030076 <Modal show={isDisplayModal} bsSize='large' animation={true} className={classNames('onborading-modal license-model-modal', setModalClassName(modalHeader))}>
AviZi280f8012017-06-09 02:39:56 +030077 <Modal.Header>
78 <Modal.Title>{`${i18n('Create New ')}${i18n(modalHeader)}`}</Modal.Title>
79 </Modal.Header>
80 <Modal.Body>
81 {this.renderModalBody(modalHeader)}
82 </Modal.Body>
83 </Modal>
84 }
85 </div>
86 );
87 }
88
89 renderModalBody(modalHeader) {
90 let {licenseModelId, version} = this.props;
91 switch (modalHeader) {
92 case overviewEditorHeaders.ENTITLEMENT_POOL:
93 return <EntitlementPoolsEditor version={version} licenseModelId={licenseModelId} isReadOnlyMode={false}/>;
94 case overviewEditorHeaders.LICENSE_AGREEMENT:
95 return <LicenseAgreementEditor version={version} licenseModelId={licenseModelId} isReadOnlyMode={false}/>;
96 case overviewEditorHeaders.FEATURE_GROUP:
97 return <FeatureGroupEditor version={version} licenseModelId={licenseModelId} isReadOnlyMode={false}/>;
98 case overviewEditorHeaders.LICENSE_KEY_GROUP:
99 return <LicenseKeyGroupsEditor version={version} licenseModelId={licenseModelId} isReadOnlyMode={false}/>;
100 }
101 }
102}
103
104export default LicenseModelOverviewView;