feat(editor): Execute sub-workflow UX and copy updates (no-changelog) (#12834)

This commit is contained in:
Milorad FIlipović
2025-01-28 11:33:23 +01:00
committed by GitHub
parent 13652c5ee2
commit de49c23971
18 changed files with 539 additions and 46 deletions

View File

@@ -11,7 +11,7 @@
}
]
},
"alias": ["n8n"],
"alias": ["n8n", "call", "sub", "workflow", "sub-workflow", "subworkflow"],
"subcategories": {
"Core Nodes": ["Helpers", "Flow"]
}

View File

@@ -8,14 +8,12 @@ import type {
} from 'n8n-workflow';
import { getWorkflowInfo } from './GenericFunctions';
import { localResourceMapping } from './methods';
import { generatePairedItemData } from '../../../utils/utilities';
import {
getCurrentWorkflowInputData,
loadWorkflowInputMappings,
} from '../../../utils/workflowInputsResourceMapping/GenericFunctions';
import { getCurrentWorkflowInputData } from '../../../utils/workflowInputsResourceMapping/GenericFunctions';
export class ExecuteWorkflow implements INodeType {
description: INodeTypeDescription = {
displayName: 'Execute Workflow',
displayName: 'Execute Sub-workflow',
name: 'executeWorkflow',
icon: 'fa:sign-in-alt',
iconColor: 'orange-red',
@@ -38,7 +36,7 @@ export class ExecuteWorkflow implements INodeType {
default: 'call_workflow',
options: [
{
name: 'Call Another Workflow',
name: 'Execute a Sub-Workflow',
value: 'call_workflow',
},
],
@@ -210,7 +208,7 @@ export class ExecuteWorkflow implements INodeType {
typeOptions: {
loadOptionsDependsOn: ['workflowId.value'],
resourceMapper: {
localResourceMapperMethod: 'loadWorkflowInputMappings',
localResourceMapperMethod: 'loadSubWorkflowInputs',
valuesLabel: 'Workflow Inputs',
mode: 'map',
fieldWords: {
@@ -275,9 +273,7 @@ export class ExecuteWorkflow implements INodeType {
};
methods = {
localResourceMapping: {
loadWorkflowInputMappings,
},
localResourceMapping,
};
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {

View File

@@ -0,0 +1 @@
export * as localResourceMapping from './localResourceMapping';

View File

@@ -0,0 +1,25 @@
import type { ILocalLoadOptionsFunctions, ResourceMapperFields } from 'n8n-workflow';
import { loadWorkflowInputMappings } from '@utils/workflowInputsResourceMapping/GenericFunctions';
export async function loadSubWorkflowInputs(
this: ILocalLoadOptionsFunctions,
): Promise<ResourceMapperFields> {
const { fields, dataMode, subworkflowInfo } = await loadWorkflowInputMappings.bind(this)();
let emptyFieldsNotice: string | undefined;
if (fields.length === 0) {
const subworkflowLink = subworkflowInfo?.id
? `<a href="/workflow/${subworkflowInfo?.id}" target="_blank">sub-workflows trigger</a>`
: 'sub-workflows trigger';
switch (dataMode) {
case 'passthrough':
emptyFieldsNotice = `This sub-workflow will consume all input data passed to it. You can define specific expected input in the ${subworkflowLink}.`;
break;
default:
emptyFieldsNotice = `The sub-workflow isn't set up to accept any inputs. Change this in the ${subworkflowLink}.`;
break;
}
}
return { fields, emptyFieldsNotice };
}