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 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';
24 const Protocols = ({protocols, qgenericFieldInfo, dataMap, onQDataChanged}) => {
26 <GridSection title={i18n('Protocols')} hasLastColSet>
27 <GridItem colSpan={2}>
29 data-test-id='nic-protocols'
30 label={i18n('Protocols')}
33 isValid={qgenericFieldInfo['protocols/protocols'].isValid}
34 errorText={qgenericFieldInfo['protocols/protocols'].errorText}
35 onInputChange={()=>{}}
36 onEnumChange={protocols => {
37 onQDataChanged({'protocols/protocols' : protocols});}
39 multiSelectedEnum={dataMap['protocols/protocols']}
41 values={qgenericFieldInfo['protocols/protocols'].enum}/>
43 <GridItem colSpan={2} lastColInRow>
45 data-test-id='nic-protocolWithHighestTrafficProfile'
46 label={i18n('Protocol with Highest Traffic Profile')}
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']}
54 const selectedIndex = e.target.selectedIndex;
55 const val = e.target.options[selectedIndex].value;
56 onQDataChanged({'protocols/protocolWithHighestTrafficProfile' : val});}
58 {(protocols.length === 0) &&
59 <option key={'You must select protocols first...'} value=''>{i18n('You must select protocols first...')}</option>
61 {protocols.map(protocol => <option key={protocol} value={protocol}>{protocol}</option>)}
68 Protocols.PropTypes = {
69 protocols: PropTypes.array,
70 onQDataChanged: PropTypes.function,
71 dataMap: PropTypes.object,
72 qgenericFieldInfo: PropTypes.object
75 export default Protocols;