X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/6a024c9a0ad6543bf95359b10bcd22aeec3e7dca..c5fa0c4eed19a9d0c163ea1727189970533f0203:/src/store/collections/collection-upload-actions.ts diff --git a/src/store/collections/collection-upload-actions.ts b/src/store/collections/collection-upload-actions.ts index 4a5aff3500..268d5ddfc5 100644 --- a/src/store/collections/collection-upload-actions.ts +++ b/src/store/collections/collection-upload-actions.ts @@ -7,9 +7,13 @@ import { RootState } from '~/store/store'; import { ServiceRepository } from '~/services/services'; import { dialogActions } from '~/store/dialog/dialog-actions'; import { loadCollectionFiles } from '../collection-panel/collection-panel-files/collection-panel-files-actions'; -import { snackbarActions } from '~/store/snackbar/snackbar-actions'; +import { snackbarActions, SnackbarKind } from '~/store/snackbar/snackbar-actions'; import { fileUploaderActions } from '~/store/file-uploader/file-uploader-actions'; -import { reset, startSubmit } from 'redux-form'; +import { reset, startSubmit, stopSubmit } from 'redux-form'; +import { progressIndicatorActions } from "~/store/progress-indicator/progress-indicator-actions"; +import { collectionPanelFilesAction } from '~/store/collection-panel/collection-panel-files/collection-panel-files-actions'; +import { createTree } from '~/models/tree'; +import { loadCollectionPanel } from '../collection-panel/collection-panel-action'; export const uploadCollectionFiles = (collectionUuid: string) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { @@ -31,11 +35,30 @@ export const submitCollectionFiles = () => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { const currentCollection = getState().collectionPanel.item; if (currentCollection) { - dispatch(startSubmit(COLLECTION_UPLOAD_FILES_DIALOG)); - await dispatch(uploadCollectionFiles(currentCollection.uuid)); - dispatch(loadCollectionFiles(currentCollection.uuid)); - dispatch(closeUploadCollectionFilesDialog()); - dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Data has been uploaded.', hideDuration: 2000 })); + try { + dispatch(progressIndicatorActions.START_WORKING(COLLECTION_UPLOAD_FILES_DIALOG)); + dispatch(startSubmit(COLLECTION_UPLOAD_FILES_DIALOG)); + await dispatch(uploadCollectionFiles(currentCollection.uuid)) + .then(() => dispatch(collectionPanelFilesAction.SET_COLLECTION_FILES({ files: createTree() }))); + dispatch(loadCollectionFiles(currentCollection.uuid)); + dispatch(loadCollectionPanel(currentCollection.uuid)); + dispatch(closeUploadCollectionFilesDialog()); + dispatch(snackbarActions.OPEN_SNACKBAR({ + message: 'Data has been uploaded.', + hideDuration: 2000, + kind: SnackbarKind.SUCCESS + })); + dispatch(progressIndicatorActions.STOP_WORKING(COLLECTION_UPLOAD_FILES_DIALOG)); + } catch (e) { + dispatch(stopSubmit(COLLECTION_UPLOAD_FILES_DIALOG)); + dispatch(closeUploadCollectionFilesDialog()); + dispatch(snackbarActions.OPEN_SNACKBAR({ + message: 'Data has not been uploaded. Too large file', + hideDuration: 2000, + kind: SnackbarKind.ERROR + })); + dispatch(progressIndicatorActions.STOP_WORKING(COLLECTION_UPLOAD_FILES_DIALOG)); + } } };