[ARVADOS-WORKBENCH2] created: 1.3.0-119-g936aa32

Git user git at public.curoverse.com
Thu Dec 13 09:54:40 EST 2018


        at  936aa32e065b7f672e27b95262720c2ce8258bf6 (commit)


commit 936aa32e065b7f672e27b95262720c2ce8258bf6
Author: Pawel Kowalczyk <pawel.kowalczyk at contractors.roche.com>
Date:   Thu Dec 13 15:54:25 2018 +0100

    modals-are-closed-after-using-browsers-back-or-forward-option
    
    Feature #14489
    
    Arvados-DCO-1.1-Signed-off-by: Pawel Kowalczyk <pawel.kowalczyk at contractors.roche.com>

diff --git a/src/routes/route-change-handlers.ts b/src/routes/route-change-handlers.ts
index c4b0fc7..655c806 100644
--- a/src/routes/route-change-handlers.ts
+++ b/src/routes/route-change-handlers.ts
@@ -7,6 +7,7 @@ import { RootStore } from '~/store/store';
 import * as Routes from '~/routes/routes';
 import * as WorkbenchActions from '~/store/workbench/workbench-actions';
 import { navigateToRootProject } from '~/store/navigation/navigation-action';
+import { dialogActions } from '~/store/dialog/dialog-actions';
 
 export const addRouteChangeHandlers = (history: History, store: RootStore) => {
     const handler = handleLocationChange(store);
@@ -38,6 +39,8 @@ const handleLocationChange = (store: RootStore) => ({ pathname }: Location) => {
     const userMatch = Routes.matchUsersRoute(pathname);
     const linksMatch = Routes.matchLinksRoute(pathname);
 
+    store.dispatch(dialogActions.CLOSE_ALL_DIALOGS());
+
     if (projectMatch) {
         store.dispatch(WorkbenchActions.loadProject(projectMatch.params.id));
     } else if (collectionMatch) {
diff --git a/src/store/dialog/dialog-actions.ts b/src/store/dialog/dialog-actions.ts
index 22629b6..ce01a50 100644
--- a/src/store/dialog/dialog-actions.ts
+++ b/src/store/dialog/dialog-actions.ts
@@ -6,7 +6,8 @@ import { unionize, ofType, UnionOf } from "~/common/unionize";
 
 export const dialogActions = unionize({
     OPEN_DIALOG: ofType<{ id: string, data: any }>(),
-    CLOSE_DIALOG: ofType<{ id: string }>()
+    CLOSE_DIALOG: ofType<{ id: string }>(),
+    CLOSE_ALL_DIALOGS: ofType<{}>()
 });
 
 export type DialogAction = UnionOf<typeof dialogActions>;
diff --git a/src/store/dialog/dialog-reducer.ts b/src/store/dialog/dialog-reducer.ts
index 48f8ee8..775a4d5 100644
--- a/src/store/dialog/dialog-reducer.ts
+++ b/src/store/dialog/dialog-reducer.ts
@@ -6,19 +6,24 @@ import { DialogAction, dialogActions } from "./dialog-actions";
 
 export type DialogState = Record<string, Dialog<any>>;
 
-export interface Dialog <T> {
+export interface Dialog<T> {
     open: boolean;
     data: T;
 }
 
-export const dialogReducer = (state: DialogState = {}, action: DialogAction) =>
+const initialState: DialogState = {};
+
+export const dialogReducer = (state: DialogState = initialState, action: DialogAction) =>
+
     dialogActions.match(action, {
         OPEN_DIALOG: ({ id, data }) => ({ ...state, [id]: { open: true, data } }),
-        CLOSE_DIALOG: ({ id }) => ({ 
-            ...state, 
-            [id]: state[id] ? { ...state[id], open: false } : { open: false, data: {} } }),
+        CLOSE_DIALOG: ({ id }) => ({
+            ...state,
+            [id]: state[id] ? { ...state[id], open: false } : { open: false, data: {} }
+        }),
+        CLOSE_ALL_DIALOGS: () => ({ ...initialState }),
         default: () => state,
     });
 
-export const getDialog = <T>(state: DialogState, id: string) => 
+export const getDialog = <T>(state: DialogState, id: string) =>
     state[id] ? state[id] as Dialog<T> : undefined;

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list