Create FileInput
[arvados-workbench2.git] / src / views / run-process-panel / inputs / file-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, isRequiredInput, FileCommandInputParameter, File } from '~/models/workflow';
7 import { Field } from 'redux-form';
8 import { TextField } from '~/components/text-field/text-field';
9 import { require } from '~/validators/require';
10
11 export interface FileInputProps {
12     input: FileCommandInputParameter;
13 }
14 export const FileInput = ({ input }: FileInputProps) =>
15     <Field
16         name={input.id}
17         label={getInputLabel(input)}
18         component={TextField}
19         format={(value?: File) => value ? value.location : ''}
20         validate={[
21             isRequiredInput(input)
22                 ? require
23                 : () => undefined,
24         ]} />;
25