blob: 39109af9a3be5e20d83c51f883d2f4fbb48d33fd [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';
talig8e9c0652017-12-20 14:30:43 +020017import PropTypes from 'prop-types';
AviZi280f8012017-06-09 02:39:56 +030018import i18n from 'nfvo-utils/i18n/i18n.js';
19import Modal from 'nfvo-components/modal/Modal.jsx';
20import classNames from 'classnames';
21
22import EntitlementPoolsEditor from '../entitlementPools/EntitlementPoolsEditor.js';
23import FeatureGroupEditor from '../featureGroups/FeatureGroupEditor.js';
24import LicenseAgreementEditor from '../licenseAgreement/LicenseAgreementEditor.js';
25import LicenseKeyGroupsEditor from '../licenseKeyGroups/LicenseKeyGroupsEditor.js';
26import {overviewEditorHeaders, selectedButton} from './LicenseModelOverviewConstants.js';
27
28import SummaryView from './SummaryView.jsx';
29import VLMListView from './VLMListView.jsx';
30import ListButtons from './summary/ListButtons.jsx';
31
32
33const setModalClassName = (modalHeader) => {
34 switch (modalHeader) {
35 case overviewEditorHeaders.ENTITLEMENT_POOL:
36 return 'entitlement-pools-modal';
37 case overviewEditorHeaders.LICENSE_AGREEMENT:
38 return 'license-agreement-modal';
39 case overviewEditorHeaders.FEATURE_GROUP:
40 return 'feature-group-modal';
41 case overviewEditorHeaders.LICENSE_KEY_GROUP:
42 return 'license-key-groups-modal';
43 default:
44 return '';
45 }
46};
47
48class LicenseModelOverviewView extends React.Component {
49
50 static propTypes = {
talig8e9c0652017-12-20 14:30:43 +020051 isDisplayModal: PropTypes.bool,
52 isReadOnlyMode: PropTypes.bool,
53 licenseModelId: PropTypes.string,
54 licensingDataList: PropTypes.array,
55 orphanDataList: PropTypes.array,
56 modalHeader: PropTypes.string,
57 selectedTab: PropTypes.string,
58 onTabSelect: PropTypes.func,
59 onCallVCAction: PropTypes.func,
60 onClose: PropTypes.func
AviZi280f8012017-06-09 02:39:56 +030061 };
62
63 render() {
talig8e9c0652017-12-20 14:30:43 +020064 let {isDisplayModal, modalHeader, licensingDataList, selectedTab, onTabSelect, orphanDataList, isReadOnlyMode} = this.props;
AviZi280f8012017-06-09 02:39:56 +030065 let selectedInUse = selectedTab !== selectedButton.NOT_IN_USE;
ilanapc6a41de2017-11-07 11:54:10 +020066 let dataList = selectedInUse ? licensingDataList : orphanDataList;
AviZi280f8012017-06-09 02:39:56 +030067 return(
68 <div className='license-model-overview'>
talig8e9c0652017-12-20 14:30:43 +020069 <SummaryView isReadOnlyMode={isReadOnlyMode}/>
AviZi280f8012017-06-09 02:39:56 +030070 <div className={classNames('overview-list-section ', !selectedInUse ? 'overview-list-orphans' : '' )}>
71 <div className='vlm-list-tab-panel'>
ilanapc6a41de2017-11-07 11:54:10 +020072 <ListButtons onTabSelect={onTabSelect}
73 selectedTab={selectedTab}
74 hasOrphans={orphanDataList.length > 0}
75 hasLicensing={licensingDataList.length > 0}/>
AviZi280f8012017-06-09 02:39:56 +030076 </div>
ilanapc6a41de2017-11-07 11:54:10 +020077 <VLMListView licensingDataList={dataList} showInUse={selectedInUse}/>
AviZi280f8012017-06-09 02:39:56 +030078 </div>
79 {
80 isDisplayModal &&
Avi Ziv61070c92017-07-26 17:37:57 +030081 <Modal show={isDisplayModal} bsSize='large' animation={true} className={classNames('onborading-modal license-model-modal', setModalClassName(modalHeader))}>
AviZi280f8012017-06-09 02:39:56 +030082 <Modal.Header>
83 <Modal.Title>{`${i18n('Create New ')}${i18n(modalHeader)}`}</Modal.Title>
84 </Modal.Header>
85 <Modal.Body>
86 {this.renderModalBody(modalHeader)}
87 </Modal.Body>
88 </Modal>
89 }
90 </div>
91 );
92 }
93
94 renderModalBody(modalHeader) {
talig8e9c0652017-12-20 14:30:43 +020095 let {licenseModelId, version, isReadOnlyMode} = this.props;
AviZi280f8012017-06-09 02:39:56 +030096 switch (modalHeader) {
97 case overviewEditorHeaders.ENTITLEMENT_POOL:
talig8e9c0652017-12-20 14:30:43 +020098 return <EntitlementPoolsEditor version={version} licenseModelId={licenseModelId} isReadOnlyMode={isReadOnlyMode}/>;
AviZi280f8012017-06-09 02:39:56 +030099 case overviewEditorHeaders.LICENSE_AGREEMENT:
talig8e9c0652017-12-20 14:30:43 +0200100 return <LicenseAgreementEditor version={version} licenseModelId={licenseModelId} isReadOnlyMode={isReadOnlyMode}/>;
AviZi280f8012017-06-09 02:39:56 +0300101 case overviewEditorHeaders.FEATURE_GROUP:
talig8e9c0652017-12-20 14:30:43 +0200102 return <FeatureGroupEditor version={version} licenseModelId={licenseModelId} isReadOnlyMode={isReadOnlyMode}/>;
AviZi280f8012017-06-09 02:39:56 +0300103 case overviewEditorHeaders.LICENSE_KEY_GROUP:
talig8e9c0652017-12-20 14:30:43 +0200104 return <LicenseKeyGroupsEditor version={version} licenseModelId={licenseModelId} isReadOnlyMode={isReadOnlyMode}/>;
AviZi280f8012017-06-09 02:39:56 +0300105 }
106 }
107}
108
109export default LicenseModelOverviewView;