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'; |
| 26 | import {overviewEditorHeaders, selectedButton} from './LicenseModelOverviewConstants.js'; |
| 27 | |
| 28 | import SummaryView from './SummaryView.jsx'; |
| 29 | import VLMListView from './VLMListView.jsx'; |
| 30 | import ListButtons from './summary/ListButtons.jsx'; |
| 31 | |
| 32 | |
| 33 | const 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 | |
| 48 | class LicenseModelOverviewView extends React.Component { |
| 49 | |
| 50 | static propTypes = { |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame^] | 51 | 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 |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 61 | }; |
| 62 | |
| 63 | render() { |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame^] | 64 | let {isDisplayModal, modalHeader, licensingDataList, selectedTab, onTabSelect, orphanDataList, isReadOnlyMode} = this.props; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 65 | let selectedInUse = selectedTab !== selectedButton.NOT_IN_USE; |
ilanap | c6a41de | 2017-11-07 11:54:10 +0200 | [diff] [blame] | 66 | let dataList = selectedInUse ? licensingDataList : orphanDataList; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 67 | return( |
| 68 | <div className='license-model-overview'> |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame^] | 69 | <SummaryView isReadOnlyMode={isReadOnlyMode}/> |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 70 | <div className={classNames('overview-list-section ', !selectedInUse ? 'overview-list-orphans' : '' )}> |
| 71 | <div className='vlm-list-tab-panel'> |
ilanap | c6a41de | 2017-11-07 11:54:10 +0200 | [diff] [blame] | 72 | <ListButtons onTabSelect={onTabSelect} |
| 73 | selectedTab={selectedTab} |
| 74 | hasOrphans={orphanDataList.length > 0} |
| 75 | hasLicensing={licensingDataList.length > 0}/> |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 76 | </div> |
ilanap | c6a41de | 2017-11-07 11:54:10 +0200 | [diff] [blame] | 77 | <VLMListView licensingDataList={dataList} showInUse={selectedInUse}/> |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 78 | </div> |
| 79 | { |
| 80 | isDisplayModal && |
Avi Ziv | 61070c9 | 2017-07-26 17:37:57 +0300 | [diff] [blame] | 81 | <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] | 82 | <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) { |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame^] | 95 | let {licenseModelId, version, isReadOnlyMode} = this.props; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 96 | switch (modalHeader) { |
| 97 | case overviewEditorHeaders.ENTITLEMENT_POOL: |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame^] | 98 | return <EntitlementPoolsEditor version={version} licenseModelId={licenseModelId} isReadOnlyMode={isReadOnlyMode}/>; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 99 | case overviewEditorHeaders.LICENSE_AGREEMENT: |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame^] | 100 | return <LicenseAgreementEditor version={version} licenseModelId={licenseModelId} isReadOnlyMode={isReadOnlyMode}/>; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 101 | case overviewEditorHeaders.FEATURE_GROUP: |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame^] | 102 | return <FeatureGroupEditor version={version} licenseModelId={licenseModelId} isReadOnlyMode={isReadOnlyMode}/>; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 103 | case overviewEditorHeaders.LICENSE_KEY_GROUP: |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame^] | 104 | return <LicenseKeyGroupsEditor version={version} licenseModelId={licenseModelId} isReadOnlyMode={isReadOnlyMode}/>; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 105 | } |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | export default LicenseModelOverviewView; |