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 Form from 'nfvo-components/input/validation/Form.jsx';
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';
22 import VmSizing from './VmSizing.jsx';
23 import i18n from 'nfvo-utils/i18n/i18n.js';
25 class ComputeEditorView extends React.Component {
27 data: PropTypes.object,
28 qdata: PropTypes.object,
29 qschema: PropTypes.object,
30 isReadOnlyMode: PropTypes.bool,
31 isManual: PropTypes.bool,
32 onDataChanged: PropTypes.func.isRequired,
33 onQDataChanged: PropTypes.func.isRequired,
34 onSubmit: PropTypes.func.isRequired,
35 onCancel: PropTypes.func.isRequired
55 const { id, name, description } = data;
56 const edittingComputeMode = Boolean(id);
59 <div className="vsp-component-computeFlavor-view">
60 {genericFieldInfo && (
66 btnClassName="sdc-modal__footer"
67 onSubmit={() => onSubmit({ data, qdata })}
68 onReset={() => onCancel()}
70 isReadOnlyMode={isReadOnlyMode}
73 onValidateForm={() => onValidateForm()}
74 className="component-questionnaire-validation-form"
76 edittingComputeMode ? i18n('Save') : i18n('Create')
78 <GridSection hasLostColSet>
80 colSpan={edittingComputeMode ? 2 : 4}
81 lastColInRow={!edittingComputeMode}>
86 label={i18n('Flavor Name')}
88 onChange={name => onDataChanged({ name })}
89 isValid={genericFieldInfo['name'].isValid}
91 genericFieldInfo['name'].errorText
97 colSpan={edittingComputeMode ? 2 : 4}
100 data-test-id="description"
102 label={i18n('Description')}
104 onChange={description =>
105 onDataChanged({ description })
108 genericFieldInfo['description'].isValid
111 genericFieldInfo['description']
117 {edittingComputeMode && (
119 qgenericFieldInfo={qgenericFieldInfo}
121 onQDataChanged={onQDataChanged}
131 return this.form.handleFormSubmit(new Event('dummy'));
135 export default ComputeEditorView;