Fix name convention issue
[sdc/sdc-workflow-designer.git] / sdc-workflow-designer-ui / src / main / frontend / src / shared / components / Select / index.js
1 /*
2 * Copyright © 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 isEmpty from 'lodash.isempty';
19
20 const Select = props => {
21     const { dataObj, selectedItemValue, disabled, label } = props;
22     return (
23         <div className="select-wrapper version-selector sdc-input">
24             {label && <label>{label}</label>}
25             <select
26                 className="inputinput-selector"
27                 key={'selector'}
28                 value={selectedItemValue}
29                 disabled={disabled}
30                 data-test-id="vc-select-box">
31                 {!isEmpty(dataObj) &&
32                     dataObj.map(item => {
33                         return (
34                             <option
35                                 key={'select-item' + item.id}
36                                 value={item.id}
37                                 data-test-id="vc-option">
38                                 {item.displayed || item.name}
39                             </option>
40                         );
41                     })}
42             </select>
43         </div>
44     );
45 };
46
47 Select.propTypes = {
48     dataObj: PropTypes.arrayOf(Object),
49     selectedItemValue: PropTypes.string,
50     disabled: PropTypes.bool,
51     label: PropTypes.string
52 };
53
54 export default Select;