Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(editor): Data transformation nodes and actions in Nodes Panel #7760

Merged
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
85ce52e
Review node descriptions
elsmr Nov 16, 2023
2256985
Scaffold new nodes from ItemList node
elsmr Nov 17, 2023
ce086d5
Split ItemsList node into 1 node per operation
elsmr Nov 20, 2023
9de95d3
Add codex for new nodes
elsmr Nov 20, 2023
d5f8c6c
Merge branch 'master' into node-936-data-transformation-nodes-and-act…
elsmr Dec 1, 2023
27a9e93
Add new icons
elsmr Dec 1, 2023
be97b05
Define sections for subcategories
elsmr Dec 4, 2023
74c453c
Merge branch 'master' into node-936-data-transformation-nodes-and-act…
elsmr Dec 4, 2023
cdd8dd3
Add tests for new list nodes
elsmr Dec 4, 2023
96691f7
Add sections for all subcategories except files
elsmr Dec 4, 2023
c6bc663
Sort items in sections alphabetically
elsmr Dec 4, 2023
7b1e02e
Copy tweaks to nodes descriptions.
gandreini Dec 5, 2023
8647fd1
Fix sorting (behavior is different across browsers)
elsmr Dec 5, 2023
46c3f7b
Update packages/nodes-base/nodes/Transform/RemoveDuplicates/RemoveDup…
elsmr Dec 6, 2023
feb163a
Update packages/nodes-base/nodes/Transform/SplitOut/SplitOut.node.json
elsmr Dec 6, 2023
bbf2db0
Icons updates.
gandreini Dec 6, 2023
8b22414
Merge branch 'node-936-data-transformation-nodes-and-actions-in-nodes…
gandreini Dec 6, 2023
c5281ca
Add test for node creator sorting
elsmr Dec 6, 2023
5bf312f
Merge branch 'master' of https://github.com/n8n-io/n8n into node-936-…
michael-radency Dec 8, 2023
c9c2e1b
Migrate Item Lists nodes in e2e tests
elsmr Dec 8, 2023
59f9eed
Fix e2e tests
elsmr Dec 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ function subcategoriesMapper(item: INodeCreateElement) {
}

