Skip to content

Commit c1c0a55

Browse files
committed
Merge branch '1.0.0-alpha1' of https://github.com/serverlessworkflow/synapse into 1.0.0-alpha1
2 parents 7e6895a + 47935b4 commit c1c0a55

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

src/dashboard/Synapse.Dashboard/Components/WorkflowDiagram/ForkTaskNodeViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace Synapse.Dashboard.Components;
1717
/// Represents a composite task node view model
1818
/// </summary>
1919
public class ForkTaskNodeViewModel
20-
: WorkflowNodeViewModel
20+
: WorkflowClusterViewModel
2121
{
2222
/// <summary>
2323
/// Initializes a new <see cref="ListenTaskNodeViewModel"/>

src/dashboard/Synapse.Dashboard/Services/WorkflowGraphBuilder.cs

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -314,11 +314,30 @@ protected virtual NodeViewModel BuildForTaskNode(TaskNodeRenderingContext<ForTas
314314
protected virtual NodeViewModel BuildForkTaskNode(TaskNodeRenderingContext<ForkTaskDefinition> context)
315315
{
316316
ArgumentNullException.ThrowIfNull(context);
317-
var node = new ForkTaskNodeViewModel(context.TaskReference, context.TaskName, this.YamlSerializer.SerializeToText(context.TaskDefinition.Fork));
318-
if (context.TaskGroup == null) context.Graph.AddNode(node);
319-
else context.TaskGroup.AddChild(node);
320-
this.BuildEdge(context.Graph, node, this.GetNextNode(context, node));
321-
return node;
317+
var cluster = new ForkTaskNodeViewModel(context.TaskReference, context.TaskName, this.YamlSerializer.SerializeToText(context.TaskDefinition.Fork));
318+
var entryPort = new PortNodeViewModel(context.TaskReference + _portSuffix);
319+
var exitPort = new PortNodeViewModel(context.TaskReference + "-exit" + _portSuffix);
320+
cluster.AddChild(entryPort);
321+
if (context.TaskGroup == null) context.Graph.AddCluster(cluster);
322+
else context.TaskGroup.AddChild(cluster);
323+
for (int i = 0, c = context.TaskDefinition.Fork.Branches.Count; i<c; i++)
324+
{
325+
var branch = context.TaskDefinition.Fork.Branches.ElementAt(i);
326+
var branchNode = this.BuildTaskNode(new(context.Workflow, context.Graph, i, branch.Key, branch.Value, cluster, context.TaskReference + "/fork/branches", context, context.EndNode, context.PreviousNode));
327+
if (branchNode is WorkflowClusterViewModel branchCluster)
328+
{
329+
this.BuildEdge(context.Graph, entryPort, branchCluster.AllNodes.Values.First());
330+
this.BuildEdge(context.Graph, branchCluster.AllNodes.Values.Last(), exitPort);
331+
}
332+
else
333+
{
334+
this.BuildEdge(context.Graph, entryPort, branchNode);
335+
this.BuildEdge(context.Graph, branchNode, exitPort);
336+
}
337+
}
338+
cluster.AddChild(exitPort);
339+
this.BuildEdge(context.Graph, exitPort, this.GetNextNode(context, cluster));
340+
return cluster;
322341
}
323342

324343
/// <summary>
@@ -426,9 +445,8 @@ protected virtual NodeViewModel BuildSwitchTaskNode(TaskNodeRenderingContext<Swi
426445
else context.TaskGroup.AddChild(node);
427446
foreach (var switchCase in context.TaskDefinition.Switch)
428447
{
429-
var nextTaskNode = this.GetNextNode(context, node, switchCase.Value.Then);
430-
this.BuildEdge(context.Graph, node, nextTaskNode, switchCase.Key);
431-
//node = nextTaskNode;
448+
var switchCaseNode = this.GetNextNode(context, node, switchCase.Value.Then);
449+
this.BuildEdge(context.Graph, node, switchCaseNode, switchCase.Key);
432450
}
433451
if (!context.TaskDefinition.Switch.Any(switchCase => string.IsNullOrEmpty(switchCase.Value.When)))
434452
{

0 commit comments

Comments
 (0)