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 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';
21 import GridSection from 'nfvo-components/grid/GridSection.jsx';
22 import GridItem from 'nfvo-components/grid/GridItem.jsx';
24 const NICPropType = PropTypes.shape({
26 name: PropTypes.string,
27 description: PropTypes.string,
28 networkId: PropTypes.string
31 class NICCreationView extends React.Component {
35 onDataChanged: PropTypes.func.isRequired,
36 onSubmit: PropTypes.func.isRequired,
37 onCancel: PropTypes.func.isRequired
41 let {data = {}, onDataChanged, genericFieldInfo, isFormValid, onValidateForm, formReady} = this.props;
42 let {name, description, networkDescription} = data;
45 {genericFieldInfo && <Form
46 ref={(form) => this.form = form}
48 onSubmit={ () => this.submit() }
49 submitButtonText={data.id ? i18n('Save') : i18n('Create')}
50 onReset={ () => this.props.onCancel() }
53 onValidateForm={() => onValidateForm()}
54 formReady={formReady} >
55 <GridSection hasLastColSet>
56 <GridItem colSpan={4} lastColInRow>
60 data-test-id='nic-name'
61 onChange={name => onDataChanged({name})}
64 isValid={genericFieldInfo['name'].isValid}
65 errorText={genericFieldInfo['name'].errorText}
66 className='field-section'/>
69 label={i18n('Description')}
70 data-test-id='nic-description'
71 onChange={description => onDataChanged({description})}
72 isValid={genericFieldInfo['description'].isValid}
73 errorText={genericFieldInfo['description'].errorText}
75 className='field-section'/>
78 <GridSection title={i18n('Network')} hasLastColSet>
79 <GridItem colSpan={2}>
80 <div className='form-group'>
81 <label className='control-label'>{i18n('Network Type')}</label>
82 <div className='network-type-radio'>
84 label={i18n('Internal')}
87 data-test-id='nic-internal'
88 className='network-radio disabled'
91 label={i18n('External')}
94 data-test-id='nic-external'
95 className='network-radio disabled'
100 <GridItem colSpan={2} lastColInRow>
102 value={networkDescription}
103 label={i18n('Network Description')}
104 data-test-id='nic-network-description'
105 onChange={networkDescription => onDataChanged({networkDescription})}
106 isValid={genericFieldInfo['networkDescription'].isValid}
107 errorText={genericFieldInfo['networkDescription'].errorText}
109 className='field-section'/>
119 const {data: nic, componentId} = this.props;
120 this.props.onSubmit({nic, componentId});
124 export default NICCreationView;