1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
6 import { StringArrayCommandInputParameter } from 'models/workflow';
7 import { Field } from 'redux-form';
8 import { GenericInputProps } from 'views/run-process-panel/inputs/generic-input';
9 import { ChipsInput } from 'components/chips-input/chips-input';
10 import { identity } from 'lodash';
11 import { withStyles, WithStyles, FormGroup, Input, InputLabel, FormControl } from '@material-ui/core';
13 export interface StringArrayInputProps {
15 input: StringArrayCommandInputParameter;
19 type CssRules = 'chips';
27 export const GroupArrayInput = ({name, input}: StringArrayInputProps) =>
31 component={StringArrayInputComponent as any}
34 const StringArrayInputComponent = (props: GenericInputProps) => {
36 <FormControl fullWidth error={props.meta.error}>
37 <InputLabel shrink={props.meta.active || props.input.value.length > 0}>{props.commandInput.id}</InputLabel>
38 <StyledInputComponent {...props} />
43 const StyledInputComponent = withStyles(styles)(
44 class InputComponent extends React.PureComponent<GenericInputProps & WithStyles<CssRules>>{
46 const { classes } = this.props;
47 const { commandInput, input, meta } = this.props;
49 deletable={!commandInput.disabled}
50 orderable={!commandInput.disabled}
51 disabled={commandInput.disabled}
53 onChange={this.handleChange}
54 handleFocus={input.onFocus}
55 createNewValue={identity}
56 inputComponent={Input}
57 chipsClassName={classes.chips}
58 pattern={/[_a-z][-0-9_a-z]*/ig}
64 handleChange = (values: {}[]) => {
65 const { input, meta } = this.props;
69 input.onChange(values);