X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/975f9b6c2e0f6d5988c01d7dbe6e2a6214d54de6..31e84a9315728c2f58a26bf0e9e1d2b38326fb86:/src/store/context-menu/context-menu-reducer.ts?ds=sidebyside diff --git a/src/store/context-menu/context-menu-reducer.ts b/src/store/context-menu/context-menu-reducer.ts index 9a825a5f..03d9cc78 100644 --- a/src/store/context-menu/context-menu-reducer.ts +++ b/src/store/context-menu/context-menu-reducer.ts @@ -2,31 +2,28 @@ // // SPDX-License-Identifier: AGPL-3.0 -// import actions, { DetailsPanelAction } from "./details-panel-action"; -// import { Resource, ResourceKind } from "../../models/resource"; +import { contextMenuActions, ContextMenuAction, ContextMenuResource } from "./context-menu-actions"; -// export interface ContextMenuState { -// position: { -// x: number; -// y: number; -// }, -// resource: { -// uuid: string; -// kind: ResourceKind. -// } -// } +export interface ContextMenuState { + open: boolean; + position: ContextMenuPosition; + resource?: ContextMenuResource; +} -// const initialState = { -// item: null, -// isOpened: false -// }; +export interface ContextMenuPosition { + x: number; + y: number; +} -// const reducer = (state: DetailsPanelState = initialState, action: DetailsPanelAction) => -// actions.match(action, { -// default: () => state, -// LOAD_DETAILS: () => state, -// LOAD_DETAILS_SUCCESS: ({ item }) => ({ ...state, item }), -// TOGGLE_DETAILS_PANEL: () => ({ ...state, isOpened: !state.isOpened }) -// }); +const initialState = { + open: false, + position: { x: 0, y: 0 } +}; + +export const contextMenuReducer = (state: ContextMenuState = initialState, action: ContextMenuAction) => + contextMenuActions.match(action, { + default: () => state, + OPEN_CONTEXT_MENU: ({ resource, position }) => ({ open: true, resource, position }), + CLOSE_CONTEXT_MENU: () => ({ ...state, open: false }) + }); -// export default reducer;