mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
fix: When community node added as tool, don't show details view (#16539)
This commit is contained in:
@@ -21,7 +21,7 @@ import { N8nTooltip } from '@n8n/design-system';
|
|||||||
import { useActions } from '../composables/useActions';
|
import { useActions } from '../composables/useActions';
|
||||||
import { useViewStacks } from '../composables/useViewStacks';
|
import { useViewStacks } from '../composables/useViewStacks';
|
||||||
import { useI18n } from '@n8n/i18n';
|
import { useI18n } from '@n8n/i18n';
|
||||||
import { isNodePreviewKey, removePreviewToken } from '../utils';
|
import { isNodePreviewKey, removePreviewToken, shouldShowCommunityNodeDetails } from '../utils';
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
nodeType: SimplifiedNodeType;
|
nodeType: SimplifiedNodeType;
|
||||||
@@ -68,9 +68,9 @@ const description = computed<string>(() => {
|
|||||||
fallback: props.nodeType.description,
|
fallback: props.nodeType.description,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const showActionArrow = computed(() => {
|
const showActionArrow = computed(() => {
|
||||||
// show action arrow if it's a community node and the community node details are not opened
|
if (shouldShowCommunityNodeDetails(isCommunityNode.value, activeViewStack)) {
|
||||||
if (isCommunityNode.value && !activeViewStack.communityNodeDetails) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import {
|
|||||||
prepareCommunityNodeDetailsViewStack,
|
prepareCommunityNodeDetailsViewStack,
|
||||||
transformNodeType,
|
transformNodeType,
|
||||||
getRootSearchCallouts,
|
getRootSearchCallouts,
|
||||||
|
shouldShowCommunityNodeDetails,
|
||||||
} from '../utils';
|
} from '../utils';
|
||||||
import { useViewStacks } from '../composables/useViewStacks';
|
import { useViewStacks } from '../composables/useViewStacks';
|
||||||
import { useKeyboardNavigation } from '../composables/useKeyboardNavigation';
|
import { useKeyboardNavigation } from '../composables/useKeyboardNavigation';
|
||||||
@@ -140,7 +141,7 @@ function onSelected(item: INodeCreateElement) {
|
|||||||
if (item.type === 'node') {
|
if (item.type === 'node') {
|
||||||
let nodeActions = getFilteredActions(item, actions);
|
let nodeActions = getFilteredActions(item, actions);
|
||||||
|
|
||||||
if (isCommunityPackageName(item.key) && !activeViewStack.value.communityNodeDetails) {
|
if (shouldShowCommunityNodeDetails(isCommunityPackageName(item.key), activeViewStack.value)) {
|
||||||
if (!nodeActions.length) {
|
if (!nodeActions.length) {
|
||||||
nodeActions = getFilteredActions(item, communityNodesAndActions.value.actions);
|
nodeActions = getFilteredActions(item, communityNodesAndActions.value.actions);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
prepareCommunityNodeDetailsViewStack,
|
prepareCommunityNodeDetailsViewStack,
|
||||||
removeTrailingTrigger,
|
removeTrailingTrigger,
|
||||||
sortNodeCreateElements,
|
sortNodeCreateElements,
|
||||||
|
shouldShowCommunityNodeDetails,
|
||||||
} from './utils';
|
} from './utils';
|
||||||
import {
|
import {
|
||||||
mockActionCreateElement,
|
mockActionCreateElement,
|
||||||
@@ -20,6 +21,9 @@ import {
|
|||||||
import { setActivePinia } from 'pinia';
|
import { setActivePinia } from 'pinia';
|
||||||
import { createTestingPinia } from '@pinia/testing';
|
import { createTestingPinia } from '@pinia/testing';
|
||||||
|
|
||||||
|
import { mock } from 'vitest-mock-extended';
|
||||||
|
import type { ViewStack } from './composables/useViewStacks';
|
||||||
|
|
||||||
vi.mock('@/stores/settings.store', () => ({
|
vi.mock('@/stores/settings.store', () => ({
|
||||||
useSettingsStore: vi.fn(() => ({ settings: {}, isAskAiEnabled: true })),
|
useSettingsStore: vi.fn(() => ({ settings: {}, isAskAiEnabled: true })),
|
||||||
}));
|
}));
|
||||||
@@ -354,4 +358,25 @@ describe('NodeCreator - utils', () => {
|
|||||||
expect(removeTrailingTrigger(input)).toEqual(expected);
|
expect(removeTrailingTrigger(input)).toEqual(expected);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('shouldShowCommunityNodeDetails', () => {
|
||||||
|
it('should return false if rootView is "AI Other" and title is "Tools"', () => {
|
||||||
|
const viewStack = mock<ViewStack>({ rootView: 'AI Other', title: 'Tools' });
|
||||||
|
expect(shouldShowCommunityNodeDetails(true, viewStack)).toBe(false);
|
||||||
|
expect(shouldShowCommunityNodeDetails(false, viewStack)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return false if communityNode is true and communityNodeDetails is defined in viewStack', () => {
|
||||||
|
const viewStack = mock<ViewStack>({ communityNodeDetails: { title: 'test' } });
|
||||||
|
expect(shouldShowCommunityNodeDetails(true, viewStack)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return true if communityNode is true and communityNodeDetails is not defined in viewStack, and the viewStack does not have rootView "AI Other" and title "Tools"', () => {
|
||||||
|
expect(shouldShowCommunityNodeDetails(true, {})).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return false if communityNode is false and communityNodeDetails is not defined in viewStack', () => {
|
||||||
|
expect(shouldShowCommunityNodeDetails(false, {})).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -328,3 +328,11 @@ export function getRootSearchCallouts(search: string, { isRagStarterCalloutVisib
|
|||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const shouldShowCommunityNodeDetails = (communityNode: boolean, viewStack: ViewStack) => {
|
||||||
|
if (viewStack.rootView === 'AI Other' && viewStack.title === 'Tools') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return communityNode && !viewStack.communityNodeDetails;
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user