RunProcessInputsForm [WIP]
[arvados-workbench2.git] / src / views / run-process-panel / inputs / float-input.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import * as React from 'react';
6 import { getInputLabel, FloatCommandInputParameter } from '~/models/workflow';
7 import { Field } from 'redux-form';
8 import { TextField } from '~/components/text-field/text-field';
9 import { isNumber } from '~/validators/is-number';
10 import { toNumber } from 'lodash';
11 export interface FloatInputProps {
12     input: FloatCommandInputParameter;
13 }
14 export const FloatInput = ({ input }: FloatInputProps) =>
15     <Field
16         name={input.id}
17         label={getInputLabel(input)}
18         component={TextField}
19         parse={value => toNumber(value)}
20         format={value => isNaN(value) ? '' : JSON.stringify(value)}
21         validate={[isNumber]} />;
22