1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { contextMenuActions, ContextMenuAction, ContextMenuResource } from "./context-menu-actions";
7 export interface ContextMenuState {
9 position: ContextMenuPosition;
10 resource?: ContextMenuResource;
13 export interface ContextMenuPosition {
18 const initialState = {
20 position: { x: 0, y: 0 }
23 export const contextMenuReducer = (state: ContextMenuState = initialState, action: ContextMenuAction) =>
24 contextMenuActions.match(action, {
26 OPEN_CONTEXT_MENU: ({ resource, position }) => ({ open: true, resource, position }),
27 CLOSE_CONTEXT_MENU: () => ({ ...state, open: false })