2 * Copyright © 2018 European Support Limited
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 or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 import React from 'react';
18 import PropTypes from 'prop-types';
19 import { isEmpty } from 'lodash';
21 const VersionSelect = props => {
23 currentWorkflowVersion,
28 function onChangeHandler(ev) {
29 const versionIndex = Object.keys(viewableVersions).find(
30 key => viewableVersions[key].id === ev.target.value
32 const currentVersion = viewableVersions[versionIndex].id;
33 dynamicDispatcher('CHANGE_VERSION', currentVersion);
34 return currentVersion;
39 className="version-selector"
41 value={currentWorkflowVersion}
42 onChange={onChangeHandler}
43 data-test-id="vc-versions-select-box">
44 {!isEmpty(viewableVersions) &&
45 viewableVersions.map(item => {
48 key={'versionSelect' + item.id}
50 data-test-id="vc-version-option">
51 {item.displayed || item.name}
59 VersionSelect.propTypes = {
60 currentWorkflowVersion: PropTypes.string,
61 viewableVersions: PropTypes.arrayOf(Object),
62 dynamicDispatcher: PropTypes.func
65 export default VersionSelect;