From dd0c098b86330ba09c1df5f7fceb9df47958ae04 Mon Sep 17 00:00:00 2001 From: Michael Kret <88898367+michael-radency@users.noreply.github.com> Date: Fri, 23 Aug 2024 11:48:01 +0300 Subject: [PATCH] fix(AI Transform Node): Data Transformation > Other section should not contain node (no-changelog) (#10519) --- .../NodeCreator/composables/useViewStacks.ts | 17 +++++++++++++++-- .../components/Node/NodeCreator/viewsData.ts | 13 ++++++------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/packages/editor-ui/src/components/Node/NodeCreator/composables/useViewStacks.ts b/packages/editor-ui/src/components/Node/NodeCreator/composables/useViewStacks.ts index 891c360e2c..2ce7aad64d 100644 --- a/packages/editor-ui/src/components/Node/NodeCreator/composables/useViewStacks.ts +++ b/packages/editor-ui/src/components/Node/NodeCreator/composables/useViewStacks.ts @@ -36,8 +36,14 @@ import { useI18n } from '@/composables/useI18n'; import { useKeyboardNavigation } from './useKeyboardNavigation'; import { useNodeTypesStore } from '@/stores/nodeTypes.store'; -import type { INodeInputFilter, NodeConnectionType, Themed } from 'n8n-workflow'; +import { + AI_TRANSFORM_NODE_TYPE, + type INodeInputFilter, + type NodeConnectionType, + type Themed, +} from 'n8n-workflow'; import { useCanvasStore } from '@/stores/canvas.store'; +import { usePostHog } from '../../../../stores/posthog.store'; interface ViewStack { uuid?: string; @@ -350,7 +356,14 @@ export const useViewStacks = defineStore('nodeCreatorViewStacks', () => { if (!stack?.items) { const subcategory = stack?.subcategory ?? DEFAULT_SUBCATEGORY; - const itemsInSubcategory = itemsBySubcategory.value[subcategory]; + let itemsInSubcategory = itemsBySubcategory.value[subcategory]; + + const aiEnabled = usePostHog().isAiEnabled(); + if (!aiEnabled) { + itemsInSubcategory = itemsInSubcategory.filter( + (item) => item.key !== AI_TRANSFORM_NODE_TYPE, + ); + } const sections = stack.sections; if (sections) { diff --git a/packages/editor-ui/src/components/Node/NodeCreator/viewsData.ts b/packages/editor-ui/src/components/Node/NodeCreator/viewsData.ts index 479a85f644..33d3626d7e 100644 --- a/packages/editor-ui/src/components/Node/NodeCreator/viewsData.ts +++ b/packages/editor-ui/src/components/Node/NodeCreator/viewsData.ts @@ -64,7 +64,6 @@ import { NodeConnectionType } from 'n8n-workflow'; import { useTemplatesStore } from '@/stores/templates.store'; import type { BaseTextKey } from '@/plugins/i18n'; import { camelCase } from 'lodash-es'; -import { usePostHog } from '@/stores/posthog.store'; export interface NodeViewItemSection { key: string; @@ -431,12 +430,12 @@ export function TriggerView() { export function RegularView(nodes: SimplifiedNodeType[]) { const i18n = useI18n(); - const popularItemsSubcategory = [SET_NODE_TYPE, CODE_NODE_TYPE, DATETIME_NODE_TYPE]; - const aiEnabled = usePostHog().isAiEnabled(); - - if (aiEnabled) { - popularItemsSubcategory.push(AI_TRANSFORM_NODE_TYPE); - } + const popularItemsSubcategory = [ + SET_NODE_TYPE, + CODE_NODE_TYPE, + DATETIME_NODE_TYPE, + AI_TRANSFORM_NODE_TYPE, + ]; const view: NodeView = { value: REGULAR_NODE_CREATOR_VIEW,