Implement better pattern for hanling actions in context menu
[arvados-workbench2.git] / src / views-components / context-menu / project-item-set.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { ContextMenuItemGroup } from "../../components/context-menu/context-menu";
6 import { ContextMenuItemSet } from "./context-menu-item-set";
7 import actions from "../../store/project/project-action";
8
9 export const projectItemSet: ContextMenuItemSet = {
10     getItems: () => items,
11     handleItem: (dispatch, item, resource) => {
12         if (item.name === "New project") {
13             dispatch(actions.OPEN_PROJECT_CREATOR({ ownerUuid: resource.uuid }));
14         }
15     }
16 };
17
18 const items: ContextMenuItemGroup[] = [[{
19     icon: "fas fa-plus fa-fw",
20     name: "New project"
21 }, {
22     icon: "fas fa-users fa-fw",
23     name: "Share"
24 }, {
25     icon: "fas fa-sign-out-alt fa-fw",
26     name: "Move to"
27 }, {
28     icon: "fas fa-star fa-fw",
29     name: "Add to favourite"
30 }, {
31     icon: "fas fa-edit fa-fw",
32     name: "Rename"
33 }, {
34     icon: "fas fa-copy fa-fw",
35     name: "Make a copy"
36 }, {
37     icon: "fas fa-download fa-fw",
38     name: "Download"
39 }], [{
40     icon: "fas fa-trash-alt fa-fw",
41     name: "Remove"
42 }
43 ]];