1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from 'react';
6 import { isRequiredInput, StringArrayCommandInputParameter } from '~/models/workflow';
7 import { Field } from 'redux-form';
8 import { ERROR_MESSAGE } from '~/validators/require';
9 import { GenericInputProps, GenericInput } from '~/views/run-process-panel/inputs/generic-input';
10 import { ChipsInput } from '~/components/chips-input/chips-input';
11 import { identity } from 'lodash';
12 import { createSelector } from 'reselect';
13 import { Input } from '@material-ui/core';
15 export interface StringArrayInputProps {
16 input: StringArrayCommandInputParameter;
18 export const StringArrayInput = ({ input }: StringArrayInputProps) =>
22 component={StringArrayInputComponent}
23 validate={validationSelector(input)} />;
26 const validationSelector = createSelector(
28 isRequired => isRequired
33 const required = (value: string[]) =>
38 const StringArrayInputComponent = (props: GenericInputProps) =>
40 component={InputComponent}
43 class InputComponent extends React.PureComponent<GenericInputProps>{
45 const { commandInput, input, meta } = this.props;
47 deletable={!commandInput.disabled}
48 orderable={!commandInput.disabled}
49 disabled={commandInput.disabled}
51 onChange={this.handleChange}
52 createNewValue={identity}
53 inputComponent={Input}
59 handleChange = (values: {}[]) => {
60 const { input, meta } = this.props;
64 input.onChange(values);