Merge branch 'master' into 13540-add-possibility-to-open-files-in-third-party-apps
[arvados-workbench2.git] / src / store / dialog / dialog-reducer.ts
index 48f8ee8a1e6caac149fb07b8c94a10a46a3f2377..30368685064dfe6f9837d7c20d0cc4808b0cbf01 100644 (file)
@@ -6,19 +6,22 @@ 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) =>
+
     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: () => ({ }),
         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;