Merge branch '14254-triggering-vie-details-from-more-options-does-not-works'
[arvados-workbench2.git] / src / views / run-process-panel / inputs / float-input.tsx
index f6fffedcd4ce8edc55cb05bdedc1cb471675931e..aeaf6cdd48dd8aa4bb0d420b7a7d24e314bad7ff 100644 (file)
@@ -3,18 +3,20 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import * as React from 'react';
-import { getInputLabel, FloatCommandInputParameter, isRequiredInput } from '~/models/workflow';
-import { Field, WrappedFieldProps } from 'redux-form';
-import { TextField } from '~/components/text-field/text-field';
+import { FloatCommandInputParameter, isRequiredInput } from '~/models/workflow';
+import { Field } from 'redux-form';
 import { isNumber } from '~/validators/is-number';
+import { GenericInput } from '~/views/run-process-panel/inputs/generic-input';
+import { Input as MaterialInput } from '@material-ui/core';
+import { GenericInputProps } from './generic-input';
 export interface FloatInputProps {
     input: FloatCommandInputParameter;
 }
 export const FloatInput = ({ input }: FloatInputProps) =>
     <Field
         name={input.id}
-        label={getInputLabel(input)}
-        component={DecimalInput}
+        commandInput={input}
+        component={FloatInputComponent}
         parse={parseFloat}
         format={value => isNaN(value) ? '' : JSON.stringify(value)}
         validate={[
@@ -22,7 +24,7 @@ export const FloatInput = ({ input }: FloatInputProps) =>
                 ? isNumber
                 : () => undefined,]} />;
 
-class DecimalInput extends React.Component<WrappedFieldProps & { label?: string }> {
+class FloatInputComponent extends React.Component<GenericInputProps> {
     state = {
         endsWithDecimalSeparator: false,
     };
@@ -42,6 +44,11 @@ class DecimalInput extends React.Component<WrappedFieldProps & { label?: string
                 onChange: this.handleChange,
             },
         };
-        return <TextField {...props} />;
+        return <GenericInput
+            component={Input}
+            {...props} />;
     }
 }
+
+const Input = (props: GenericInputProps) =>
+    <MaterialInput fullWidth {...props.input} error={props.meta.touched && !!props.meta.error} />;