1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
6 import { memoize } from 'lodash/fp';
7 import { FloatCommandInputParameter, isRequiredInput } from 'models/workflow';
8 import { Field } from 'redux-form';
9 import { isNumber } from 'validators/is-number';
10 import { GenericInputProps, GenericInput } from './generic-input';
11 import { FloatInput as FloatInputComponent } from 'components/float-input/float-input';
12 export interface FloatInputProps {
13 input: FloatCommandInputParameter;
15 export const FloatInput = ({ input }: FloatInputProps) =>
22 validate={getValidation(input)} />;
24 const format = (value: any) => isNaN(value) ? '' : JSON.stringify(value);
26 const getValidation = memoize(
27 (input: FloatCommandInputParameter) => ([
28 isRequiredInput(input)
33 const Input = (props: GenericInputProps) =>
35 component={InputComponent}
38 const InputComponent = ({ input, meta, commandInput }: GenericInputProps) =>
41 error={meta.touched && !!meta.error}
42 disabled={commandInput.disabled}