Send new user data to server
[arvados-workbench2.git] / src / views / run-process-panel / inputs / string-input.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import * as React from 'react';
6 import { isRequiredInput, StringCommandInputParameter } from '~/models/workflow';
7 import { Field } from 'redux-form';
8 import { require } from '~/validators/require';
9 import { GenericInputProps, GenericInput } from '~/views/run-process-panel/inputs/generic-input';
10 import { Input as MaterialInput } from '@material-ui/core';
11
12 export interface StringInputProps {
13     input: StringCommandInputParameter;
14 }
15 export const StringInput = ({ input }: StringInputProps) =>
16     <Field
17         name={input.id}
18         commandInput={input}
19         component={StringInputComponent}
20         validate={[
21             isRequiredInput(input)
22                 ? require
23                 : () => undefined,
24         ]} />;
25
26 const StringInputComponent = (props: GenericInputProps) =>
27     <GenericInput
28         component={Input}
29         {...props} />;
30
31 const Input = (props: GenericInputProps) =>
32     <MaterialInput
33         fullWidth
34         error={props.meta.touched && !!props.meta.error}
35         disabled={props.commandInput.disabled}
36         {...props.input} />;