X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/017dcf25de396de8e382c9a288c62e21717aa600..3626497d024cddee09990afd6e08a24debaf5c7b:/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..ac14c355 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 } from "./context-menu-actions"; export interface ContextMenuState { + open: boolean; position: ContextMenuPosition; resource?: ContextMenuResource; } @@ -18,17 +18,19 @@ export interface ContextMenuPosition { export interface ContextMenuResource { uuid: string; kind: string; + name: string; + description?: 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;