X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/e6039bec0497aa7e1391958e5c4f84bbaeef653e..2a7fd99c212c33a1ec9911f8529fa5afc59a7bb2:/src/store/context-menu/context-menu-reducer.ts diff --git a/src/store/context-menu/context-menu-reducer.ts b/src/store/context-menu/context-menu-reducer.ts index 147f094336..03d9cc7843 100644 --- a/src/store/context-menu/context-menu-reducer.ts +++ b/src/store/context-menu/context-menu-reducer.ts @@ -2,10 +2,10 @@ // // SPDX-License-Identifier: AGPL-3.0 -import { ResourceKind } from "../../models/resource"; -import actions, { ContextMenuAction } from "./context-menu-actions"; +import { contextMenuActions, ContextMenuAction, ContextMenuResource } from "./context-menu-actions"; export interface ContextMenuState { + open: boolean; position: ContextMenuPosition; resource?: ContextMenuResource; } @@ -15,20 +15,15 @@ export interface ContextMenuPosition { y: number; } -export interface ContextMenuResource { - uuid: string; - kind: string; -} - const initialState = { + open: false, position: { x: 0, y: 0 } }; -const reducer = (state: ContextMenuState = initialState, action: ContextMenuAction) => - actions.match(action, { +export const contextMenuReducer = (state: ContextMenuState = initialState, action: ContextMenuAction) => + contextMenuActions.match(action, { default: () => state, - OPEN_CONTEXT_MENU: ({resource, position}) => ({ resource, position }), - CLOSE_CONTEXT_MENU: () => ({ position: state.position }) + OPEN_CONTEXT_MENU: ({ resource, position }) => ({ open: true, resource, position }), + CLOSE_CONTEXT_MENU: () => ({ ...state, open: false }) }); -export default reducer;