13494: Forces complete collection panel reload on after file operations.
authorLucas Di Pentima <lucas@di-pentima.com.ar>
Fri, 20 Nov 2020 18:07:04 +0000 (15:07 -0300)
committerLucas Di Pentima <lucas@di-pentima.com.ar>
Fri, 20 Nov 2020 18:07:04 +0000 (15:07 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas@di-pentima.com.ar>

src/store/collection-panel/collection-panel-action.ts
src/store/collection-panel/collection-panel-files/collection-panel-files-actions.ts

index 58407b903e9696af73e7a0dc20c345b188cd58e2..7881d6723854242525c4b5c88a907d72772e870c 100644 (file)
@@ -29,10 +29,12 @@ export type CollectionPanelAction = UnionOf<typeof collectionPanelActions>;
 
 export const COLLECTION_TAG_FORM_NAME = 'collectionTagForm';
 
-export const loadCollectionPanel = (uuid: string) =>
+export const loadCollectionPanel = (uuid: string, forceReload = false) =>
     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
         const { collectionPanel: { item } } = getState();
-        const collection = item ? item : await services.collectionService.get(uuid);
+        const collection = (item && item.uuid === uuid && !forceReload)
+            ? item
+            : await services.collectionService.get(uuid);
         dispatch<any>(loadDetailsPanel(collection.uuid));
         dispatch(collectionPanelActions.LOAD_COLLECTION_SUCCESS({ item: collection }));
         dispatch(resourcesActions.SET_RESOURCES([collection]));
index 1d2a40b22ddfa10c3d68bf13d7ab423dc7f42683..3f9948fca034e3915e9bcebddd56d64bd4109e1a 100644 (file)
@@ -15,7 +15,7 @@ import { startSubmit, stopSubmit, initialize, FormErrors } from 'redux-form';
 import { getDialog } from "~/store/dialog/dialog-reducer";
 import { getFileFullPath, sortFilesTree } from "~/services/collection-service/collection-service-files-response";
 import { progressIndicatorActions } from "~/store/progress-indicator/progress-indicator-actions";
-import { loadDetailsPanel } from "~/store/details-panel/details-panel-action";
+import { loadCollectionPanel } from "../collection-panel-action";
 
 export const collectionPanelFilesAction = unionize({
     SET_COLLECTION_FILES: ofType<CollectionFilesTree>(),
@@ -56,13 +56,12 @@ export const removeCollectionFiles = (filePaths: string[]) =>
         const currentCollection = getState().collectionPanel.item;
         if (currentCollection) {
             services.collectionService.deleteFiles(currentCollection.uuid, filePaths).then(() => {
-                dispatch<any>(loadCollectionFiles(currentCollection.uuid));
+                dispatch<any>(loadCollectionPanel(currentCollection.uuid, true));
                 dispatch(snackbarActions.OPEN_SNACKBAR({
                     message: 'Removed.',
                     hideDuration: 2000,
                     kind: SnackbarKind.SUCCESS
                 }));
-                dispatch<any>(loadDetailsPanel(currentCollection.uuid));
             }).catch(e =>
                 dispatch(snackbarActions.OPEN_SNACKBAR({
                     message: 'Could not remove file.',
@@ -147,10 +146,9 @@ export const renameFile = (newFullPath: string) =>
                 const oldPath = getFileFullPath(file);
                 const newPath = newFullPath;
                 services.collectionService.moveFile(currentCollection.uuid, oldPath, newPath).then(() => {
-                    dispatch<any>(loadCollectionFiles(currentCollection.uuid));
+                    dispatch<any>(loadCollectionPanel(currentCollection.uuid, true));
                     dispatch(dialogActions.CLOSE_DIALOG({ id: RENAME_FILE_DIALOG }));
                     dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'File name changed.', hideDuration: 2000 }));
-                    dispatch<any>(loadDetailsPanel(currentCollection.uuid));
                 }).catch (e => {
                     const errors: FormErrors<RenameFileDialogData, string> = {
                         path: `Could not rename the file: ${e.responseText}`