1 import React from 'react';
2 import i18n from 'nfvo-utils/i18n/i18n.js';
4 import ValidationForm from 'nfvo-components/input/validation/ValidationForm.jsx';
5 import ValidationInput from 'nfvo-components/input/validation/ValidationInput.jsx';
6 import {optionsInputValues as licenseKeyGroupOptionsInputValues} from './LicenseKeyGroupsConstants.js';
7 import {other as optionInputOther} from 'nfvo-components/input/inputOptions/InputOptions.jsx';
9 const LicenseKeyGroupPropType = React.PropTypes.shape({
10 id: React.PropTypes.string,
11 name: React.PropTypes.string,
12 description: React.PropTypes.string,
13 operationalScope: React.PropTypes.shape({
14 choices: React.PropTypes.array,
15 other: React.PropTypes.string
17 type: React.PropTypes.string
20 class LicenseKeyGroupsEditorView extends React.Component {
22 data: LicenseKeyGroupPropType,
23 previousData: LicenseKeyGroupPropType,
24 isReadOnlyMode: React.PropTypes.bool,
25 onDataChanged: React.PropTypes.func.isRequired,
26 onSubmit: React.PropTypes.func.isRequired,
27 onCancel: React.PropTypes.func.isRequired
30 static defaultProps = {
35 let {data = {}, onDataChanged, isReadOnlyMode} = this.props;
36 let {name, description, operationalScope, type} = data;
41 onSubmit={ () => this.submit() }
42 onReset={ () => this.props.onCancel() }
44 isReadOnlyMode={isReadOnlyMode}
45 className='license-key-groups-form'>
46 <div className='license-key-groups-form-row'>
48 onChange={name => onDataChanged({name})}
52 validations={{maxLength: 120, required: true}}
57 onEnumChange={operationalScope => onDataChanged({operationalScope:{choices: operationalScope, other: ''}})}
58 onOtherChange={operationalScope => onDataChanged({operationalScope:{choices: [optionInputOther.OTHER], other: operationalScope}})}
59 label={i18n('Operational Scope')}
60 validations={{required: true}}
61 multiSelectedEnum={operationalScope && operationalScope.choices}
62 otherValue={operationalScope && operationalScope.other}
63 values={licenseKeyGroupOptionsInputValues.OPERATIONAL_SCOPE}/>
65 <div className='license-key-groups-form-row'>
67 onChange={description => onDataChanged({description})}
69 label={i18n('Description')}
71 validations={{maxLength: 1000, required: true}}
75 onEnumChange={type => onDataChanged({type})}
79 validations={{required: true}}
80 values={licenseKeyGroupOptionsInputValues.TYPE}/>
87 const {data: licenseKeyGroup, previousData: previousLicenseKeyGroup} = this.props;
88 this.props.onSubmit({licenseKeyGroup, previousLicenseKeyGroup});
92 export default LicenseKeyGroupsEditorView;