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.isempty';
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 onVersionSelectChange(currentVersion);
38 className="version-selector"
40 value={currentWorkflowVersion.id}
41 onChange={onChangeHandler}
42 data-test-id="vc-versions-select-box">
43 {!isEmpty(viewableVersions) &&
44 viewableVersions.map(item => {
45 const displayedName = `${item.name} ${
46 currentWorkflowVersion.id === item.id
47 ? currentWorkflowVersion.state.toUpperCase()
52 key={'versionSelect' + item.id}
54 data-test-id="vc-version-option">
63 VersionSelect.propTypes = {
64 currentWorkflowVersion: PropTypes.object,
65 viewableVersions: PropTypes.arrayOf(Object),
66 onVersionSelectChange: PropTypes.func
69 export default VersionSelect;