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, IntArrayCommandInputParameter } 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 { createSelector } from 'reselect';
12 import { IntInput } from '~/components/int-input/int-input';
14 export interface IntArrayInputProps {
15 input: IntArrayCommandInputParameter;
17 export const IntArrayInput = ({ input }: IntArrayInputProps) =>
21 component={IntArrayInputComponent}
22 validate={validationSelector(input)} />;
25 const validationSelector = createSelector(
27 isRequired => isRequired
32 const required = (value: string[]) =>
37 const IntArrayInputComponent = (props: GenericInputProps) =>
39 component={InputComponent}
42 class InputComponent extends React.PureComponent<GenericInputProps>{
44 const { commandInput, input, meta } = this.props;
46 deletable={!commandInput.disabled}
47 orderable={!commandInput.disabled}
48 disabled={commandInput.disabled}
50 onChange={this.handleChange}
51 createNewValue={value => parseInt(value, 10)}
52 inputComponent={IntInput}
58 handleChange = (values: {}[]) => {
59 const { input, meta } = this.props;
63 input.onChange(values);