AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 1 | /*! |
| 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 | */ |
| 16 | import React from 'react'; |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 17 | import PropTypes from 'prop-types'; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 18 | import i18n from 'nfvo-utils/i18n/i18n.js'; |
| 19 | import Modal from 'nfvo-components/modal/Modal.jsx'; |
| 20 | import classNames from 'classnames'; |
| 21 | |
| 22 | import EntitlementPoolsEditor from '../entitlementPools/EntitlementPoolsEditor.js'; |
| 23 | import FeatureGroupEditor from '../featureGroups/FeatureGroupEditor.js'; |
| 24 | import LicenseAgreementEditor from '../licenseAgreement/LicenseAgreementEditor.js'; |
| 25 | import LicenseKeyGroupsEditor from '../licenseKeyGroups/LicenseKeyGroupsEditor.js'; |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame^] | 26 | import { |
| 27 | overviewEditorHeaders, |
| 28 | selectedButton |
| 29 | } from './LicenseModelOverviewConstants.js'; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 30 | |
| 31 | import SummaryView from './SummaryView.jsx'; |
| 32 | import VLMListView from './VLMListView.jsx'; |
| 33 | import ListButtons from './summary/ListButtons.jsx'; |
| 34 | |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame^] | 35 | const 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 | } |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 48 | }; |
| 49 | |
| 50 | class LicenseModelOverviewView extends React.Component { |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame^] | 51 | 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 | }; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 63 | |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame^] | 64 | 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 | } |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 119 | |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame^] | 120 | 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 | } |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 157 | } |
| 158 | |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame^] | 159 | export default LicenseModelOverviewView; |