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 or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 import React from 'react';
17 import PropTypes from 'prop-types';
18 import i18n from 'nfvo-utils/i18n/i18n.js';
19 import Input from 'nfvo-components/input/validation/Input.jsx';
20 import Form from 'nfvo-components/input/validation/Form.jsx';
22 const VersionPropType = PropTypes.shape({
23 name: PropTypes.string,
24 description: PropTypes.string,
25 creationMethod: PropTypes.string
28 class VersionsPageCreationView extends React.Component {
30 data: VersionPropType,
31 availableMethods: PropTypes.array,
32 onDataChanged: PropTypes.func.isRequired,
33 onSubmit: PropTypes.func.isRequired,
34 onCancel: PropTypes.func.isRequired
45 let { additionalInfo: { OptionalCreationMethods } } = baseVersion;
46 let { description, creationMethod } = data;
49 <div className="version-creation-page">
50 {genericFieldInfo && (
52 ref={validationForm =>
53 (this.validationForm = validationForm)
56 btnClassName="sdc-modal__footer"
57 onSubmit={() => this.submit()}
58 submitButtonText={i18n('Create')}
59 onReset={() => onCancel()}
61 isValid={this.props.isFormValid}
62 formReady={this.props.formReady}
63 onValidateForm={() => this.validate()}>
64 <div className="version-form-row">
66 label={i18n('Version Category')}
67 value={creationMethod}
68 onChange={e => this.onSelectMethod(e)}
71 data-test-id="new-version-category"
73 genericFieldInfo.creationMethod.isValid
76 genericFieldInfo.creationMethod.errorText
79 <option key="" value="">
80 {i18n('Please select…')}
82 {OptionalCreationMethods.map(method => (
83 <option key={method} value={method}>
90 <div className="version-form-row">
92 label={i18n('Description')}
96 data-test-id="new-version-description"
97 isValid={genericFieldInfo.description.isValid}
99 genericFieldInfo.description.errorText
101 onChange={description =>
102 onDataChanged({ description })
105 groupClassName="no-bottom-margin"
115 const selectedIndex = e.target.selectedIndex;
116 const creationMethod = e.target.options[selectedIndex].value;
117 this.props.onDataChanged({ creationMethod });
121 let { baseVersion, data: { description, creationMethod } } = this.props;
122 this.props.onSubmit({
124 payload: { description, creationMethod }
129 this.props.onValidateForm();
133 export default VersionsPageCreationView;