1 import React, {Component, PropTypes} from 'react';
3 import i18n from 'nfvo-utils/i18n/i18n.js';
4 import Form from 'nfvo-components/input/validation/ValidationForm.jsx';
5 import ValidationInput from 'nfvo-components/input/validation/ValidationInput.jsx';
6 import SoftwareProductCategoriesHelper from 'sdc-app/onboarding/softwareProduct/SoftwareProductCategoriesHelper.js';
8 class SoftwareProductDetails extends Component {
11 vendorName: PropTypes.string,
12 currentSoftwareProduct: PropTypes.shape({
14 name: PropTypes.string,
15 description: PropTypes.string,
16 category: PropTypes.string,
17 subCategory: PropTypes.string,
18 vendorId: PropTypes.string,
19 vendorName: PropTypes.string,
20 licensingVersion: PropTypes.string,
21 licensingData: PropTypes.shape({
22 licenceAgreement: PropTypes.string,
23 featureGroups: PropTypes.array
26 softwareProductCategories: PropTypes.array,
27 finalizedLicenseModelList: PropTypes.array,
28 licenseAgreementList: PropTypes.array,
29 featureGroupsList: PropTypes.array,
30 onSubmit: PropTypes.func.isRequired,
31 onDataChanged: PropTypes.func.isRequired,
32 onValidityChanged: PropTypes.func.isRequired,
33 qdata: PropTypes.object.isRequired,
34 qschema: PropTypes.object.isRequired,
35 onQDataChanged: PropTypes.func.isRequired,
36 onVendorParamChanged: PropTypes.func.isRequired
40 licensingVersionsList: []
44 let {softwareProductCategories, finalizedLicenseModelList, onDataChanged, featureGroupsList, licenseAgreementList, currentSoftwareProduct} = this.props;
45 let {name, description, vendorId, licensingVersion, subCategory, licensingData = {}} = currentSoftwareProduct;
46 let licensingVersionsList = this.state.licensingVersionsList.length > 0 ? this.state.licensingVersionsList : this.refreshVendorVersionsList(vendorId);
47 let {qdata, qschema, onQDataChanged} = this.props;
48 let {isReadOnlyMode} = this.props;
51 <div className='vsp-details-page'>
54 className='vsp-general-tab'
56 onSubmit={() => this.props.onSubmit(currentSoftwareProduct, qdata)}
57 onValidityChanged={(isValidityData) => this.props.onValidityChanged(isValidityData)}
58 isReadOnlyMode={isReadOnlyMode}>
59 <div className='section-title general'>{i18n('General')}</div>
60 <div className='vsp-general-tab-inline-section'>
61 <div className='vsp-general-tab-sub-section'>
66 onChange={name => onDataChanged({name})}
67 validations={{validateName: true, maxLength: 120, required: true}}
68 className='field-section'/>
70 label={i18n('Vendor')}
72 selectedEnum={vendorId}
73 onEnumChange={vendorId => this.onVendorParamChanged({vendorId})}
74 className='field-section'>
75 {finalizedLicenseModelList.map(lm => <option key={lm.id} value={lm.id}>{lm.vendorName}</option>)}
77 <div className='input-row'>
79 label={i18n('Category')}
81 selectedEnum={subCategory}
82 onEnumChange={subCategory => this.onSelectSubCategory(subCategory)}
83 className='field-section'>
85 softwareProductCategories.map(category =>
86 category.subcategories &&
89 label={category.name}>{category.subcategories.map(sub =>
92 value={sub.uniqueId}>{`${sub.name} (${category.name})`}</option>)}
99 <div className='vsp-general-tab-sub-section input-row'>
101 label={i18n('Description')}
104 onChange={description => onDataChanged({description})}
105 className='field-section'
106 validations={{required: true}}/>
109 <div className='vsp-general-tab-section licenses'>
110 <div className='section-title'>{i18n('Licenses')}</div>
111 <div className='vsp-general-tab-inline-section input-row'>
113 onEnumChange={licensingVersion => this.onVendorParamChanged({vendorId, licensingVersion})}
114 selectedEnum={licensingVersion}
115 label={i18n('Licensing Version')}
116 values={licensingVersionsList}
118 className='field-section'/>
120 label={i18n('License Agreement')}
122 selectedEnum={licensingData.licenseAgreement}
123 className='field-section'
124 onEnumChange={(licenseAgreement) => this.onLicensingDataChanged({licenseAgreement, featureGroups: []})}>
125 <option key='placeholder' value=''>{i18n('Select...')}</option>
126 {licenseAgreementList.map(la => <option value={la.id} key={la.id}>{la.name}</option>)}
129 <div className='vsp-general-tab-inline-section input-row'>
130 {licensingData.licenseAgreement && (
134 onEnumChange={featureGroups => this.onFeatureGroupsChanged({featureGroups})}
135 multiSelectedEnum={licensingData.featureGroups}
136 name='feature-groups'
137 label={i18n('Feature Groups')}
139 values={featureGroupsList}/>)
147 onDataChanged={onQDataChanged}
148 className='vsp-general-tab'
150 isReadOnlyMode={isReadOnlyMode}>
151 <div className='vsp-general-tab-section'>
152 <div className='section-title'> {i18n('Availability')} </div>
153 <div className='vsp-general-tab-inline-section'>
154 <div className='vsp-general-tab-sub-section input-row'>
156 label={i18n('Use Availability Zones for High Availability')}
158 pointer='/general/availability/useAvailabilityZonesForHighAvailability'/>
161 <div className='section-title'> {i18n('Regions')} </div>
162 <div className='vsp-general-tab-inline-section'>
163 <div className='vsp-general-tab-sub-section input-row'>
167 pointer='/general/regionsData/regions'/>
170 <div className='section-title'> {i18n('Storage Data Replication')} </div>
171 <div className='vsp-general-tab-inline-section'>
172 <div className='vsp-general-tab-sub-section'>
174 label={i18n('Storage Replication Size (GB)')}
176 pointer='/general/storageDataReplication/storageReplicationSize'
177 className='field-section'/>
179 label={i18n('Storage Replication Source')}
181 pointer='/general/storageDataReplication/storageReplicationSource'
182 className='field-section'/>
184 <div className='vsp-general-tab-sub-section'>
186 label={i18n('Storage Replication Frequency (minutes)')}
188 pointer='/general/storageDataReplication/storageReplicationFrequency'
189 className='field-section'/>
191 label={i18n('Storage Replication Destination')}
193 pointer='/general/storageDataReplication/storageReplicationDestination'
194 className='field-section'/>
203 onVendorParamChanged({vendorId, licensingVersion}) {
204 let {finalizedLicenseModelList, onVendorParamChanged} = this.props;
205 if(!licensingVersion) {
206 const licensingVersionsList = this.refreshVendorVersionsList(vendorId);
207 licensingVersion = licensingVersionsList.length > 0 ? licensingVersionsList[0].enum : '';
209 let vendorName = finalizedLicenseModelList.find(licenseModelItem => licenseModelItem.id === vendorId).vendorName || '';
216 onVendorParamChanged(deltaData);
219 refreshVendorVersionsList(vendorId) {
224 let {finalVersions} = this.props.finalizedLicenseModelList.find(vendor => vendor.id === vendorId);
226 let licensingVersionsList = [{
228 title: i18n('Select...')
231 finalVersions.forEach(version => licensingVersionsList.push({
237 return licensingVersionsList;
240 onSelectSubCategory(subCategory) {
241 let {softwareProductCategories, onDataChanged} = this.props;
242 let category = SoftwareProductCategoriesHelper.getCurrentCategoryOfSubCategory(subCategory, softwareProductCategories);
243 onDataChanged({category, subCategory});
246 onFeatureGroupsChanged({featureGroups}) {
247 this.onLicensingDataChanged({featureGroups});
250 onLicensingDataChanged(deltaData) {
251 this.props.onDataChanged({
253 ...this.props.currentSoftwareProduct.licensingData,
260 return this.refs.validationForm.handleFormSubmit(new Event('dummy'));
264 export default SoftwareProductDetails;