X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/77c5d854b58b46395c5db5531268494d40f27786..08f915990ffe4588c076efce4d01e0b3bed2b398:/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 603ee90b..09f6e19c 100644
--- a/src/views-components/context-menu/context-menu.tsx
+++ b/src/views-components/context-menu/context-menu.tsx
@@ -14,9 +14,10 @@ import { sortByProperty } from "common/array-utils";
 type DataProps = Pick<ContextMenuProps, "anchorEl" | "items" | "open"> & { resource?: ContextMenuResource };
 const mapStateToProps = (state: RootState): DataProps => {
     const { open, position, resource } = state.contextMenu;
+    const isAdmin = state.auth.user!.isAdmin;
     return {
         anchorEl: resource ? createAnchorAt(position) : undefined,
-        items: getMenuActionSet(resource),
+        items: getMenuActionSet(resource, isAdmin),
         open,
         resource
     };
@@ -59,8 +60,15 @@ export const addMenuActionSet = (name: string, itemSet: ContextMenuActionSet) =>
 };
 
 const emptyActionSet: ContextMenuActionSet = [];
-const getMenuActionSet = (resource?: ContextMenuResource): ContextMenuActionSet => {
-    return resource ? menuActionSets.get(resource.menuKind) || emptyActionSet : emptyActionSet;
+const getMenuActionSet = (resource?: ContextMenuResource, isAdmin?: boolean): ContextMenuActionSet => {
+    if (resource) {
+        return menuActionSets
+            .get(resource.menuKind)!
+            .map((group) => (group.filter((item) => (item.adminOnly ? isAdmin : true))))
+            || emptyActionSet
+    } else {
+        return emptyActionSet;
+    }
 };
 
 export enum ContextMenuKind {
@@ -98,5 +106,6 @@ export enum ContextMenuKind {
     USER = "User",
     GROUPS = "Group",
     GROUP_MEMBER = "GroupMember",
+    PERMISSION_EDIT = "PermissionEdit",
     LINK = "Link",
 }
