refs #14857-new-workbench-affects-files-content
[arvados-workbench2.git] / src / store / collections / collection-upload-actions.ts
index c410cf04920f77c32a187657ac768865e9426a5e..268d5ddfc50c560ae98d74a4b121c5487a5b3a38 100644 (file)
@@ -11,6 +11,9 @@ import { snackbarActions, SnackbarKind } from '~/store/snackbar/snackbar-actions
 import { fileUploaderActions } from '~/store/file-uploader/file-uploader-actions';
 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) => {
@@ -35,8 +38,10 @@ export const submitCollectionFiles = () =>
             try {
                 dispatch(progressIndicatorActions.START_WORKING(COLLECTION_UPLOAD_FILES_DIALOG));
                 dispatch(startSubmit(COLLECTION_UPLOAD_FILES_DIALOG));
-                await dispatch<any>(uploadCollectionFiles(currentCollection.uuid));
+                await dispatch<any>(uploadCollectionFiles(currentCollection.uuid))
+                    .then(() => dispatch<any>(collectionPanelFilesAction.SET_COLLECTION_FILES({ files: createTree() })));
                 dispatch<any>(loadCollectionFiles(currentCollection.uuid));
+                dispatch<any>(loadCollectionPanel(currentCollection.uuid));
                 dispatch(closeUploadCollectionFilesDialog());
                 dispatch(snackbarActions.OPEN_SNACKBAR({
                     message: 'Data has been uploaded.',
@@ -52,7 +57,7 @@ export const submitCollectionFiles = () =>
                     hideDuration: 2000,
                     kind: SnackbarKind.ERROR
                 }));
-                dispatch(progressIndicatorActions.STOP_WORKING(COLLECTION_UPLOAD_FILES_DIALOG));                
+                dispatch(progressIndicatorActions.STOP_WORKING(COLLECTION_UPLOAD_FILES_DIALOG));
             }
         }
     };
@@ -61,4 +66,4 @@ export const closeUploadCollectionFilesDialog = () => dialogActions.CLOSE_DIALOG
 
 const handleUploadProgress = (dispatch: Dispatch) => (fileId: number, loaded: number, total: number, currentTime: number) => {
     dispatch(fileUploaderActions.SET_UPLOAD_PROGRESS({ fileId, loaded, total, currentTime }));
-};
+};
\ No newline at end of file