1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import 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 import { fileUploaderActions } from 'store/file-uploader/file-uploader-actions';
14 import { progressIndicatorActions } from 'store/progress-indicator/progress-indicator-actions';
16 type DialogCollectionFilesUploadProps = WithDialogProps<{}> & InjectedFormProps<CollectionCreateFormDialogData>;
18 export const DialogCollectionFilesUpload = (props: DialogCollectionFilesUploadProps) => {
21 dialogTitle='Upload data'
22 formFields={UploadCollectionFilesFields}
23 submitLabel='Upload data'
25 cancelCallback={() => {
26 const { submitting, dispatch } = (props as any);
29 dispatch(progressIndicatorActions.STOP_WORKING('uploadCollectionFilesDialog'));
30 dispatch(fileUploaderActions.CANCEL_FILES_UPLOAD());
31 dispatch(fileUploaderActions.CLEAR_UPLOAD());
38 const UploadCollectionFilesFields = () => <>
41 validate={FILES_FIELD_VALIDATION}
42 component={FileUploaderField} />
43 <WarningCollection text="Uploading new files will change content address." />
46 const FILES_FIELD_VALIDATION = [require];