From 28596d30668be79b92b344856e6b307a735da488 Mon Sep 17 00:00:00 2001 From: Ahmed Awan Date: Tue, 29 Oct 2024 11:39:43 -0500 Subject: [PATCH] Add a filter for `labels` (tags) in Tool Search Fixes https://github.com/galaxyproject/galaxy/issues/19069 --- client/src/components/Panels/utilities.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/client/src/components/Panels/utilities.ts b/client/src/components/Panels/utilities.ts index 95da1acbbf69..27dde0d1cf86 100644 --- a/client/src/components/Panels/utilities.ts +++ b/client/src/components/Panels/utilities.ts @@ -15,6 +15,7 @@ import levenshteinDistance from "@/utils/levenshtein"; const FILTER_KEYS = { id: ["id", "tool_id"], panel_section_name: ["section", "panel_section_name"], + labels: ["label", "labels", "tag"], }; const STRING_REPLACEMENTS: string[] = [" ", "-", "\\(", "\\)", "'", ":", `"`]; const MINIMUM_DL_LENGTH = 5; // for Demerau-Levenshtein distance @@ -286,7 +287,14 @@ export function searchToolsByKeys( if (key === "combined") { actualValue = `${tool.name.trim()} ${tool.description.trim()}`.toLowerCase(); } else { - actualValue = (tool[key as keyof Tool] as string)?.trim().toLowerCase(); + const toolVal = tool[key as keyof Tool]; + if (typeof toolVal === "string") { + actualValue = toolVal.trim().toLowerCase(); + } else if (Array.isArray(toolVal)) { + actualValue = toolVal.join(" ").trim().toLowerCase(); + } else if (typeof toolVal === "number") { + actualValue = toolVal.toString().trim().toLowerCase(); + } } // get all (space separated) words in actualValue for tool (for DL)