X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/428d454e2681d66bb14558946cfe2fb77a2c8dce..2c2a877d45ed33ba2c529c6996ccd79b0447a554:/src/views/run-process-panel/inputs/int-input.tsx

diff --git a/src/views/run-process-panel/inputs/int-input.tsx b/src/views/run-process-panel/inputs/int-input.tsx
index 5b6f95dbcb..78f0d736d1 100644
--- a/src/views/run-process-panel/inputs/int-input.tsx
+++ b/src/views/run-process-panel/inputs/int-input.tsx
@@ -3,10 +3,12 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import * as React from 'react';
-import { IntCommandInputParameter, getInputLabel } from '~/models/workflow';
+import { memoize } from 'lodash/fp';
+import { IntCommandInputParameter, 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 { IntInput as IntInputComponent } from '~/components/int-input/int-input';
 
 export interface IntInputProps {
     input: IntCommandInputParameter;
@@ -14,9 +16,34 @@ export interface IntInputProps {
 export const IntInput = ({ input }: IntInputProps) =>
     <Field
         name={input.id}
-        label={getInputLabel(input)}
-        component={TextField}
-        parse={value => parseInt(value, 10)}
-        format={value => isNaN(value) ? '' : JSON.stringify(value)}
-        validate={[isInteger]} />;
+        commandInput={input}
+        component={InputComponent}
+        parse={parse}
+        format={format}
+        validate={getValidation(input)} />;
+
+const parse = (value: any) => value === '' ? '' : parseInt(value, 10);
+
+const format = (value: any) => isNaN(value) ? '' : JSON.stringify(value);
+
+const getValidation = memoize(
+    (input: IntCommandInputParameter) => ([
+        isRequiredInput(input)
+            ? isInteger
+            : () => undefined,
+    ]));
+
+const InputComponent = (props: GenericInputProps) =>
+    <GenericInput
+        component={Input}
+        {...props} />;
+
+
+const Input = (props: GenericInputProps) =>
+    <IntInputComponent
+        fullWidth
+        type='number'
+        error={props.meta.touched && !!props.meta.error}
+        disabled={props.commandInput.disabled}
+        {...props.input} />;
 
