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'; |
| 17 | import i18n from 'nfvo-utils/i18n/i18n.js'; |
| 18 | import Modal from 'nfvo-components/modal/Modal.jsx'; |
| 19 | import classNames from 'classnames'; |
| 20 | |
| 21 | import EntitlementPoolsEditor from '../entitlementPools/EntitlementPoolsEditor.js'; |
| 22 | import FeatureGroupEditor from '../featureGroups/FeatureGroupEditor.js'; |
| 23 | import LicenseAgreementEditor from '../licenseAgreement/LicenseAgreementEditor.js'; |
| 24 | import LicenseKeyGroupsEditor from '../licenseKeyGroups/LicenseKeyGroupsEditor.js'; |
| 25 | import {overviewEditorHeaders, selectedButton} from './LicenseModelOverviewConstants.js'; |
| 26 | |
| 27 | import SummaryView from './SummaryView.jsx'; |
| 28 | import VLMListView from './VLMListView.jsx'; |
| 29 | import ListButtons from './summary/ListButtons.jsx'; |
| 30 | |
| 31 | |
| 32 | const 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 | |
| 47 | class 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, |
ilanap | c6a41de | 2017-11-07 11:54:10 +0200 | [diff] [blame] | 54 | orphanDataList: React.PropTypes.array, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 55 | modalHeader: React.PropTypes.string, |
Avi Ziv | 61070c9 | 2017-07-26 17:37:57 +0300 | [diff] [blame] | 56 | selectedTab: React.PropTypes.string, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 57 | onTabSelect: React.PropTypes.func, |
| 58 | onCallVCAction: React.PropTypes.func, |
| 59 | onClose: React.PropTypes.func |
| 60 | }; |
| 61 | |
| 62 | render() { |
ilanap | c6a41de | 2017-11-07 11:54:10 +0200 | [diff] [blame] | 63 | let {isDisplayModal, modalHeader, licensingDataList, selectedTab, onTabSelect, orphanDataList} = this.props; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 64 | let selectedInUse = selectedTab !== selectedButton.NOT_IN_USE; |
ilanap | c6a41de | 2017-11-07 11:54:10 +0200 | [diff] [blame] | 65 | let dataList = selectedInUse ? licensingDataList : orphanDataList; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 66 | return( |
| 67 | <div className='license-model-overview'> |
| 68 | <SummaryView/> |
| 69 | <div className={classNames('overview-list-section ', !selectedInUse ? 'overview-list-orphans' : '' )}> |
| 70 | <div className='vlm-list-tab-panel'> |
ilanap | c6a41de | 2017-11-07 11:54:10 +0200 | [diff] [blame] | 71 | <ListButtons onTabSelect={onTabSelect} |
| 72 | selectedTab={selectedTab} |
| 73 | hasOrphans={orphanDataList.length > 0} |
| 74 | hasLicensing={licensingDataList.length > 0}/> |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 75 | </div> |
ilanap | c6a41de | 2017-11-07 11:54:10 +0200 | [diff] [blame] | 76 | <VLMListView licensingDataList={dataList} showInUse={selectedInUse}/> |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 77 | </div> |
| 78 | { |
| 79 | isDisplayModal && |
Avi Ziv | 61070c9 | 2017-07-26 17:37:57 +0300 | [diff] [blame] | 80 | <Modal show={isDisplayModal} bsSize='large' animation={true} className={classNames('onborading-modal license-model-modal', setModalClassName(modalHeader))}> |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 81 | <Modal.Header> |
| 82 | <Modal.Title>{`${i18n('Create New ')}${i18n(modalHeader)}`}</Modal.Title> |
| 83 | </Modal.Header> |
| 84 | <Modal.Body> |
| 85 | {this.renderModalBody(modalHeader)} |
| 86 | </Modal.Body> |
| 87 | </Modal> |
| 88 | } |
| 89 | </div> |
| 90 | ); |
| 91 | } |
| 92 | |
| 93 | renderModalBody(modalHeader) { |
| 94 | let {licenseModelId, version} = this.props; |
| 95 | switch (modalHeader) { |
| 96 | case overviewEditorHeaders.ENTITLEMENT_POOL: |
| 97 | return <EntitlementPoolsEditor version={version} licenseModelId={licenseModelId} isReadOnlyMode={false}/>; |
| 98 | case overviewEditorHeaders.LICENSE_AGREEMENT: |
| 99 | return <LicenseAgreementEditor version={version} licenseModelId={licenseModelId} isReadOnlyMode={false}/>; |
| 100 | case overviewEditorHeaders.FEATURE_GROUP: |
| 101 | return <FeatureGroupEditor version={version} licenseModelId={licenseModelId} isReadOnlyMode={false}/>; |
| 102 | case overviewEditorHeaders.LICENSE_KEY_GROUP: |
| 103 | return <LicenseKeyGroupsEditor version={version} licenseModelId={licenseModelId} isReadOnlyMode={false}/>; |
| 104 | } |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | export default LicenseModelOverviewView; |