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 {
34 onDataChanged: PropTypes.func.isRequired,
35 onSubmit: PropTypes.func.isRequired,
36 onCancel: PropTypes.func.isRequired
48 let { name, description, networkDescription } = data;
51 {genericFieldInfo && (
53 ref={form => (this.form = form)}
55 onSubmit={() => this.submit()}
57 data.id ? i18n('Save') : i18n('Create')
59 onReset={() => this.props.onCancel()}
62 onValidateForm={() => onValidateForm()}
63 formReady={formReady}>
64 <GridSection hasLastColSet>
65 <GridItem colSpan={4} lastColInRow>
69 data-test-id="nic-name"
70 onChange={name => onDataChanged({ name })}
73 isValid={genericFieldInfo['name'].isValid}
75 genericFieldInfo['name'].errorText
77 className="field-section"
81 label={i18n('Description')}
82 data-test-id="nic-description"
83 onChange={description =>
84 onDataChanged({ description })
87 genericFieldInfo['description'].isValid
90 genericFieldInfo['description']
94 className="field-section"
98 <GridSection title={i18n('Network')} hasLastColSet>
99 <GridItem colSpan={2}>
100 <div className="form-group">
101 <label className="control-label">
102 {i18n('Network Type')}
104 <div className="network-type-radio">
106 label={i18n('Internal')}
109 data-test-id="nic-internal"
110 className="network-radio disabled"
114 label={i18n('External')}
117 data-test-id="nic-external"
118 className="network-radio disabled"
124 <GridItem colSpan={2} lastColInRow>
126 value={networkDescription}
127 label={i18n('Network Description')}
128 data-test-id="nic-network-description"
129 onChange={networkDescription =>
130 onDataChanged({ networkDescription })
133 genericFieldInfo['networkDescription']
137 genericFieldInfo['networkDescription']
141 className="field-section"
152 const { data: nic, componentId } = this.props;
153 this.props.onSubmit({ nic, componentId });
157 export default NICCreationView;