react 16 upgrade
[sdc.git] / openecomp-ui / src / sdc-app / onboarding / softwareProduct / components / network / nicEditorComponents / NameAndPurpose.jsx
1 /*
2  * Copyright © 2016-2018 European Support Limited
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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 or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
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 GridSection from 'nfvo-components/grid/GridSection.jsx';
21 import GridItem from 'nfvo-components/grid/GridItem.jsx';
22
23 const NameAndPurpose = ({
24     onDataChanged,
25     genericFieldInfo,
26     isReadOnlyMode,
27     name,
28     description
29 }) => {
30     return (
31         <GridSection hastLastColSet>
32             <GridItem colSpan={2}>
33                 <Input
34                     label={i18n('Name')}
35                     value={name}
36                     data-test-id="nic-name"
37                     disabled={true}
38                     isRequired={true}
39                     onChange={name => onDataChanged({ name })}
40                     isValid={genericFieldInfo['name'].isValid}
41                     errorText={genericFieldInfo['name'].errorText}
42                     type="text"
43                 />
44             </GridItem>
45             <GridItem colSpan={2} lastColInRow>
46                 <Input
47                     label={i18n('Purpose of NIC')}
48                     value={description}
49                     data-test-id="nic-description"
50                     onChange={description => onDataChanged({ description })}
51                     disabled={isReadOnlyMode}
52                     type="textarea"
53                 />
54             </GridItem>
55         </GridSection>
56     );
57 };
58
59 NameAndPurpose.propTypes = {
60     name: PropTypes.string,
61     description: PropTypes.string,
62     onDataChanged: PropTypes.func,
63     isReadOnlyMode: PropTypes.bool
64 };
65
66 export default NameAndPurpose;