X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/9320734bb358e7148918da13e81ebba59ecf16e8..a39bf00394970696d31d163104c163ad0dd1da80:/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 147f0943..03d9cc78 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;