From c2218334146136acc3560ffe43c46cdb845358ae Mon Sep 17 00:00:00 2001 From: Mutasem Aldmour <4711238+mutdmour@users.noreply.github.com> Date: Wed, 1 Oct 2025 11:01:04 +0200 Subject: [PATCH] fix: Show Builder's Ask Admin tooltip just for owner (#20246) --- .../Agent/AskAssistantBuild.test.ts | 28 +++++++++++++++++++ .../AskAssistant/Agent/AskAssistantBuild.vue | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/packages/frontend/editor-ui/src/components/AskAssistant/Agent/AskAssistantBuild.test.ts b/packages/frontend/editor-ui/src/components/AskAssistant/Agent/AskAssistantBuild.test.ts index 7514ae96984..9ca2e17be72 100644 --- a/packages/frontend/editor-ui/src/components/AskAssistant/Agent/AskAssistantBuild.test.ts +++ b/packages/frontend/editor-ui/src/components/AskAssistant/Agent/AskAssistantBuild.test.ts @@ -6,6 +6,7 @@ interface VueComponentInstance { __vueParentComponent?: { setupState?: { onUserMessage?: (message: string) => Promise; + showAskOwnerTooltip?: boolean; }; }; } @@ -94,6 +95,7 @@ import { mockedStore } from '@/__tests__/utils'; import { STORES } from '@n8n/stores'; import { useWorkflowsStore } from '@/stores/workflows.store'; import type { INodeUi } from '@/Interface'; +import { useUsersStore } from '@/stores/users.store'; vi.mock('@/event-bus', () => ({ nodeViewEventBus: { @@ -213,6 +215,32 @@ describe('AskAssistantBuild', () => { expect(builderStore.sendChatMessage).not.toHaveBeenCalled(); expect(builderStore.addAssistantMessages).not.toHaveBeenCalled(); }); + + it('should show ask owner tooltip when user is not instance owner', () => { + const usersStore = mockedStore(useUsersStore); + usersStore.isInstanceOwner = false; + + const { container } = renderComponent(); + + // Get the component instance + const vm = (container.firstElementChild as VueComponentInstance)?.__vueParentComponent; + const showAskOwnerTooltip = vm?.setupState?.showAskOwnerTooltip; + + expect(showAskOwnerTooltip).toBe(true); + }); + + it('should not show ask owner tooltip when user is instance owner', () => { + const usersStore = mockedStore(useUsersStore); + usersStore.isInstanceOwner = true; + + const { container } = renderComponent(); + + // Get the component instance + const vm = (container.firstElementChild as VueComponentInstance)?.__vueParentComponent; + const showAskOwnerTooltip = vm?.setupState?.showAskOwnerTooltip; + + expect(showAskOwnerTooltip).toBe(false); + }); }); describe('user message handling', () => { diff --git a/packages/frontend/editor-ui/src/components/AskAssistant/Agent/AskAssistantBuild.vue b/packages/frontend/editor-ui/src/components/AskAssistant/Agent/AskAssistantBuild.vue index 42fec552b78..e5ba69ec51f 100644 --- a/packages/frontend/editor-ui/src/components/AskAssistant/Agent/AskAssistantBuild.vue +++ b/packages/frontend/editor-ui/src/components/AskAssistant/Agent/AskAssistantBuild.vue @@ -52,7 +52,7 @@ const showExecuteMessage = computed(() => { }); const creditsQuota = computed(() => builderStore.creditsQuota); const creditsRemaining = computed(() => builderStore.creditsRemaining); -const showAskOwnerTooltip = computed(() => usersStore.isInstanceOwner); +const showAskOwnerTooltip = computed(() => !usersStore.isInstanceOwner); async function onUserMessage(content: string) { const isNewWorkflow = workflowsStore.isNewWorkflow;