fix(core): Fix issue with not displayed child workflow executions (#3867)

This commit is contained in:
Omar Ajoue
2022-08-12 14:31:11 +02:00
committed by GitHub
parent d4b4e234a6
commit f782bcd52d
6 changed files with 73 additions and 24 deletions

View File

@@ -31,6 +31,7 @@ import {
IWorkflowExecuteAdditionalData,
IWorkflowExecuteHooks,
IWorkflowHooksOptionalParameters,
IWorkflowSettings,
LoggerProxy as Logger,
Workflow,
WorkflowExecuteMode,
@@ -810,6 +811,8 @@ export async function getRunData(
export async function getWorkflowData(
workflowInfo: IExecuteWorkflowInfo,
userId: string,
parentWorkflowId?: string,
parentWorkflowSettings?: IWorkflowSettings,
): Promise<IWorkflowBase> {
if (workflowInfo.id === undefined && workflowInfo.code === undefined) {
throw new Error(
@@ -847,6 +850,14 @@ export async function getWorkflowData(
}
} else {
workflowData = workflowInfo.code;
if (workflowData) {
if (!workflowData.id) {
workflowData.id = parentWorkflowId;
}
if (!workflowData.settings) {
workflowData.settings = parentWorkflowSettings;
}
}
}
return workflowData!;
@@ -864,10 +875,14 @@ export async function getWorkflowData(
export async function executeWorkflow(
workflowInfo: IExecuteWorkflowInfo,
additionalData: IWorkflowExecuteAdditionalData,
inputData?: INodeExecutionData[],
parentExecutionId?: string,
loadedWorkflowData?: IWorkflowBase,
loadedRunData?: IWorkflowExecutionDataProcess,
options?: {
parentWorkflowId?: string;
inputData?: INodeExecutionData[];
parentExecutionId?: string;
loadedWorkflowData?: IWorkflowBase;
loadedRunData?: IWorkflowExecutionDataProcess;
parentWorkflowSettings?: IWorkflowSettings;
},
): Promise<Array<INodeExecutionData[] | null> | IWorkflowExecuteProcess> {
const externalHooks = ExternalHooks();
await externalHooks.init();
@@ -875,30 +890,38 @@ export async function executeWorkflow(
const nodeTypes = NodeTypes();
const workflowData =
loadedWorkflowData ?? (await getWorkflowData(workflowInfo, additionalData.userId));
options?.loadedWorkflowData ??
(await getWorkflowData(
workflowInfo,
additionalData.userId,
options?.parentWorkflowId,
options?.parentWorkflowSettings,
));
const workflowName = workflowData ? workflowData.name : undefined;
const workflow = new Workflow({
id: workflowInfo.id,
id: workflowData.id?.toString(),
name: workflowName,
nodes: workflowData.nodes,
connections: workflowData.connections,
active: workflowData.active,
nodeTypes,
staticData: workflowData.staticData,
settings: workflowData.settings,
});
const runData =
loadedRunData ?? (await getRunData(workflowData, additionalData.userId, inputData));
options?.loadedRunData ??
(await getRunData(workflowData, additionalData.userId, options?.inputData));
let executionId;
if (parentExecutionId !== undefined) {
executionId = parentExecutionId;
if (options?.parentExecutionId !== undefined) {
executionId = options?.parentExecutionId;
} else {
executionId =
parentExecutionId !== undefined
? parentExecutionId
options?.parentExecutionId !== undefined
? options?.parentExecutionId
: await ActiveExecutions.getInstance().add(runData);
}
@@ -946,7 +969,7 @@ export async function executeWorkflow(
runData.executionMode,
runExecutionData,
);
if (parentExecutionId !== undefined) {
if (options?.parentExecutionId !== undefined) {
// Must be changed to become typed
return {
startedAt: new Date(),