1 import React from 'react';
2 import {connect} from 'react-redux';
3 import Input from 'react-bootstrap/lib/Input.js';
5 import LicenseModelActionHelper from './onboarding/licenseModel/LicenseModelActionHelper.js';
6 import LicenseAgreementListEditor from './onboarding/licenseModel/licenseAgreement/LicenseAgreementListEditor.js';
7 import LicenseAgreementActionHelper from './onboarding/licenseModel/licenseAgreement/LicenseAgreementActionHelper.js';
8 import FeatureGroupListEditor from './onboarding/licenseModel/featureGroups/FeatureGroupListEditor.js';
9 import FeatureGroupsActionHelper from './onboarding/licenseModel/featureGroups/FeatureGroupsActionHelper.js';
10 import LicenseKeyGroupsListEditor from './onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsListEditor.js';
11 import LicenseKeyGroupsActionHelper from './onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsActionHelper.js';
12 import EntitlementPoolsListEditor from './onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditor.js';
13 import EntitlementPoolsActionHelper from './onboarding/licenseModel/entitlementPools/EntitlementPoolsActionHelper.js';
14 import SoftwareProductLandingPage from './onboarding/softwareProduct/landingPage/SoftwareProductLandingPage.js';
15 import SoftwareProductDetails from './onboarding/softwareProduct/details/SoftwareProductDetails.js';
16 import OnboardingCatalog from './onboarding/OnboardingCatalog.js';
17 import SoftwareProductActionHelper from './onboarding/softwareProduct/SoftwareProductActionHelper.js';
18 import FlowsListEditor from './flows/FlowsListEditor.js';
19 import FlowsActions from './flows/FlowsActions.js';
22 const mapStateToProps = ({licenseModelList}) => {
23 return {licenseModelList};
27 const mapActionsToProps = dispatch => {
29 onBootstrapped: () => LicenseModelActionHelper.fetchLicenseModels(dispatch),
30 onLicenseAgreementListEditor: licenseModelId => LicenseAgreementActionHelper.fetchLicenseAgreementList(dispatch, {licenseModelId}),
31 onFeatureGroupsListEditor: licenseModelId => FeatureGroupsActionHelper.fetchFeatureGroupsList(dispatch, {licenseModelId}),
32 onLicenseKeyGroupsListEditor: licenseModelId =>LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(dispatch, {licenseModelId}),
33 onEntitlementPoolsListEditor: licenseModelId => EntitlementPoolsActionHelper.fetchEntitlementPoolsList(dispatch, {licenseModelId}),
34 onOnboardingCatalog: () => SoftwareProductActionHelper.fetchSoftwareProductList(dispatch),
35 onSoftwareProductDetails: () => SoftwareProductActionHelper.fetchSoftwareProductCategories(dispatch),
36 onFlowsListEditor: () => FlowsActions.fetchFlows(dispatch)
40 class ModuleOptions extends React.Component {
43 onBootstrapped: React.PropTypes.func.isRequired,
44 onLicenseAgreementListEditor: React.PropTypes.func.isRequired,
45 onFeatureGroupsListEditor: React.PropTypes.func.isRequired,
46 onLicenseKeyGroupsListEditor: React.PropTypes.func.isRequired,
47 onEntitlementPoolsListEditor: React.PropTypes.func.isRequired,
48 onOnboardingCatalog: React.PropTypes.func.isRequired,
49 onSoftwareProductDetails: React.PropTypes.func.isRequired,
53 currentModule: localStorage.getItem('default-module'),
54 licenseModelId: localStorage.getItem('default-license-model-id')
58 this.props.onBootstrapped();
62 let {currentModule, licenseModelId} = this.state;
63 let {licenseModelList} = this.props;
65 <div style={{marginTop:20}}>
68 value={licenseModelId}
71 onChange={this.handleLicenseModelIdChange}
72 className='inner-pagination select-input'>
73 <option value='' key={null}>Select License Model</option>
75 licenseModelList.map(({id, vendorName}) => <option value={id} key={id}>{`${vendorName} License Model`}</option>)
83 onChange={this.handleModuleSelection}
84 className='inner-pagination select-input'>
85 <option value=''>Select Module</option>
86 <option value='EntitlementPoolsListEditor'>Entitlement Pools</option>
87 <option value='LicenseAgreementListEditor'>License Agreements</option>
88 <option value='FutureGroupListEditor'>Feature Groups</option>
89 <option value='LicenseKeyGroupsListEditor'>License Key Groups</option>
90 <option value='SoftwareProductLanding'>Software Product Landing</option>
91 <option value='SoftwareProductDetails'>Software Product Details</option>
92 <option value='OnboardingCatalog'>Onboarding Catalog</option>
93 <option value='Flows'>Flows</option>
95 <div className='sub-module-view' style={{paddingTop: 10, margin: 4, borderTop: '1px solid silver'}}>
96 {this.renderModule(currentModule)}
102 renderModule(currentModule) {
103 const {licenseModelId} = this.state;
104 if (!licenseModelId) {
108 switch (currentModule) {
109 case 'LicenseAgreementListEditor':
110 this.props.onLicenseAgreementListEditor(licenseModelId);
111 return <LicenseAgreementListEditor licenseModelId={licenseModelId}/>;
112 case 'FutureGroupListEditor':
113 this.props.onFeatureGroupsListEditor(licenseModelId);
114 return <FeatureGroupListEditor licenseModelId={licenseModelId}/>;
115 case 'EntitlementPoolsListEditor':
116 this.props.onEntitlementPoolsListEditor(licenseModelId);
117 return <EntitlementPoolsListEditor licenseModelId={licenseModelId}/>;
118 case 'LicenseKeyGroupsListEditor':
119 this.props.onLicenseKeyGroupsListEditor(licenseModelId);
120 return <LicenseKeyGroupsListEditor licenseModelId={licenseModelId}/>;
121 case 'SoftwareProductLanding':
122 return <SoftwareProductLandingPage licenseModelId={licenseModelId}/>;
123 case 'SoftwareProductDetails':
124 this.props.onSoftwareProductDetails(licenseModelId);
125 return <SoftwareProductDetails licenseModelId={licenseModelId}/>;
126 case 'OnboardingCatalog':
127 this.props.onOnboardingCatalog();
128 return <OnboardingCatalog/>;
130 this.props.onFlowsListEditor();
131 return <FlowsListEditor/>;
137 handleModuleSelection = () => {
138 let selectedModule = this.refs.selectedModule.getValue();
139 localStorage.setItem('default-module', selectedModule);
140 this.setState({currentModule: selectedModule});
143 handleLicenseModelIdChange = () => {
144 let licenseModelId = this.refs.licenseModelId.getValue();
145 localStorage.setItem('default-license-model-id', licenseModelId);
146 this.setState({licenseModelId});
150 export default connect(mapStateToProps, mapActionsToProps)(ModuleOptions);