2 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 import React from 'react';
17 import {connect} from 'react-redux';
18 import Input from 'nfvo-components/input/validation/InputWrapper.jsx';
20 import LicenseModelActionHelper from './onboarding/licenseModel/LicenseModelActionHelper.js';
21 import LicenseAgreementListEditor from './onboarding/licenseModel/licenseAgreement/LicenseAgreementListEditor.js';
22 import LicenseAgreementActionHelper from './onboarding/licenseModel/licenseAgreement/LicenseAgreementActionHelper.js';
23 import FeatureGroupListEditor from './onboarding/licenseModel/featureGroups/FeatureGroupListEditor.js';
24 import FeatureGroupsActionHelper from './onboarding/licenseModel/featureGroups/FeatureGroupsActionHelper.js';
25 import LicenseKeyGroupsListEditor from './onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsListEditor.js';
26 import LicenseKeyGroupsActionHelper from './onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsActionHelper.js';
27 import EntitlementPoolsListEditor from './onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditor.js';
28 import EntitlementPoolsActionHelper from './onboarding/licenseModel/entitlementPools/EntitlementPoolsActionHelper.js';
29 import SoftwareProductLandingPage from './onboarding/softwareProduct/landingPage/SoftwareProductLandingPage.js';
30 import SoftwareProductDetails from './onboarding/softwareProduct/details/SoftwareProductDetails.js';
31 import Onboard from './onboarding/onboard/Onboard.js';
32 import SoftwareProductActionHelper from './onboarding/softwareProduct/SoftwareProductActionHelper.js';
33 import FlowsListEditor from './flows/FlowsListEditor.js';
34 import FlowsActions from './flows/FlowsActions.js';
37 const mapStateToProps = ({licenseModelList}) => {
38 return {licenseModelList};
42 const mapActionsToProps = dispatch => {
44 onBootstrapped: () => LicenseModelActionHelper.fetchLicenseModels(dispatch),
45 onLicenseAgreementListEditor: licenseModelId => LicenseAgreementActionHelper.fetchLicenseAgreementList(dispatch, {licenseModelId}),
46 onFeatureGroupsListEditor: licenseModelId => FeatureGroupsActionHelper.fetchFeatureGroupsList(dispatch, {licenseModelId}),
47 onLicenseKeyGroupsListEditor: licenseModelId =>LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(dispatch, {licenseModelId}),
48 onEntitlementPoolsListEditor: licenseModelId => EntitlementPoolsActionHelper.fetchEntitlementPoolsList(dispatch, {licenseModelId}),
49 onOnboardingCatalog: () => SoftwareProductActionHelper.fetchSoftwareProductList(dispatch),
50 onSoftwareProductDetails: () => SoftwareProductActionHelper.fetchSoftwareProductCategories(dispatch),
51 onFlowsListEditor: () => FlowsActions.fetchFlows(dispatch)
55 class ModuleOptions extends React.Component {
58 onBootstrapped: React.PropTypes.func.isRequired,
59 onLicenseAgreementListEditor: React.PropTypes.func.isRequired,
60 onFeatureGroupsListEditor: React.PropTypes.func.isRequired,
61 onLicenseKeyGroupsListEditor: React.PropTypes.func.isRequired,
62 onEntitlementPoolsListEditor: React.PropTypes.func.isRequired,
63 onOnboardingCatalog: React.PropTypes.func.isRequired,
64 onSoftwareProductDetails: React.PropTypes.func.isRequired,
68 currentModule: localStorage.getItem('default-module'),
69 licenseModelId: localStorage.getItem('default-license-model-id')
73 this.props.onBootstrapped();
77 let {currentModule, licenseModelId} = this.state;
78 let {licenseModelList} = this.props;
80 <div style={{marginTop:20}}>
83 value={licenseModelId}
86 onChange={this.handleLicenseModelIdChange}
87 className='inner-pagination select-input'>
88 <option value='' key={null}>Select License Model</option>
90 licenseModelList.map(({id, vendorName}) => <option value={id} key={id}>{`${vendorName} License Model`}</option>)
98 onChange={this.handleModuleSelection}
99 className='inner-pagination select-input'>
100 <option value=''>Select Module</option>
101 <option value='EntitlementPoolsListEditor'>Entitlement Pools</option>
102 <option value='LicenseAgreementListEditor'>License Agreements</option>
103 <option value='FutureGroupListEditor'>Feature Groups</option>
104 <option value='LicenseKeyGroupsListEditor'>License Key Groups</option>
105 <option value='SoftwareProductLanding'>Software Product Landing</option>
106 <option value='SoftwareProductDetails'>Software Product Details</option>
107 <option value='OnboardingCatalog'>Onboarding Catalog</option>
108 <option value='Flows'>Flows</option>
110 <div className='sub-module-view' style={{paddingTop: 10, margin: 4, borderTop: '1px solid silver'}}>
111 {this.renderModule(currentModule)}
117 renderModule(currentModule) {
118 const {licenseModelId} = this.state;
119 if (!licenseModelId) {
123 switch (currentModule) {
124 case 'LicenseAgreementListEditor':
125 this.props.onLicenseAgreementListEditor(licenseModelId);
126 return <LicenseAgreementListEditor licenseModelId={licenseModelId}/>;
127 case 'FutureGroupListEditor':
128 this.props.onFeatureGroupsListEditor(licenseModelId);
129 return <FeatureGroupListEditor licenseModelId={licenseModelId}/>;
130 case 'EntitlementPoolsListEditor':
131 this.props.onEntitlementPoolsListEditor(licenseModelId);
132 return <EntitlementPoolsListEditor licenseModelId={licenseModelId}/>;
133 case 'LicenseKeyGroupsListEditor':
134 this.props.onLicenseKeyGroupsListEditor(licenseModelId);
135 return <LicenseKeyGroupsListEditor licenseModelId={licenseModelId}/>;
136 case 'SoftwareProductLanding':
137 return <SoftwareProductLandingPage licenseModelId={licenseModelId}/>;
138 case 'SoftwareProductDetails':
139 this.props.onSoftwareProductDetails(licenseModelId);
140 return <SoftwareProductDetails licenseModelId={licenseModelId}/>;
141 case 'OnboardingCatalog':
142 this.props.onOnboardingCatalog();
145 this.props.onFlowsListEditor();
146 return <FlowsListEditor/>;
152 handleModuleSelection = () => {
153 let selectedModule = this.refs.selectedModule.getValue();
154 localStorage.setItem('default-module', selectedModule);
155 this.setState({currentModule: selectedModule});
158 handleLicenseModelIdChange = () => {
159 let licenseModelId = this.refs.licenseModelId.getValue();
160 localStorage.setItem('default-license-model-id', licenseModelId);
161 this.setState({licenseModelId});
165 export default connect(mapStateToProps, mapActionsToProps)(ModuleOptions);