X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/c53693847e622ef89ba7d62a93fc7d60dc68e6df..fd44760652570645bb40ff9445bb5b9305a7fa1c:/src/views-components/context-menu/context-menu.tsx

diff --git a/src/views-components/context-menu/context-menu.tsx b/src/views-components/context-menu/context-menu.tsx
index d92948c8..db5765ee 100644
--- a/src/views-components/context-menu/context-menu.tsx
+++ b/src/views-components/context-menu/context-menu.tsx
@@ -4,13 +4,12 @@
 
 import { connect } from "react-redux";
 import { RootState } from "~/store/store";
-import { contextMenuActions } from "~/store/context-menu/context-menu-actions";
+import { contextMenuActions, ContextMenuResource } from "~/store/context-menu/context-menu-actions";
 import { ContextMenu as ContextMenuComponent, ContextMenuProps, ContextMenuItem } from "~/components/context-menu/context-menu";
 import { createAnchorAt } from "~/components/popover/helpers";
-import { ContextMenuResource } from "~/store/context-menu/context-menu-reducer";
 import { ContextMenuActionSet, ContextMenuAction } from "./context-menu-action-set";
 import { Dispatch } from "redux";
-
+import { memoize } from 'lodash';
 type DataProps = Pick<ContextMenuProps, "anchorEl" | "items" | "open"> & { resource?: ContextMenuResource };
 const mapStateToProps = (state: RootState): DataProps => {
     const { open, position, resource } = state.contextMenu;
@@ -35,14 +34,20 @@ const mapDispatchToProps = (dispatch: Dispatch): ActionProps => ({
     }
 });
 
+const handleItemClick = memoize(
+    (resource: DataProps['resource'], onItemClick: ActionProps['onItemClick']): ContextMenuProps['onItemClick'] =>
+        item => {
+            onItemClick(item, resource);
+        }
+);
+
 const mergeProps = ({ resource, ...dataProps }: DataProps, actionProps: ActionProps): ContextMenuProps => ({
     ...dataProps,
     ...actionProps,
-    onItemClick: item => {
-        actionProps.onItemClick(item, resource);
-    }
+    onItemClick: handleItemClick(resource, actionProps.onItemClick)
 });
 
+
 export const ContextMenu = connect(mapStateToProps, mapDispatchToProps, mergeProps)(ContextMenuComponent);
 
 const menuActionSets = new Map<string, ContextMenuActionSet>();
@@ -51,19 +56,41 @@ export const addMenuActionSet = (name: string, itemSet: ContextMenuActionSet) =>
     menuActionSets.set(name, itemSet);
 };
 
+const emptyActionSet: ContextMenuActionSet = [];
 const getMenuActionSet = (resource?: ContextMenuResource): ContextMenuActionSet => {
-    return resource ? menuActionSets.get(resource.kind) || [] : [];
+    return resource ? menuActionSets.get(resource.menuKind) || emptyActionSet : emptyActionSet;
 };
 
 export enum ContextMenuKind {
+    API_CLIENT_AUTHORIZATION = "ApiClientAuthorization",
     ROOT_PROJECT = "RootProject",
     PROJECT = "Project",
+    READONLY_PROJECT = 'ReadOnlyProject',
+    PROJECT_ADMIN = "ProjectAdmin",
     RESOURCE = "Resource",
     FAVORITE = "Favorite",
+    TRASH = "Trash",
     COLLECTION_FILES = "CollectionFiles",
+    READONLY_COLLECTION_FILES = "ReadOnlyCollectionFiles",
     COLLECTION_FILES_ITEM = "CollectionFilesItem",
+    READONLY_COLLECTION_FILES_ITEM = "ReadOnlyCollectionFilesItem",
+    COLLECTION_FILES_NOT_SELECTED = "CollectionFilesNotSelected",
     COLLECTION = 'Collection',
+    COLLECTION_ADMIN = 'CollectionAdmin',
     COLLECTION_RESOURCE = 'CollectionResource',
+    READONLY_COLLECTION = 'ReadOnlyCollection',
+    TRASHED_COLLECTION = 'TrashedCollection',
     PROCESS = "Process",
-    PROCESS_LOGS = "ProcessLogs"
+    PROCESS_ADMIN = 'ProcessAdmin',
+    PROCESS_RESOURCE = 'ProcessResource',
+    PROCESS_LOGS = "ProcessLogs",
+    REPOSITORY = "Repository",
+    SSH_KEY = "SshKey",
+    VIRTUAL_MACHINE = "VirtualMachine",
+    KEEP_SERVICE = "KeepService",
+    USER = "User",
+    NODE = "Node",
+    GROUPS = "Group",
+    GROUP_MEMBER = "GroupMember",
+    LINK = "Link",
 }
