Create getDialog selector
authorMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Sat, 18 Aug 2018 09:22:15 +0000 (11:22 +0200)
committerMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Sat, 18 Aug 2018 09:22:15 +0000 (11:22 +0200)
Feature #14015

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

src/store/dialog/dialog-reducer.ts

index 34d38fdf4ea6e2d39dc28814a2f2a1dcee5e9733..1675db4d76f6c226076b59bf1f6ac04848cb2e86 100644 (file)
@@ -6,9 +6,9 @@ import { DialogAction, dialogActions } from "./dialog-actions";
 
 export type DialogState = Record<string, Dialog>;
 
-export interface Dialog {
+export interface Dialog <T = any> {
     open: boolean;
-    data: any;
+    data: T;
 }
 
 export const dialogReducer = (state: DialogState = {}, action: DialogAction) =>
@@ -20,3 +20,5 @@ export const dialogReducer = (state: DialogState = {}, action: DialogAction) =>
         default: () => state,
     });
 
+export const getDialog = <T>(state: DialogState, id: string) => 
+    state[id] ? state[id] as Dialog<T> : undefined;