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 Form from 'nfvo-components/input/validation/Form.jsx';
18 import VmSizing from './computeComponents/VmSizing.jsx';
19 import NumberOfVms from './computeComponents/NumberOfVms.jsx';
20 import GuestOs from './computeComponents/GuestOs.jsx';
21 import Validator from 'nfvo-utils/Validator.js';
23 class SoftwareProductComponentComputeView extends React.Component {
26 dataMap: React.PropTypes.object,
27 qgenericFieldInfo: React.PropTypes.object,
28 isReadOnlyMode: React.PropTypes.bool,
29 onQDataChanged: React.PropTypes.func.isRequired,
30 qValidateData: React.PropTypes.func.isRequired,
31 onSubmit: React.PropTypes.func.isRequired
35 let {qdata, dataMap, qgenericFieldInfo, isReadOnlyMode, onQDataChanged, qValidateData, onSubmit} = this.props;
38 <div className='vsp-component-questionnaire-view'>
39 { qgenericFieldInfo && <Form
40 ref={ (form) => { this.form = form; }}
44 onSubmit={() => onSubmit({qdata})}
45 className='component-questionnaire-validation-form'
46 isReadOnlyMode={isReadOnlyMode} >
47 <VmSizing onQDataChanged={onQDataChanged} dataMap={dataMap} qgenericFieldInfo={qgenericFieldInfo} />
48 <NumberOfVms onQDataChanged={onQDataChanged} dataMap={dataMap}
49 qgenericFieldInfo={qgenericFieldInfo} qValidateData={qValidateData}
50 customValidations={{'compute/numOfVMs/maximum' : this.validateMax, 'compute/numOfVMs/minimum': this.validateMin}} />
51 <GuestOs onQDataChanged={onQDataChanged} dataMap={dataMap} qgenericFieldInfo={qgenericFieldInfo} />
58 return this.form.handleFormSubmit(new Event('dummy'));
61 validateMin(value, state) {
62 let maxVal = state.dataMap['compute/numOfVMs/maximum'];
63 return Validator.validateItem(value,maxVal,'maximum');
66 validateMax(value, state) {
67 let minVal = state.dataMap['compute/numOfVMs/minimum'];
68 return Validator.validateItem(value,minVal,'minimum');
72 export default SoftwareProductComponentComputeView;