fix: Show Builder's Ask Admin tooltip just for owner (#20246)

This commit is contained in:
Mutasem Aldmour 2025-10-01 11:01:04 +02:00 committed by GitHub
parent c518574131
commit c221833414
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 29 additions and 1 deletions

View File

@ -6,6 +6,7 @@ interface VueComponentInstance {
__vueParentComponent?: {
setupState?: {
onUserMessage?: (message: string) => Promise<void>;
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', () => {

View File

@ -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;