blob: d6c79ddb5286666e1f6d7d64698703cc88b73777 [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,
55 selectedTab: React.PropTypes.symbol,
56 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'>
70 <div className='section-title'>{selectedInUse ? i18n('VLM List View') : i18n('Entities not in Use')}</div>
71 <ListButtons onTabSelect={onTabSelect} selectedInUse={selectedInUse}/>
72 </div>
73 <VLMListView licensingDataList={licensingDataList} showInUse={selectedInUse}/>
74 </div>
75 {
76 isDisplayModal &&
77 <Modal show={isDisplayModal} bsSize='large' animation={true} className={classNames('onborading-modal', setModalClassName(modalHeader))}>
78 <Modal.Header>
79 <Modal.Title>{`${i18n('Create New ')}${i18n(modalHeader)}`}</Modal.Title>
80 </Modal.Header>
81 <Modal.Body>
82 {this.renderModalBody(modalHeader)}
83 </Modal.Body>
84 </Modal>
85 }
86 </div>
87 );
88 }
89
90 renderModalBody(modalHeader) {
91 let {licenseModelId, version} = this.props;
92 switch (modalHeader) {
93 case overviewEditorHeaders.ENTITLEMENT_POOL:
94 return <EntitlementPoolsEditor version={version} licenseModelId={licenseModelId} isReadOnlyMode={false}/>;
95 case overviewEditorHeaders.LICENSE_AGREEMENT:
96 return <LicenseAgreementEditor version={version} licenseModelId={licenseModelId} isReadOnlyMode={false}/>;
97 case overviewEditorHeaders.FEATURE_GROUP:
98 return <FeatureGroupEditor version={version} licenseModelId={licenseModelId} isReadOnlyMode={false}/>;
99 case overviewEditorHeaders.LICENSE_KEY_GROUP:
100 return <LicenseKeyGroupsEditor version={version} licenseModelId={licenseModelId} isReadOnlyMode={false}/>;
101 }
102 }
103}
104
105export default LicenseModelOverviewView;