X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/08f915990ffe4588c076efce4d01e0b3bed2b398..b375eb7f05d9862716f5c27ef8450043453c52ba:/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 09f6e19c..4766259a 100644
--- a/src/views-components/context-menu/context-menu.tsx
+++ b/src/views-components/context-menu/context-menu.tsx
@@ -14,10 +14,19 @@ 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;
+
+    const filteredItems = getMenuActionSet(resource).map((group) => (group.filter((item) => {
+        if (resource && item.filters) {
+            // Execute all filters on this item, every returns true IFF all filters return true
+            return item.filters.every((filter) => filter(state, resource));
+        } else {
+            return true;
+        }
+    })));
+
     return {
         anchorEl: resource ? createAnchorAt(position) : undefined,
-        items: getMenuActionSet(resource, isAdmin),
+        items: filteredItems,
         open,
         resource
     };
@@ -60,16 +69,9 @@ export const addMenuActionSet = (name: string, itemSet: ContextMenuActionSet) =>
 };
 
 const emptyActionSet: ContextMenuActionSet = [];
-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;
-    }
-};
+const getMenuActionSet = (resource?: ContextMenuResource): ContextMenuActionSet => (
+    resource ? menuActionSets.get(resource.menuKind) || emptyActionSet : emptyActionSet
+);
 
 export enum ContextMenuKind {
     API_CLIENT_AUTHORIZATION = "ApiClientAuthorization",
@@ -108,4 +110,5 @@ export enum ContextMenuKind {
     GROUP_MEMBER = "GroupMember",
     PERMISSION_EDIT = "PermissionEdit",
     LINK = "Link",
+    WORKFLOW = "Workflow",
 }
