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 {
28 data: PropTypes.object,
29 qdata: PropTypes.object,
30 qschema: PropTypes.object,
31 isReadOnlyMode: PropTypes.bool,
32 isManual: PropTypes.bool,
33 onDataChanged: PropTypes.func.isRequired,
34 onQDataChanged: PropTypes.func.isRequired,
35 onSubmit: PropTypes.func.isRequired,
36 onCancel: PropTypes.func.isRequired
40 let {data = {}, qdata = {}, qgenericFieldInfo, dataMap, genericFieldInfo, isReadOnlyMode, isManual, isFormValid, formReady,
41 onDataChanged, onQDataChanged, onSubmit, onCancel, onValidateForm} = this.props;
42 const {id, name, description} = data;
43 const edittingComputeMode = Boolean(id);
46 <div className='vsp-component-computeFlavor-view'>
47 {genericFieldInfo && <Form
52 onSubmit={ () => onSubmit({data, qdata}) }
53 onReset={ () => onCancel() }
55 isReadOnlyMode={isReadOnlyMode}
58 onValidateForm={() => onValidateForm() }
59 className='component-questionnaire-validation-form'
60 submitButtonText={edittingComputeMode ? i18n('Save') : i18n('Create')}>
61 <GridSection hasLostColSet>
62 <GridItem colSpan={edittingComputeMode ? 2 : 4} lastColInRow={!edittingComputeMode}>
67 label={i18n('Flavor Name')}
69 onChange={name => onDataChanged({name})}
70 isValid={genericFieldInfo['name'].isValid}
71 errorText={genericFieldInfo['name'].errorText}
74 <GridItem colSpan={edittingComputeMode ? 2 : 4} lastColInRow>
76 data-test-id='description'
78 label={i18n('Description')}
80 onChange={description => onDataChanged({description})}
81 isValid={genericFieldInfo['description'].isValid}
82 errorText={genericFieldInfo['description'].errorText}/>
85 {edittingComputeMode && <VmSizing qgenericFieldInfo={qgenericFieldInfo} dataMap={dataMap} onQDataChanged={onQDataChanged}/>}
93 return this.form.handleFormSubmit(new Event('dummy'));
97 export default ComputeEditorView;