2 * Copyright © 2016-2018 European Support Limited
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.
17 import React from 'react';
18 import i18n from 'nfvo-utils/i18n/i18n.js';
19 import Input from 'nfvo-components/input/validation/Input.jsx';
20 import GridSection from 'nfvo-components/grid/GridSection.jsx';
21 import GridItem from 'nfvo-components/grid/GridItem.jsx';
23 optionsInputValues as licenseKeyGroupOptionsInputValues,
25 } from '../LicenseKeyGroupsConstants.js';
26 import { optionsInputValues as LicenseModelOptionsInputValues } from '../../LicenseModelConstants.js';
27 import { DATE_FORMAT } from 'sdc-app/onboarding/OnboardingConstants.js';
28 import UuId from 'sdc-app/onboarding/licenseModel/components/UuId.jsx';
30 const LicenseKeyGroupFormContent = ({
36 thresholdValueValidation
47 manufacturerReferenceNumber,
52 <GridSection hasLostColSet>
53 <GridItem colSpan={2}>
56 onDataChanged({ name }, LKG_FORM_NAME, {
61 data-test-id="create-lkg-name"
63 isValid={genericFieldInfo.name.isValid}
64 errorText={genericFieldInfo.name.errorText}
69 <GridItem colSpan={2}>
73 const selectedIndex = e.target.selectedIndex;
74 const val = e.target.options[selectedIndex].value;
75 onDataChanged({ type: val }, LKG_FORM_NAME);
79 data-test-id="create-lkg-type"
80 isValid={genericFieldInfo.type.isValid}
81 errorText={genericFieldInfo.type.errorText}
82 groupClassName="bootstrap-input-options"
83 className="input-options-select"
86 {licenseKeyGroupOptionsInputValues.TYPE.map(type => (
87 <option key={type.enum} value={type.enum}>
93 <GridItem colSpan={2} stretch>
95 onChange={description =>
96 onDataChanged({ description }, LKG_FORM_NAME)
98 label={i18n('Description')}
99 data-test-id="create-lkg-description"
101 isValid={genericFieldInfo.description.isValid}
102 errorText={genericFieldInfo.description.errorText}
110 // setting the unit to the correct value
111 const selectedIndex = e.target.selectedIndex;
112 const val = e.target.options[selectedIndex].value;
113 onDataChanged({ thresholdUnits: val }, LKG_FORM_NAME);
114 // TODO make sure that the value is valid too
116 { thresholdValue: thresholdValue },
119 thresholdValue: thresholdValueValidation
123 value={thresholdUnits}
124 label={i18n('Threshold Units')}
125 data-test-id="create-ep-threshold-units"
126 isValid={genericFieldInfo.thresholdUnits.isValid}
127 errorText={genericFieldInfo.thresholdUnits.errorText}
128 groupClassName="bootstrap-input-options"
129 className="input-options-select"
131 {LicenseModelOptionsInputValues.THRESHOLD_UNITS.map(
133 <option key={mtype.enum} value={mtype.enum}>{`${
141 label={i18n('Start Date')}
143 dateFormat={DATE_FORMAT}
144 startDate={startDate}
146 onChange={startDate =>
150 ? startDate.format(DATE_FORMAT)
154 { startDate: validateStartDate }
157 isValid={genericFieldInfo.startDate.isValid}
158 errorText={genericFieldInfo.startDate.errorText}
164 className="entitlement-pools-form-row-threshold-value"
165 onChange={thresholdValue =>
166 onDataChanged({ thresholdValue }, LKG_FORM_NAME, {
167 thresholdValue: thresholdValueValidation
170 label={i18n('Threshold Value')}
171 isValid={genericFieldInfo.thresholdValue.isValid}
172 errorText={genericFieldInfo.thresholdValue.errorText}
173 data-test-id="create-ep-threshold-value"
174 value={thresholdValue}
179 label={i18n('Expiry Date')}
181 dateFormat={DATE_FORMAT}
182 startDate={startDate}
184 onChange={expiryDate => {
187 expiryDate: expiryDate
188 ? expiryDate.format(DATE_FORMAT)
193 onDataChanged({ startDate }, LKG_FORM_NAME, {
194 startDate: validateStartDate
197 isValid={genericFieldInfo.expiryDate.isValid}
198 errorText={genericFieldInfo.expiryDate.errorText}
202 <GridItem colSpan={2}>
204 onChange={manufacturerReferenceNumber =>
206 { manufacturerReferenceNumber },
210 label={i18n('Manufacturer Reference Number')}
211 value={manufacturerReferenceNumber}
212 data-test-id="create-ep-mrn"
214 groupClassName="no-bottom-margin"
217 <GridItem colSpan={2}>
219 onChange={increments =>
220 onDataChanged({ increments }, LKG_FORM_NAME)
222 label={i18n('Increments')}
224 data-test-id="create-ep-increments"
226 groupClassName="no-bottom-margin"
229 {id && versionUUID && <UuId id={id} versionUUID={versionUUID} />}
234 export default LicenseKeyGroupFormContent;