X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/99d2472afc89ca78a4fef46ac08ce520b3bcf17b..378c6a3a18cd9849bf4233e130a9ffdf250de35e:/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 69f9c9af70..8b51478d2b 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; } @@ -17,18 +17,19 @@ export interface ContextMenuPosition { export interface ContextMenuResource { uuid: string; - kind: ResourceKind; + kind: string; + name: 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;