Restric order and filters arguments of favorite list
[arvados-workbench2.git] / src / store / context-menu / context-menu-reducer.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { ResourceKind } from "../../models/resource";
6 import actions, { ContextMenuAction } from "./context-menu-actions";
7
8 export interface ContextMenuState {
9     position: ContextMenuPosition;
10     resource?: ContextMenuResource;
11 }
12
13 export interface ContextMenuPosition {
14     x: number;
15     y: number;
16 }
17
18 export interface ContextMenuResource {
19     uuid: string;
20     kind: string;
21 }
22
23 const initialState = {
24     position: { x: 0, y: 0 }
25 };
26
27 const reducer = (state: ContextMenuState = initialState, action: ContextMenuAction) =>
28     actions.match(action, {
29         default: () => state,
30         OPEN_CONTEXT_MENU: ({resource, position}) => ({ resource, position }),
31         CLOSE_CONTEXT_MENU: () => ({ position: state.position })
32     });
33
34 export default reducer;