1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from 'react';
6 import { memoize } from 'lodash/fp';
7 import { IntCommandInputParameter, isRequiredInput } from '~/models/workflow';
8 import { Field } from 'redux-form';
9 import { isInteger } from '~/validators/is-integer';
10 import { GenericInputProps, GenericInput } from '~/views/run-process-panel/inputs/generic-input';
11 import { IntInput as IntInputComponent } from '~/components/int-input/int-input';
13 export interface IntInputProps {
14 input: IntCommandInputParameter;
16 export const IntInput = ({ input }: IntInputProps) =>
20 component={InputComponent}
23 validate={getValidation(input)} />;
25 const parse = (value: any) => parseInt(value, 10);
27 const format = (value: any) => isNaN(value) ? '' : JSON.stringify(value);
29 const getValidation = memoize(
30 (input: IntCommandInputParameter) => ([
31 isRequiredInput(input)
36 const InputComponent = (props: GenericInputProps) =>
42 const Input = (props: GenericInputProps) =>
46 error={props.meta.touched && !!props.meta.error}
47 disabled={props.commandInput.disabled}