1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from 'react';
6 import { Field } from 'redux-form';
7 import { Select, MenuItem } from '@material-ui/core';
8 import { EnumCommandInputParameter, CommandInputEnumSchema } from '~/models/workflow';
9 import { GenericInputProps, GenericInput } from './generic-input';
11 export interface EnumInputProps {
12 input: EnumCommandInputParameter;
14 export const EnumInput = ({ input }: EnumInputProps) =>
18 component={EnumInputComponent}
21 const EnumInputComponent = (props: GenericInputProps) =>
26 const Input = (props: GenericInputProps) => {
27 const type = props.commandInput.type as CommandInputEnumSchema;
29 value={props.input.value}
30 onChange={props.input.onChange}
31 disabled={props.commandInput.disabled} >
32 {type.symbols.map(symbol =>
33 <MenuItem key={symbol} value={extractValue(symbol)}>
34 {extractValue(symbol)}
40 * Values in workflow definition have an absolute form, for example:
42 * ```#input_collector.cwl/enum_type/Pathway table```
44 * We want a value that is in form accepted by backend.
45 * According to the example above, the correct value is:
49 const extractValue = (symbol: string) => symbol.split('/').pop();