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 PropTypes from 'prop-types';
18 import { connect } from 'react-redux';
19 import Input from 'nfvo-components/input/validation/InputWrapper.jsx';
21 import LicenseModelActionHelper from './onboarding/licenseModel/LicenseModelActionHelper.js';
22 import LicenseAgreementListEditor from './onboarding/licenseModel/licenseAgreement/LicenseAgreementListEditor.js';
23 import LicenseAgreementActionHelper from './onboarding/licenseModel/licenseAgreement/LicenseAgreementActionHelper.js';
24 import FeatureGroupListEditor from './onboarding/licenseModel/featureGroups/FeatureGroupListEditor.js';
25 import FeatureGroupsActionHelper from './onboarding/licenseModel/featureGroups/FeatureGroupsActionHelper.js';
26 import LicenseKeyGroupsListEditor from './onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsListEditor.js';
27 import LicenseKeyGroupsActionHelper from './onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsActionHelper.js';
28 import EntitlementPoolsListEditor from './onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditor.js';
29 import EntitlementPoolsActionHelper from './onboarding/licenseModel/entitlementPools/EntitlementPoolsActionHelper.js';
30 import SoftwareProductLandingPage from './onboarding/softwareProduct/landingPage/SoftwareProductLandingPage.js';
31 import SoftwareProductDetails from './onboarding/softwareProduct/details/SoftwareProductDetails.js';
32 import Onboard from './onboarding/onboard/Onboard.js';
33 import SoftwareProductActionHelper from './onboarding/softwareProduct/SoftwareProductActionHelper.js';
34 import FlowsListEditor from './flows/FlowsListEditor.js';
35 import FlowsActions from './flows/FlowsActions.js';
37 const mapStateToProps = ({ licenseModelList }) => {
38 return { licenseModelList };
41 const mapActionsToProps = dispatch => {
44 LicenseModelActionHelper.fetchLicenseModels(dispatch),
45 onLicenseAgreementListEditor: licenseModelId =>
46 LicenseAgreementActionHelper.fetchLicenseAgreementList(dispatch, {
49 onFeatureGroupsListEditor: licenseModelId =>
50 FeatureGroupsActionHelper.fetchFeatureGroupsList(dispatch, {
53 onLicenseKeyGroupsListEditor: licenseModelId =>
54 LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(dispatch, {
57 onEntitlementPoolsListEditor: licenseModelId =>
58 EntitlementPoolsActionHelper.fetchEntitlementPoolsList(dispatch, {
61 onOnboardingCatalog: () =>
62 SoftwareProductActionHelper.fetchSoftwareProductList(dispatch),
63 onSoftwareProductDetails: () =>
64 SoftwareProductActionHelper.fetchSoftwareProductCategories(
67 onFlowsListEditor: () => FlowsActions.fetchFlows(dispatch)
71 class ModuleOptions extends React.Component {
73 onBootstrapped: PropTypes.func.isRequired,
74 onLicenseAgreementListEditor: PropTypes.func.isRequired,
75 onFeatureGroupsListEditor: PropTypes.func.isRequired,
76 onLicenseKeyGroupsListEditor: PropTypes.func.isRequired,
77 onEntitlementPoolsListEditor: PropTypes.func.isRequired,
78 onOnboardingCatalog: PropTypes.func.isRequired,
79 onSoftwareProductDetails: PropTypes.func.isRequired
83 currentModule: localStorage.getItem('default-module'),
84 licenseModelId: localStorage.getItem('default-license-model-id')
88 this.props.onBootstrapped();
92 let { currentModule, licenseModelId } = this.state;
93 let { licenseModelList } = this.props;
95 <div style={{ marginTop: 20 }}>
98 value={licenseModelId}
101 onChange={this.handleLicenseModelIdChange}
102 className="inner-pagination select-input">
103 <option value="" key={null}>
106 {licenseModelList.map(({ id, vendorName }) => (
109 key={id}>{`${vendorName} License Model`}</option>
114 value={currentModule}
117 onChange={this.handleModuleSelection}
118 className="inner-pagination select-input">
119 <option value="">Select Module</option>
120 <option value="EntitlementPoolsListEditor">
123 <option value="LicenseAgreementListEditor">
126 <option value="FutureGroupListEditor">
129 <option value="LicenseKeyGroupsListEditor">
132 <option value="SoftwareProductLanding">
133 Software Product Landing
135 <option value="SoftwareProductDetails">
136 Software Product Details
138 <option value="OnboardingCatalog">
141 <option value="Flows">Flows</option>
144 className="sub-module-view"
148 borderTop: '1px solid silver'
150 {this.renderModule(currentModule)}
156 renderModule(currentModule) {
157 const { licenseModelId } = this.state;
158 if (!licenseModelId) {
162 switch (currentModule) {
163 case 'LicenseAgreementListEditor':
164 this.props.onLicenseAgreementListEditor(licenseModelId);
166 <LicenseAgreementListEditor
167 licenseModelId={licenseModelId}
170 case 'FutureGroupListEditor':
171 this.props.onFeatureGroupsListEditor(licenseModelId);
173 <FeatureGroupListEditor licenseModelId={licenseModelId} />
175 case 'EntitlementPoolsListEditor':
176 this.props.onEntitlementPoolsListEditor(licenseModelId);
178 <EntitlementPoolsListEditor
179 licenseModelId={licenseModelId}
182 case 'LicenseKeyGroupsListEditor':
183 this.props.onLicenseKeyGroupsListEditor(licenseModelId);
185 <LicenseKeyGroupsListEditor
186 licenseModelId={licenseModelId}
189 case 'SoftwareProductLanding':
191 <SoftwareProductLandingPage
192 licenseModelId={licenseModelId}
195 case 'SoftwareProductDetails':
196 this.props.onSoftwareProductDetails(licenseModelId);
198 <SoftwareProductDetails licenseModelId={licenseModelId} />
200 case 'OnboardingCatalog':
201 this.props.onOnboardingCatalog();
204 this.props.onFlowsListEditor();
205 return <FlowsListEditor />;
211 handleModuleSelection = () => {
212 let selectedModule = this.refs.selectedModule.getValue();
213 localStorage.setItem('default-module', selectedModule);
214 this.setState({ currentModule: selectedModule });
217 handleLicenseModelIdChange = () => {
218 let licenseModelId = this.refs.licenseModelId.getValue();
219 localStorage.setItem('default-license-model-id', licenseModelId);
220 this.setState({ licenseModelId });
224 export default connect(mapStateToProps, mapActionsToProps)(ModuleOptions);