X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/9fed03a84c6ef5234d61f7d62c93f7629da2409d..df9ea1569dd0d4ae1c05bacc8a5e5f7695f4453b:/src/store/dialog/dialog-reducer.ts diff --git a/src/store/dialog/dialog-reducer.ts b/src/store/dialog/dialog-reducer.ts index e49f65de..48f8ee8a 100644 --- a/src/store/dialog/dialog-reducer.ts +++ b/src/store/dialog/dialog-reducer.ts @@ -4,11 +4,11 @@ import { DialogAction, dialogActions } from "./dialog-actions"; -export type DialogState = Record; +export type DialogState = Record>; -export interface Dialog { +export interface Dialog { open: boolean; - data?: any; + data: T; } export const dialogReducer = (state: DialogState = {}, action: DialogAction) => @@ -16,7 +16,9 @@ export const dialogReducer = (state: DialogState = {}, action: DialogAction) => OPEN_DIALOG: ({ id, data }) => ({ ...state, [id]: { open: true, data } }), CLOSE_DIALOG: ({ id }) => ({ ...state, - [id]: state[id] ? { ...state[id], open: false } : { open: false } }), + [id]: state[id] ? { ...state[id], open: false } : { open: false, data: {} } }), default: () => state, }); +export const getDialog = (state: DialogState, id: string) => + state[id] ? state[id] as Dialog : undefined;