2 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
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.
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 onSubmit={() => onSubmit({ data, qdata })}
67 onReset={() => onCancel()}
69 isReadOnlyMode={isReadOnlyMode}
72 onValidateForm={() => onValidateForm()}
73 className="component-questionnaire-validation-form"
75 edittingComputeMode ? i18n('Save') : i18n('Create')
77 <GridSection hasLostColSet>
79 colSpan={edittingComputeMode ? 2 : 4}
80 lastColInRow={!edittingComputeMode}>
85 label={i18n('Flavor Name')}
87 onChange={name => onDataChanged({ name })}
88 isValid={genericFieldInfo['name'].isValid}
90 genericFieldInfo['name'].errorText
96 colSpan={edittingComputeMode ? 2 : 4}
99 data-test-id="description"
101 label={i18n('Description')}
103 onChange={description =>
104 onDataChanged({ description })
107 genericFieldInfo['description'].isValid
110 genericFieldInfo['description']
116 {edittingComputeMode && (
118 qgenericFieldInfo={qgenericFieldInfo}
120 onQDataChanged={onQDataChanged}
130 return this.form.handleFormSubmit(new Event('dummy'));
134 export default ComputeEditorView;