function baseSubcategoriesFilter(item: INodeCreateElement): boolean {
if (item.type === 'section') return item.children.every(baseSubcategoriesFilter);
if (item.type === 'section') return true;
if (item.type !== 'node') return false;

const hasTriggerGroup = item.properties.group.includes('trigger');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { SectionCreateElement } from '@/Interface';
import { groupItemsInSections } from '../utils';
import { mockNodeCreateElement } from './utils';
import { groupItemsInSections, sortNodeCreateElements } from '../utils';
import { mockActionCreateElement, mockNodeCreateElement, mockSectionCreateElement } from './utils';

describe('NodeCreator - utils', () => {
describe('groupItemsInSections', () => {
Expand Down Expand Up @@ -46,4 +46,20 @@ describe('NodeCreator - utils', () => {
expect(result).toEqual([node1, node2, node3]);
});
});

describe('sortNodeCreateElements', () => {
it('should sort nodes alphabetically by displayName', () => {
const node1 = mockNodeCreateElement({ key: 'newNode' }, { displayName: 'xyz' });
const node2 = mockNodeCreateElement({ key: 'popularNode' }, { displayName: 'abc' });
const node3 = mockNodeCreateElement({ key: 'otherNode' }, { displayName: 'ABC' });
expect(sortNodeCreateElements([node1, node2, node3])).toEqual([node2, node3, node1]);
});

it('should not change order for other types (sections, actions)', () => {
const node1 = mockSectionCreateElement();
const node2 = mockActionCreateElement();
const node3 = mockSectionCreateElement();
expect(sortNodeCreateElements([node1, node2, node3])).toEqual([node1, node2, node3]);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ export const useViewStacks = defineStore('nodeCreatorViewStacks', () => {

// Sort only if non-root view
if (!stack.items) {
sortNodeCreateElements(stackItems);
stackItems = sortNodeCreateElements(stackItems);
}

updateCurrentViewStack({ baselineItems: stackItems });
Expand Down
8 changes: 4 additions & 4 deletions packages/editor-ui/src/components/Node/NodeCreator/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function subcategorizeItems(items: SimplifiedNodeType[]) {

export function sortNodeCreateElements(nodes: INodeCreateElement[]) {
return nodes.sort((a, b) => {
if (a.type !== 'node' || b.type !== 'node') return -1;
if (a.type !== 'node' || b.type !== 'node') return 0;
const displayNameA = a.properties?.displayName?.toLowerCase() || a.key;
const displayNameB = b.properties?.displayName?.toLowerCase() || b.key;

Expand Down Expand Up @@ -101,16 +101,16 @@ export function groupItemsInSections(
type: 'section',
key: section.key,
title: section.title,
children: itemsBySection[section.key],
children: sortNodeCreateElements(itemsBySection[section.key] ?? []),
}),
)
.concat({
type: 'section',
key: 'other',
title: i18n.baseText('nodeCreator.sectionNames.other'),
children: itemsBySection.other,
children: sortNodeCreateElements(itemsBySection.other ?? []),
})
.filter((section) => section.children);
.filter((section) => section.children.length > 0);

if (result.length <= 1) {
return items;
Expand Down
76 changes: 65 additions & 11 deletions packages/editor-ui/src/components/Node/NodeCreator/viewsData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
TRANSFORM_DATA_SUBCATEGORY,
FILES_SUBCATEGORY,
FLOWS_CONTROL_SUBCATEGORY,
HELPERS_SUBCATEGORY,
TRIGGER_NODE_CREATOR_VIEW,
EMAIL_IMAP_NODE_TYPE,
DEFAULT_SUBCATEGORY,
Expand All @@ -29,6 +28,26 @@ import {
AI_CATEGORY_EMBEDDING,
AI_OTHERS_NODE_CREATOR_VIEW,
AI_UNCATEGORIZED_CATEGORY,
SET_NODE_TYPE,
CODE_NODE_TYPE,
DATETIME_NODE_TYPE,
FILTER_NODE_TYPE,
REMOVE_DUPLICATES_NODE_TYPE,
SPLIT_OUT_NODE_TYPE,
LIMIT_NODE_TYPE,
SUMMARIZE_NODE_TYPE,
AGGREGATE_NODE_TYPE,
MERGE_NODE_TYPE,
HTML_NODE_TYPE,
MARKDOWN_NODE_TYPE,
XML_NODE_TYPE,
CRYPTO_NODE_TYPE,
IF_NODE_TYPE,
SPLIT_IN_BATCHES_NODE_TYPE,
HTTP_REQUEST_NODE_TYPE,
HELPERS_SUBCATEGORY,
RSS_READ_NODE_TYPE,
EMAIL_SEND_NODE_TYPE,
} from '@/constants';
import { useI18n } from '@/composables/useI18n';
import { useNodeTypesStore } from '@/stores/nodeTypes.store';
Expand Down Expand Up @@ -340,6 +359,7 @@ export function RegularView(nodes: SimplifiedNodeType[]) {
properties: {
title: 'App Regular Nodes',
icon: 'globe',
forceIncludeNodes: [RSS_READ_NODE_TYPE, EMAIL_SEND_NODE_TYPE],
},
},
{
Expand All @@ -353,27 +373,45 @@ export function RegularView(nodes: SimplifiedNodeType[]) {
{
key: 'popular',
title: i18n.baseText('nodeCreator.sectionNames.popular'),
items: [],
items: [SET_NODE_TYPE, CODE_NODE_TYPE, DATETIME_NODE_TYPE],
},
{
key: 'addOrRemove',
title: i18n.baseText('nodeCreator.sectionNames.transform.addOrRemove'),
items: [
FILTER_NODE_TYPE,
REMOVE_DUPLICATES_NODE_TYPE,
SPLIT_OUT_NODE_TYPE,
LIMIT_NODE_TYPE,
],
},
{
key: 'combine',
title: i18n.baseText('nodeCreator.sectionNames.transform.combine'),
items: [SUMMARIZE_NODE_TYPE, AGGREGATE_NODE_TYPE, MERGE_NODE_TYPE],
},
{
key: 'convert',
title: i18n.baseText('nodeCreator.sectionNames.transform.convert'),
items: [HTML_NODE_TYPE, MARKDOWN_NODE_TYPE, XML_NODE_TYPE, CRYPTO_NODE_TYPE],
},
],
},
},
{
type: 'subcategory',
key: HELPERS_SUBCATEGORY,
category: CORE_NODES_CATEGORY,
properties: {
title: HELPERS_SUBCATEGORY,
icon: 'toolbox',
},
},
{
type: 'subcategory',
key: FLOWS_CONTROL_SUBCATEGORY,
category: CORE_NODES_CATEGORY,
properties: {
title: FLOWS_CONTROL_SUBCATEGORY,
icon: 'code-branch',
sections: [
{
key: 'popular',
title: i18n.baseText('nodeCreator.sectionNames.popular'),
items: [FILTER_NODE_TYPE, IF_NODE_TYPE, SPLIT_IN_BATCHES_NODE_TYPE, MERGE_NODE_TYPE],
},
],
},
},
{
Expand All @@ -385,6 +423,22 @@ export function RegularView(nodes: SimplifiedNodeType[]) {
icon: 'file-alt',
},
},
{
type: 'subcategory',
key: HELPERS_SUBCATEGORY,
category: CORE_NODES_CATEGORY,
properties: {
title: HELPERS_SUBCATEGORY,
icon: 'toolbox',
sections: [
{
key: 'popular',
title: i18n.baseText('nodeCreator.sectionNames.popular'),
items: [HTTP_REQUEST_NODE_TYPE, WEBHOOK_NODE_TYPE, CODE_NODE_TYPE],
},
],
},
},
],
};

Expand Down
11 changes: 11 additions & 0 deletions packages/editor-ui/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,17 @@ export const XERO_NODE_TYPE = 'n8n-nodes-base.xero';
export const ZENDESK_NODE_TYPE = 'n8n-nodes-base.zendesk';
export const ZENDESK_TRIGGER_NODE_TYPE = 'n8n-nodes-base.zendeskTrigger';
export const DISCORD_NODE_TYPE = 'n8n-nodes-base.discord';
export const DATETIME_NODE_TYPE = 'n8n-nodes-base.dateTime';
export const REMOVE_DUPLICATES_NODE_TYPE = 'n8n-nodes-base.removeDuplicates';
export const SPLIT_OUT_NODE_TYPE = 'n8n-nodes-base.splitOut';
export const LIMIT_NODE_TYPE = 'n8n-nodes-base.limit';
export const SUMMARIZE_NODE_TYPE = 'n8n-nodes-base.summarize';
export const AGGREGATE_NODE_TYPE = 'n8n-nodes-base.aggregate';
export const MERGE_NODE_TYPE = 'n8n-nodes-base.merge';
export const MARKDOWN_NODE_TYPE = 'n8n-nodes-base.markdown';
export const XML_NODE_TYPE = 'n8n-nodes-base.xml';
export const CRYPTO_NODE_TYPE = 'n8n-nodes-base.crypto';
export const RSS_READ_NODE_TYPE = 'n8n-nodes-base.rssFeedRead';

export const CREDENTIAL_ONLY_NODE_PREFIX = 'n8n-creds-base';
export const CREDENTIAL_ONLY_HTTP_NODE_VERSION = 4.1;
Expand Down
5 changes: 4 additions & 1 deletion packages/editor-ui/src/plugins/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@
"nodeCreator.subcategoryNames.dataTransformation": "Data transformation",
"nodeCreator.subcategoryNames.files": "Files",
"nodeCreator.subcategoryNames.flow": "Flow",
"nodeCreator.subcategoryNames.helpers": "Helpers",
"nodeCreator.subcategoryNames.helpers": "Advanced",
"nodeCreator.subcategoryNames.otherTriggerNodes": "Other ways...",
"nodeCreator.subcategoryNames.agents": "Agents",
"nodeCreator.subcategoryNames.chains": "Chains",
Expand All @@ -900,6 +900,9 @@
"nodeCreator.subcategoryNames.miscellaneous": "Miscellaneous",
"nodeCreator.sectionNames.popular": "Popular",
"nodeCreator.sectionNames.other": "Other",
"nodeCreator.sectionNames.transform.combine": "Combine items",
"nodeCreator.sectionNames.transform.addOrRemove": "Add or remove items",
"nodeCreator.sectionNames.transform.convert": "Convert data",
"nodeCreator.triggerHelperPanel.addAnotherTrigger": "Add another trigger",
"nodeCreator.triggerHelperPanel.addAnotherTriggerDescription": "Triggers start your workflow. Workflows can have multiple triggers.",
"nodeCreator.triggerHelperPanel.title": "When should this workflow run?",
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Code/Code.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
},
"alias": ["cpde", "Javascript", "JS", "Python", "Script", "Custom Code", "Function"],
"subcategories": {
"Core Nodes": ["Data Transformation"]
"Core Nodes": ["Helpers", "Data Transformation"]
}
}
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Crypto/Crypto.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
},
"alias": ["Encrypt", "SHA", "Hash"],
"subcategories": {
"Core Nodes": ["Helpers"]
"Core Nodes": ["Data Transformation"]
}
}
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/DateTime/DateTime.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
]
},
"subcategories": {
"Core Nodes": ["Helpers", "Data Transformation"]
"Core Nodes": ["Data Transformation"]
}
}
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/DateTime/V2/DateTimeV2.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class DateTimeV2 implements INodeType {
},
inputs: ['main'],
outputs: ['main'],
description: 'Manipulate date and time values',
properties: [
{
displayName: 'Operation',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
]
},
"subcategories": {
"Core Nodes": ["Helpers", "Other Trigger Nodes"]
"Core Nodes": ["Other Trigger Nodes"]
}
}
3 changes: 0 additions & 3 deletions packages/nodes-base/nodes/EmailSend/EmailSend.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,5 @@
}
]
},
"subcategories": {
"Core Nodes": ["Helpers"]
},
"alias": ["SMTP"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
]
},
"subcategories": {
"Core Nodes": ["Helpers", "Other Trigger Nodes"]
"Core Nodes": ["Other Trigger Nodes"]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
},
"alias": ["n8n"],
"subcategories": {
"Core Nodes": ["Helpers"]
"Core Nodes": ["Helpers", "Flow"]
}
}
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Filter/Filter.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
},
"alias": ["Router", "Filter", "Condition", "Logic", "Boolean", "Branch"],
"subcategories": {
"Core Nodes": ["Flow"]
"Core Nodes": ["Flow", "Data Transformation"]
}
}
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Filter/Filter.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class Filter implements INodeType {
icon: 'fa:filter',
group: ['transform'],
version: 1,
description: 'Filter out incoming items based on given conditions',
description: 'Remove items matching a condition',
defaults: {
name: 'Filter',
color: '#229eff',
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Form/FormTrigger.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
"generic": []
},
"subcategories": {
"Core Nodes": ["Helpers", "Other Trigger Nodes"]
"Core Nodes": ["Other Trigger Nodes"]
}
}
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Html/Html.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
]
},
"subcategories": {
"Core Nodes": ["Helpers", "Data Transformation"]
"Core Nodes": ["Data Transformation"]
},
"alias": ["extract", "template", "table"]
}
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/ItemLists/ItemLists.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export class ItemLists extends VersionedNodeType {
name: 'itemLists',
icon: 'file:itemLists.svg',
group: ['input'],
hidden: true,
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
description: 'Helper for working with lists of items and transforming arrays',
defaultVersion: 3.1,
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Markdown/Markdown.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
]
},
"subcategories": {
"Core Nodes": ["Helpers", "Data Transformation"]
"Core Nodes": ["Data Transformation"]
}
}
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Merge/Merge.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@
},
"alias": ["Join", "Concatenate", "Wait"],
"subcategories": {
"Core Nodes": ["Flow"]
"Core Nodes": ["Flow", "Data Transformation"]
}
}
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Merge/v2/MergeV2.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const versionDescription: INodeTypeDescription = {
group: ['transform'],
version: [2, 2.1, 2.2],
subtitle: '={{$parameter["mode"]}}',
description: 'Merges data of multiple streams once data from both is available',
description: 'Merge data of two inputs once data from both is available',
defaults: {
name: 'Merge',
color: '#00bbcc',
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/N8n/N8n.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
},
"alias": ["Workflow", "Execution"],
"subcategories": {
"Core Nodes": ["Helpers", "Flow", "Other Trigger Nodes"]
"Core Nodes": ["Helpers", "Other Trigger Nodes"]
}
}
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/RenameKeys/RenameKeys.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class RenameKeys implements INodeType {
icon: 'fa:edit',
group: ['transform'],
version: 1,
description: 'Renames keys',
description: 'Update item field names',
defaults: {
name: 'Rename Keys',
color: '#772244',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
]
},
"subcategories": {
"Core Nodes": ["Flow"]
"Core Nodes": ["Helpers"]
}
}
Loading
Loading