blob: 689936059760919c2a4c22c66397635d922b365d [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';
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020026import {
27 overviewEditorHeaders,
28 selectedButton
29} from './LicenseModelOverviewConstants.js';
AviZi280f8012017-06-09 02:39:56 +030030
31import SummaryView from './SummaryView.jsx';
32import VLMListView from './VLMListView.jsx';
33import ListButtons from './summary/ListButtons.jsx';
34
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020035const setModalClassName = modalHeader => {
36 switch (modalHeader) {
37 case overviewEditorHeaders.ENTITLEMENT_POOL:
38 return 'entitlement-pools-modal';
39 case overviewEditorHeaders.LICENSE_AGREEMENT:
40 return 'license-agreement-modal';
41 case overviewEditorHeaders.FEATURE_GROUP:
42 return 'feature-group-modal';
43 case overviewEditorHeaders.LICENSE_KEY_GROUP:
44 return 'license-key-groups-modal';
45 default:
46 return '';
47 }
AviZi280f8012017-06-09 02:39:56 +030048};
49
50class LicenseModelOverviewView extends React.Component {
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020051 static propTypes = {
52 isDisplayModal: PropTypes.bool,
53 isReadOnlyMode: PropTypes.bool,
54 licenseModelId: PropTypes.string,
55 licensingDataList: PropTypes.array,
56 orphanDataList: PropTypes.array,
57 modalHeader: PropTypes.string,
58 selectedTab: PropTypes.string,
59 onTabSelect: PropTypes.func,
60 onCallVCAction: PropTypes.func,
61 onClose: PropTypes.func
62 };
AviZi280f8012017-06-09 02:39:56 +030063
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020064 render() {
65 let {
66 isDisplayModal,
67 modalHeader,
68 licensingDataList,
69 selectedTab,
70 onTabSelect,
71 orphanDataList,
72 isReadOnlyMode
73 } = this.props;
74 let selectedInUse = selectedTab !== selectedButton.NOT_IN_USE;
75 let dataList = selectedInUse ? licensingDataList : orphanDataList;
76 return (
77 <div className="license-model-overview">
78 <SummaryView isReadOnlyMode={isReadOnlyMode} />
79 <div
80 className={classNames(
81 'overview-list-section ',
82 !selectedInUse ? 'overview-list-orphans' : ''
83 )}>
84 <div className="vlm-list-tab-panel">
85 <ListButtons
86 onTabSelect={onTabSelect}
87 selectedTab={selectedTab}
88 hasOrphans={orphanDataList.length > 0}
89 hasLicensing={licensingDataList.length > 0}
90 />
91 </div>
92 <VLMListView
93 licensingDataList={dataList}
94 showInUse={selectedInUse}
95 />
96 </div>
97 {isDisplayModal && (
98 <Modal
99 show={isDisplayModal}
100 bsSize="large"
101 animation={true}
102 className={classNames(
103 'onborading-modal license-model-modal',
104 setModalClassName(modalHeader)
105 )}>
106 <Modal.Header>
107 <Modal.Title>{`${i18n('Create New ')}${i18n(
108 modalHeader
109 )}`}</Modal.Title>
110 </Modal.Header>
111 <Modal.Body>
112 {this.renderModalBody(modalHeader)}
113 </Modal.Body>
114 </Modal>
115 )}
116 </div>
117 );
118 }
AviZi280f8012017-06-09 02:39:56 +0300119
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200120 renderModalBody(modalHeader) {
121 let { licenseModelId, version, isReadOnlyMode } = this.props;
122 switch (modalHeader) {
123 case overviewEditorHeaders.ENTITLEMENT_POOL:
124 return (
125 <EntitlementPoolsEditor
126 version={version}
127 licenseModelId={licenseModelId}
128 isReadOnlyMode={isReadOnlyMode}
129 />
130 );
131 case overviewEditorHeaders.LICENSE_AGREEMENT:
132 return (
133 <LicenseAgreementEditor
134 version={version}
135 licenseModelId={licenseModelId}
136 isReadOnlyMode={isReadOnlyMode}
137 />
138 );
139 case overviewEditorHeaders.FEATURE_GROUP:
140 return (
141 <FeatureGroupEditor
142 version={version}
143 licenseModelId={licenseModelId}
144 isReadOnlyMode={isReadOnlyMode}
145 />
146 );
147 case overviewEditorHeaders.LICENSE_KEY_GROUP:
148 return (
149 <LicenseKeyGroupsEditor
150 version={version}
151 licenseModelId={licenseModelId}
152 isReadOnlyMode={isReadOnlyMode}
153 />
154 );
155 }
156 }
AviZi280f8012017-06-09 02:39:56 +0300157}
158
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200159export default LicenseModelOverviewView;