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, |
| 54 | modalHeader: React.PropTypes.string, |
Avi Ziv | 61070c9 | 2017-07-26 17:37:57 +0300 | [diff] [blame^] | 55 | selectedTab: React.PropTypes.string, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 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'> |
Avi Ziv | 61070c9 | 2017-07-26 17:37:57 +0300 | [diff] [blame^] | 70 | <ListButtons onTabSelect={onTabSelect} selectedTab={selectedTab}/> |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 71 | </div> |
| 72 | <VLMListView licensingDataList={licensingDataList} showInUse={selectedInUse}/> |
| 73 | </div> |
| 74 | { |
| 75 | isDisplayModal && |
Avi Ziv | 61070c9 | 2017-07-26 17:37:57 +0300 | [diff] [blame^] | 76 | <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] | 77 | <Modal.Header> |
| 78 | <Modal.Title>{`${i18n('Create New ')}${i18n(modalHeader)}`}</Modal.Title> |
| 79 | </Modal.Header> |
| 80 | <Modal.Body> |
| 81 | {this.renderModalBody(modalHeader)} |
| 82 | </Modal.Body> |
| 83 | </Modal> |
| 84 | } |
| 85 | </div> |
| 86 | ); |
| 87 | } |
| 88 | |
| 89 | renderModalBody(modalHeader) { |
| 90 | let {licenseModelId, version} = this.props; |
| 91 | switch (modalHeader) { |
| 92 | case overviewEditorHeaders.ENTITLEMENT_POOL: |
| 93 | return <EntitlementPoolsEditor version={version} licenseModelId={licenseModelId} isReadOnlyMode={false}/>; |
| 94 | case overviewEditorHeaders.LICENSE_AGREEMENT: |
| 95 | return <LicenseAgreementEditor version={version} licenseModelId={licenseModelId} isReadOnlyMode={false}/>; |
| 96 | case overviewEditorHeaders.FEATURE_GROUP: |
| 97 | return <FeatureGroupEditor version={version} licenseModelId={licenseModelId} isReadOnlyMode={false}/>; |
| 98 | case overviewEditorHeaders.LICENSE_KEY_GROUP: |
| 99 | return <LicenseKeyGroupsEditor version={version} licenseModelId={licenseModelId} isReadOnlyMode={false}/>; |
| 100 | } |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | export default LicenseModelOverviewView; |