From bdc3a9172df09a2b218fd447cd9c3eab6bcfcec6 Mon Sep 17 00:00:00 2001 From: Nikhil Kuriakose Date: Tue, 5 Aug 2025 11:23:07 +0200 Subject: [PATCH] fix(editor): Correct ai template url (#17908) --- .../src/components/Node/NodeCreator/viewsData.ts | 9 ++++++--- packages/frontend/editor-ui/src/constants.ts | 3 +++ .../frontend/editor-ui/src/stores/templates.store.ts | 7 +++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/frontend/editor-ui/src/components/Node/NodeCreator/viewsData.ts b/packages/frontend/editor-ui/src/components/Node/NodeCreator/viewsData.ts index 804c3a45ee..a28002107c 100644 --- a/packages/frontend/editor-ui/src/components/Node/NodeCreator/viewsData.ts +++ b/packages/frontend/editor-ui/src/components/Node/NodeCreator/viewsData.ts @@ -57,6 +57,7 @@ import { AI_CODE_TOOL_LANGCHAIN_NODE_TYPE, AI_WORKFLOW_TOOL_LANGCHAIN_NODE_TYPE, HUMAN_IN_THE_LOOP_CATEGORY, + TEMPLATE_CATEGORY_AI, } from '@/constants'; import { useI18n } from '@n8n/i18n'; import { useNodeTypesStore } from '@/stores/nodeTypes.store'; @@ -176,8 +177,10 @@ export function AIView(_nodes: SimplifiedNodeType[]): NodeView { const websiteCategoryURLParams = templatesStore.websiteTemplateRepositoryParameters; websiteCategoryURLParams.append('utm_user_role', 'AdvancedAI'); - const websiteCategoryURL = - templatesStore.constructTemplateRepositoryURL(websiteCategoryURLParams); + const aiTemplatesURL = templatesStore.constructTemplateRepositoryURL( + websiteCategoryURLParams, + TEMPLATE_CATEGORY_AI, + ); const askAiEnabled = useSettingsStore().isAskAiEnabled; const aiTransformNode = nodeTypesStore.getNodeType(AI_TRANSFORM_NODE_TYPE); @@ -196,7 +199,7 @@ export function AIView(_nodes: SimplifiedNodeType[]): NodeView { icon: 'box-open', description: i18n.baseText('nodeCreator.aiPanel.linkItem.description'), name: 'ai_templates_root', - url: websiteCategoryURL, + url: aiTemplatesURL, tag: { type: 'info', text: i18n.baseText('nodeCreator.triggerHelperPanel.manualTriggerTag'), diff --git a/packages/frontend/editor-ui/src/constants.ts b/packages/frontend/editor-ui/src/constants.ts index 2d15e446c4..9d6f2f2043 100644 --- a/packages/frontend/editor-ui/src/constants.ts +++ b/packages/frontend/editor-ui/src/constants.ts @@ -223,6 +223,9 @@ export const RESPOND_TO_WEBHOOK_NODE_TYPE = 'n8n-nodes-base.respondToWebhook'; export const CREDENTIAL_ONLY_NODE_PREFIX = 'n8n-creds-base'; export const CREDENTIAL_ONLY_HTTP_NODE_VERSION = 4.1; +// template categories +export const TEMPLATE_CATEGORY_AI = 'categories/ai'; + export const EXECUTABLE_TRIGGER_NODE_TYPES = [ START_NODE_TYPE, MANUAL_TRIGGER_NODE_TYPE, diff --git a/packages/frontend/editor-ui/src/stores/templates.store.ts b/packages/frontend/editor-ui/src/stores/templates.store.ts index 94c1265a50..63e71591c8 100644 --- a/packages/frontend/editor-ui/src/stores/templates.store.ts +++ b/packages/frontend/editor-ui/src/stores/templates.store.ts @@ -195,8 +195,11 @@ export const useTemplatesStore = defineStore(STORES.TEMPLATES, () => { `${TEMPLATES_URLS.BASE_WEBSITE_URL}${getTemplatePathByRole(userRole.value)}?${websiteTemplateRepositoryParameters.value.toString()}`, ); - const constructTemplateRepositoryURL = (params: URLSearchParams): string => { - return `${TEMPLATES_URLS.BASE_WEBSITE_URL}?${params.toString()}`; + const constructTemplateRepositoryURL = (params: URLSearchParams, category?: string): string => { + const baseUrl = category + ? `${TEMPLATES_URLS.BASE_WEBSITE_URL}${category}` + : TEMPLATES_URLS.BASE_WEBSITE_URL; + return `${baseUrl}?${params.toString()}`; }; const addCategories = (_categories: ITemplatesCategory[]): void => {