Add collaboration feature
[sdc.git] / openecomp-ui / src / sdc-app / onboarding / softwareProduct / components / network / nicEditorComponents / Protocols.jsx
1 /*!
2  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
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
13  * or implied. See the License for the specific language governing
14  * permissions and 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 InputOptions from 'nfvo-components/input/validation/InputOptions.jsx';
21 import GridSection from 'nfvo-components/grid/GridSection.jsx';
22 import GridItem from 'nfvo-components/grid/GridItem.jsx';
23
24 const Protocols = ({protocols, qgenericFieldInfo, dataMap, onQDataChanged}) => {
25         return (
26                 <GridSection title={i18n('Protocols')} hasLastColSet>
27                                 <GridItem colSpan={2}>
28                                         <InputOptions
29                                                 data-test-id='nic-protocols'
30                                                 label={i18n('Protocols')}
31                                                 type='select'
32                                                 isMultiSelect={true}
33                                                 isValid={qgenericFieldInfo['protocols/protocols'].isValid}
34                                                 errorText={qgenericFieldInfo['protocols/protocols'].errorText}
35                                                 onInputChange={()=>{}}
36                                                 onEnumChange={protocols => {
37                                                         onQDataChanged({'protocols/protocols' : protocols});}
38                                                 }
39                                                 multiSelectedEnum={dataMap['protocols/protocols']}
40                                                 clearable={false}
41                                                 values={qgenericFieldInfo['protocols/protocols'].enum}/>
42                                 </GridItem>
43                                 <GridItem colSpan={2} lastColInRow>
44                                         <Input
45                                                 data-test-id='nic-protocolWithHighestTrafficProfile'
46                                                 label={i18n('Protocol with Highest Traffic Profile')}
47                                                 type='select'
48                                                 groupClassName='bootstrap-input-options'
49                                                 className='input-options-select'
50                                                 isValid={qgenericFieldInfo['protocols/protocolWithHighestTrafficProfile'].isValid}
51                                                 errorText={qgenericFieldInfo['protocols/protocolWithHighestTrafficProfile'].errorText}
52                                                 value={dataMap['protocols/protocolWithHighestTrafficProfile']}
53                                                 onChange={(e) => {
54                                                         const selectedIndex = e.target.selectedIndex;
55                                                         const val = e.target.options[selectedIndex].value;
56                                                         onQDataChanged({'protocols/protocolWithHighestTrafficProfile' : val});}
57                                                 }>
58                                                 {(protocols.length === 0) &&
59                                                         <option key={'You must select protocols first...'} value=''>{i18n('You must select protocols first...')}</option>
60                                                 }
61                                                 {protocols.map(protocol => <option key={protocol} value={protocol}>{protocol}</option>)}
62                                         </Input>
63                                 </GridItem>
64                 </GridSection>
65         );
66 };
67
68 Protocols.PropTypes = {
69         protocols: PropTypes.array,
70         onQDataChanged:  PropTypes.function,
71         dataMap: PropTypes.object,
72         qgenericFieldInfo: PropTypes.object
73 };
74
75 export default Protocols;