feat(AI Transform Node): New node (#10405)

Co-authored-by: Giulio Andreini <g.andreini@gmail.com>
Co-authored-by: Shireen Missi <94372015+ShireenMissi@users.noreply.github.com>
This commit is contained in:
Michael Kret
2024-08-14 16:20:02 +03:00
committed by GitHub
parent 5ed2a77740
commit 4d222ac19d
24 changed files with 839 additions and 39 deletions

View File

@@ -9,6 +9,7 @@ import type {
import {
AI_CATEGORY_AGENTS,
AI_SUBCATEGORY,
AI_TRANSFORM_NODE_TYPE,
CORE_NODES_CATEGORY,
DEFAULT_SUBCATEGORY,
} from '@/constants';
@@ -19,6 +20,8 @@ import type { NodeViewItemSection } from './viewsData';
import { i18n } from '@/plugins/i18n';
import { sortBy } from 'lodash-es';
import { usePostHog } from '@/stores/posthog.store';
export function transformNodeType(
node: SimplifiedNodeType,
subcategory?: string,
@@ -74,6 +77,11 @@ export function sortNodeCreateElements(nodes: INodeCreateElement[]) {
}
export function searchNodes(searchFilter: string, items: INodeCreateElement[]) {
const aiEnabled = usePostHog().isAiEnabled();
if (!aiEnabled) {
items = items.filter((item) => item.key !== AI_TRANSFORM_NODE_TYPE);
}
// In order to support the old search we need to remove the 'trigger' part
const trimmedFilter = searchFilter.toLowerCase().replace('trigger', '').trimEnd();

View File

@@ -1,4 +1,5 @@
import {
AI_TRANSFORM_NODE_TYPE,
CORE_NODES_CATEGORY,
WEBHOOK_NODE_TYPE,
OTHER_TRIGGER_NODES_SUBCATEGORY,
@@ -63,6 +64,7 @@ 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;
@@ -429,6 +431,13 @@ 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 view: NodeView = {
value: REGULAR_NODE_CREATOR_VIEW,
title: i18n.baseText('nodeCreator.triggerHelperPanel.whatHappensNext'),
@@ -453,7 +462,7 @@ export function RegularView(nodes: SimplifiedNodeType[]) {
{
key: 'popular',
title: i18n.baseText('nodeCreator.sectionNames.popular'),
items: [SET_NODE_TYPE, CODE_NODE_TYPE, DATETIME_NODE_TYPE],
items: popularItemsSubcategory,
},
{
key: 'addOrRemove',