1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from 'react';
6 import { WrappedFieldProps } from 'redux-form';
7 import { FormGroup, FormLabel, FormHelperText } from '@material-ui/core';
8 import { GenericCommandInputParameter, getInputLabel, isRequiredInput } from '~/models/workflow';
10 export type GenericInputProps = WrappedFieldProps & {
11 commandInput: GenericCommandInputParameter<any, any>;
14 type GenericInputContainerProps = GenericInputProps & {
15 component: React.ComponentType<GenericInputProps>;
17 export const GenericInput = ({ component: Component, ...props }: GenericInputContainerProps) => {
20 focused={props.meta.active}
21 required={isRequiredInput(props.commandInput)}
22 error={props.meta.touched && !!props.meta.error}>
23 {getInputLabel(props.commandInput)}
25 <Component {...props} />
26 <FormHelperText error={props.meta.touched && !!props.meta.error}>
28 props.meta.touched && props.meta.error
30 : props.commandInput.doc