Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Commit

Permalink
Fix timeline does not show when using the DO_WHILE loop.
Browse files Browse the repository at this point in the history
  • Loading branch information
ppolxda committed Jul 5, 2023
1 parent 9c8f184 commit cb39e12
Showing 1 changed file with 76 additions and 1 deletion.
77 changes: 76 additions & 1 deletion ui/src/components/diagram/WorkflowDAG.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,81 @@ export default class WorkflowDAG {
}
}

getRefTaskChilds(task) {
switch (task.type) {
case "FORK_JOIN": {
const outerForkTasks = task.forkTasks || [];
return _.flatten(
outerForkTasks.map((innerForkTasks) =>
innerForkTasks.map((tasks) => tasks)
)
);
}

case "FORK_JOIN_DYNAMIC": {
const dfTaskResult = this.getLastTaskResult(task.taskReferenceName);
const forkedTasks = _.get(dfTaskResult, "inputData.forkedTaskDefs");
const forkedTasksCount = _.get(forkedTasks, "length");

if (!forkedTasksCount) {
const placeholderRef =
task.taskReferenceName + "_DF_EMPTY_PLACEHOLDER";
const placeholderTask = {
name: placeholderRef, // will be overwritten if results available
taskReferenceName: placeholderRef, // will be overwritten if results available
type: "DF_EMPTY_PLACEHOLDER",
};
return [placeholderTask];
} else {
return dfTaskResult.inputData.forkedTaskDefs;
}
}

case "DECISION": // DECISION is deprecated and will be removed in a future release
case "SWITCH": {
const retval = [];
if (!_.isEmpty(task.defaultCase)) {
retval.push(...this.getRefTask(task.defaultCase));
}
retval.push(
..._.flatten(
Object.entries(task.decisionCases).map(([caseValue, tasks]) => {
return tasks;
})
)
);
return retval;
}

case "DO_WHILE": {
return task.loopOver;
}

/*
case "TERMINATE":
case "JOIN":
case "TERMINAL":
case "EVENT":
case "SUB_WORKFLOW":
case "EXCLUSIVE_JOIN":
*/
default: {
return [];
}
}
}

getRefTask(task) {
const taskRefs = this.getRefTaskChilds(task)
.map((t) => {
return this.getRefTask(t);
})
.reduce((r, tasks) => {
return r.concat(tasks);
}, []);
return [task].concat(taskRefs);
}

processDoWhileTask(doWhileTask, antecedents) {
console.assert(Array.isArray(antecedents));

Expand All @@ -272,7 +347,7 @@ export default class WorkflowDAG {
aliasForRef: doWhileTask.taskReferenceName,
};

const loopOverRefPrefixes = doWhileTask.loopOver.map(
const loopOverRefPrefixes = this.getRefTask(doWhileTask).map(
(t) => t.taskReferenceName
);
if (hasDoWhileExecuted) {
Expand Down

0 comments on commit cb39e12

Please sign in to comment.