X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/77c5d854b58b46395c5db5531268494d40f27786..0f55c7182b5231712e77f2538dd0c69336558647:/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 603ee90b81..a8e7fd028a 100644
--- a/src/views-components/context-menu/context-menu.tsx
+++ b/src/views-components/context-menu/context-menu.tsx
@@ -14,9 +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 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),
+        items: filteredItems,
         open,
         resource
     };
@@ -59,9 +69,9 @@ 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): ContextMenuActionSet => (
+    resource ? menuActionSets.get(resource.menuKind) || emptyActionSet : emptyActionSet
+);
 
 export enum ContextMenuKind {
     API_CLIENT_AUTHORIZATION = "ApiClientAuthorization",
@@ -98,5 +108,8 @@ export enum ContextMenuKind {
     USER = "User",
     GROUPS = "Group",
     GROUP_MEMBER = "GroupMember",
+    PERMISSION_EDIT = "PermissionEdit",
     LINK = "Link",
+    WORKFLOW = "Workflow",
+    SEARCH_RESULTS = "SearchResults"
 }
