Navigate back to the trash after restoring a collection
authorMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Tue, 25 Sep 2018 09:36:32 +0000 (11:36 +0200)
committerMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Tue, 25 Sep 2018 09:36:32 +0000 (11:36 +0200)
Feature #14244

Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski@contractors.roche.com>

src/store/trash/trash-actions.ts

index 5cf952eb1fa98a5a53857faf2f9da6224039fcfb..b59276c1f2bea84454a48fc11f28d247fa6b4913 100644 (file)
@@ -10,6 +10,8 @@ import { trashPanelActions } from "~/store/trash-panel/trash-panel-action";
 import { activateSidePanelTreeItem, loadSidePanelTreeProjects } from "~/store/side-panel-tree/side-panel-tree-actions";
 import { projectPanelActions } from "~/store/project-panel/project-panel-action";
 import { ResourceKind } from "~/models/resource";
+import { navigateToTrash } from '../navigation/navigation-action';
+import { matchTrashRoute, matchCollectionRoute } from '../../routes/routes';
 
 export const toggleProjectTrashed = (uuid: string, ownerUuid: string, isTrashed: boolean) =>
     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository): Promise<any> => {
@@ -46,8 +48,12 @@ export const toggleCollectionTrashed = (uuid: string, isTrashed: boolean) =>
     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository): Promise<any> => {
         try {
             if (isTrashed) {
+                const { location } = getState().router;
                 dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Restoring from trash..." }));
                 await services.collectionService.untrash(uuid);
+                if (matchCollectionRoute(location ? location.pathname : '')) {
+                    dispatch(navigateToTrash);
+                }
                 dispatch(trashPanelActions.REQUEST_ITEMS());
                 dispatch(snackbarActions.OPEN_SNACKBAR({
                     message: "Restored from trash",