Extract GenericInput component
[arvados-workbench2.git] / src / views / run-process-panel / inputs / int-input.tsx
index 60a49b61f5295dfb678d9dba28aee79f5206e56f..6d0307a821065b35a2fe9e5cb07f6ae5d70da3f1 100644 (file)
@@ -5,8 +5,9 @@
 import * as React from 'react';
 import { IntCommandInputParameter, getInputLabel, isRequiredInput } from '~/models/workflow';
 import { Field } from 'redux-form';
-import { TextField } from '~/components/text-field/text-field';
 import { isInteger } from '~/validators/is-integer';
+import { GenericInputProps, GenericInput } from '~/views/run-process-panel/inputs/generic-input';
+import { Input as MaterialInput } from '@material-ui/core';
 
 export interface IntInputProps {
     input: IntCommandInputParameter;
@@ -14,8 +15,8 @@ export interface IntInputProps {
 export const IntInput = ({ input }: IntInputProps) =>
     <Field
         name={input.id}
-        label={getInputLabel(input)}
-        component={TextField}
+        commandInput={input}
+        component={IntInputComponent}
         parse={value => parseInt(value, 10)}
         format={value => isNaN(value) ? '' : JSON.stringify(value)}
         validate={[
@@ -24,3 +25,12 @@ export const IntInput = ({ input }: IntInputProps) =>
                 : () => undefined,
         ]} />;
 
+const IntInputComponent = (props: GenericInputProps) =>
+    <GenericInput
+        component={Input}
+        {...props} />;
+
+
+const Input = (props: GenericInputProps) =>
+    <MaterialInput type='number' {...props.input} />;
+