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>{
48 value={this.props.input.value}
49 onChange={this.handleChange}
50 createNewValue={identity}
51 inputComponent={Input}
53 error: this.props.meta.error,
57 handleChange = (values: {}[]) => {
58 const { input, meta } = this.props;
62 input.onChange(values);