From 17b6fb37791315602c4a127dbdef1a985a73e0b8 Mon Sep 17 00:00:00 2001 From: Laila Los <44241786+ElectronicBlueberry@users.noreply.github.com> Date: Tue, 26 Mar 2024 12:13:29 +0100 Subject: [PATCH 1/3] add getShortToolId util --- client/src/utils/tool.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 client/src/utils/tool.ts diff --git a/client/src/utils/tool.ts b/client/src/utils/tool.ts new file mode 100644 index 000000000000..941a1bba8c90 --- /dev/null +++ b/client/src/utils/tool.ts @@ -0,0 +1,12 @@ +/** + * Converts a long tool ID to a short tool id. + * If the passed in ID is short already, returns it. + * @param longId long tool-id + * @returns short tool-id + */ +export function getShortToolId(longId: string): string { + const toolIdSlash = longId.split("/"); + const shortId = toolIdSlash[toolIdSlash.length - 2]; + + return shortId ?? longId; +} From 92bfdb20ff9998d33a993de0b754d9d2ae0fda32 Mon Sep 17 00:00:00 2001 From: Laila Los <44241786+ElectronicBlueberry@users.noreply.github.com> Date: Tue, 26 Mar 2024 12:14:08 +0100 Subject: [PATCH 2/3] consolidate tool id shortening methods --- client/src/components/ToolRecommendation.vue | 9 +++------ .../src/components/Workflow/Editor/Recommendations.vue | 7 ++----- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/client/src/components/ToolRecommendation.vue b/client/src/components/ToolRecommendation.vue index bf3e4f891bb8..7df9be1a2660 100644 --- a/client/src/components/ToolRecommendation.vue +++ b/client/src/components/ToolRecommendation.vue @@ -22,6 +22,8 @@ import { getCompatibleRecommendations } from "components/Workflow/Editor/modules import * as d3 from "d3"; import { getAppRoot } from "onload/loadConfig"; +import { getShortToolId } from "@/utils/tool"; + export default { props: { toolId: { @@ -38,12 +40,7 @@ export default { }, computed: { getToolId() { - let toolId = this.toolId || ""; - if (toolId.indexOf("/") > 0) { - const toolIdSlash = toolId.split("/"); - toolId = toolIdSlash[toolIdSlash.length - 2]; - } - return toolId; + return getShortToolId(this.toolId ?? ""); }, }, created() { diff --git a/client/src/components/Workflow/Editor/Recommendations.vue b/client/src/components/Workflow/Editor/Recommendations.vue index 5d1153cb5744..81b741c11903 100644 --- a/client/src/components/Workflow/Editor/Recommendations.vue +++ b/client/src/components/Workflow/Editor/Recommendations.vue @@ -22,6 +22,7 @@ import LoadingSpan from "components/LoadingSpan"; import _l from "utils/localization"; import { useWorkflowStores } from "@/composables/workflowStores"; +import { getShortToolId } from "@/utils/tool"; import { getToolPredictions } from "./modules/services"; import { getCompatibleRecommendations } from "./modules/utilities"; @@ -59,11 +60,7 @@ export default { }, methods: { getToolId(toolId) { - if (toolId !== undefined && toolId !== null && toolId.indexOf("/") > -1) { - const toolIdSlash = toolId.split("/"); - toolId = toolIdSlash[toolIdSlash.length - 2]; - } - return toolId; + return getShortToolId(toolId ?? ""); }, getWorkflowPath(currentNodeId) { const steps = {}; From 2b321eff736ae819d6c53b639d643f41f1e92b93 Mon Sep 17 00:00:00 2001 From: Laila Los <44241786+ElectronicBlueberry@users.noreply.github.com> Date: Tue, 26 Mar 2024 12:14:25 +0100 Subject: [PATCH 3/3] use short tool id as help forum tag --- client/src/components/Tool/ToolHelpForum.vue | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client/src/components/Tool/ToolHelpForum.vue b/client/src/components/Tool/ToolHelpForum.vue index da592eba6035..a3b14d538e23 100644 --- a/client/src/components/Tool/ToolHelpForum.vue +++ b/client/src/components/Tool/ToolHelpForum.vue @@ -5,6 +5,7 @@ import { computed, onMounted, ref } from "vue"; import { fetcher } from "@/api/schema"; import { useConfigStore } from "@/stores/configurationStore"; +import { getShortToolId } from "@/utils/tool"; import { createTopicUrl, type HelpForumPost, type HelpForumTopic, useHelpURLs } from "./helpForumUrls"; @@ -26,7 +27,8 @@ const helpAvailable = computed(() => topics.value.length > 0); const root = ref(null); -const query = computed(() => `tags:${props.toolId}+${toolHelpTag} status:solved`); +const shortToolId = computed(() => getShortToolId(props.toolId)); +const query = computed(() => `tags:${shortToolId.value}+${toolHelpTag} status:solved`); onMounted(async () => { const response = await helpFetcher({ query: query.value }); @@ -49,7 +51,7 @@ function blurbForTopic(topicId: number): string { const { createNewTopicUrl, searchTopicUrl } = useHelpURLs({ title: computed(() => props.toolName), - tags: computed(() => [props.toolId, toolHelpTag]), + tags: computed(() => [shortToolId.value, toolHelpTag]), query, });