Merge branch '14856-actions-on-selected-files-inside-collections-are-not-working'
[arvados-workbench2.git] / src / views-components / dialog-upload / dialog-collection-files-upload.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 { InjectedFormProps, Field } from 'redux-form';
7 import { WithDialogProps } from '~/store/dialog/with-dialog';
8 import { CollectionCreateFormDialogData } from '~/store/collections/collection-create-actions';
9 import { FormDialog } from '~/components/form-dialog/form-dialog';
10 import { require } from '~/validators/require';
11 import { FileUploaderField } from '~/views-components/file-uploader/file-uploader';
12 import { WarningCollection } from '~/components/warning-collection/warning-collection';
13
14 type DialogCollectionFilesUploadProps = WithDialogProps<{}> & InjectedFormProps<CollectionCreateFormDialogData>;
15
16 export const DialogCollectionFilesUpload = (props: DialogCollectionFilesUploadProps) =>
17     <FormDialog
18         dialogTitle='Upload data'
19         formFields={UploadCollectionFilesFields}
20         submitLabel='Upload data'
21         {...props}
22     />;
23
24 const UploadCollectionFilesFields = () => <>
25     <Field
26         name='files'
27         validate={FILES_FIELD_VALIDATION}
28         component={FileUploaderField} />
29     <WarningCollection text="Uploading new files will change content address." />
30 </>;
31
32 const FILES_FIELD_VALIDATION = [require];
33
34