diff --git a/src/dashboard/Synapse.Dashboard/Services/WorkflowGraphBuilder.cs b/src/dashboard/Synapse.Dashboard/Services/WorkflowGraphBuilder.cs index 8f332508..db358e98 100644 --- a/src/dashboard/Synapse.Dashboard/Services/WorkflowGraphBuilder.cs +++ b/src/dashboard/Synapse.Dashboard/Services/WorkflowGraphBuilder.cs @@ -143,7 +143,7 @@ protected virtual void BuildTransitions(INodeViewModel node, TaskNodeRenderingCo while (!string.IsNullOrWhiteSpace(nextTask?.Definition?.If)) { this.Logger.LogTrace("[WorkflowGraphBuilder.BuildTransitions][{nodeId}] if clause found, looking up next task.", node.Id); - nextTask = this.GetNextTask(context.TasksList, nextTask.Name); + nextTask = this.GetNextTask(context.TasksList, nextTask.Name, FlowDirective.Continue); transitions.Add(nextTask); this.Logger.LogTrace("[WorkflowGraphBuilder.BuildTransitions][{nodeId}] found transition to '{nextTaskName}'", node.Id, nextTask?.Name); } @@ -214,7 +214,7 @@ protected INodeViewModel BuildTaskNode(TaskNodeRenderingContext context) SwitchTaskDefinition => this.BuildSwitchTaskNode(context.OfType<SwitchTaskDefinition>()), TryTaskDefinition => this.BuildTryTaskNode(context.OfType<TryTaskDefinition>()), WaitTaskDefinition => this.BuildWaitTaskNode(context.OfType<WaitTaskDefinition>()), - _ => throw new NotSupportedException($"The specified task type '{context.TaskDefinition?.GetType()}' is not supported") + _ => throw new NotSupportedException($"The specified task type '{context.TaskDefinition?.GetType()}' is not supported. (reference: '{context.TaskReference}')") } ?? throw new Exception($"Unable to define a last node for task '{context.TaskName}'"); } @@ -259,7 +259,8 @@ protected virtual NodeViewModel BuildCallTaskNode(TaskNodeRenderingContext<CallT break; } default: - callType = context.TaskDefinition.Call.ToLower(); + callType = "custom-function"; + content = context.TaskDefinition.Call.ToLower(); break; } var node = new CallTaskNodeViewModel(context.TaskReference, context.TaskName!, content, callType); @@ -482,8 +483,19 @@ protected virtual NodeViewModel BuildSwitchTaskNode(TaskNodeRenderingContext<Swi foreach (var switchCase in context.TaskDefinition.Switch) { var switchCaseTask = this.GetNextTask(context.TasksList, context.TaskName, switchCase.Value.Then)!; - var switchCaseNode = this.BuildTaskNode(new(context.Workflow, context.Graph, context.TasksList, switchCaseTask.Index, switchCaseTask.Name, switchCaseTask.Definition, context.TaskGroup, context.ParentReference, context.ParentContext, context.EntryNode, context.ExitNode)); - this.BuildEdge(context.Graph, this.GetNodeAnchor(node, NodePortType.Exit), GetNodeAnchor(switchCaseNode, NodePortType.Entry)); + if (switchCaseTask.Index != -1) + { + var switchCaseNode = this.BuildTaskNode(new(context.Workflow, context.Graph, context.TasksList, switchCaseTask.Index, switchCaseTask.Name, switchCaseTask.Definition, context.TaskGroup, context.ParentReference, context.ParentContext, context.EntryNode, context.ExitNode)); + this.BuildEdge(context.Graph, this.GetNodeAnchor(node, NodePortType.Exit), GetNodeAnchor(switchCaseNode, NodePortType.Entry)); + } + else if (switchCaseTask.Name == FlowDirective.Exit) + { + this.BuildEdge(context.Graph, this.GetNodeAnchor(node, NodePortType.Exit), context.ExitNode); + } + else if (switchCaseTask.Name == FlowDirective.End) + { + this.BuildEdge(context.Graph, this.GetNodeAnchor(node, NodePortType.Exit), context.Graph.AllNodes.Skip(1).First().Value); + } } if (!context.TaskDefinition.Switch.Any(switchCase => string.IsNullOrEmpty(switchCase.Value.When))) { diff --git a/src/dashboard/Synapse.Dashboard/wwwroot/index.html b/src/dashboard/Synapse.Dashboard/wwwroot/index.html index 8c8d94c6..7bf82812 100644 --- a/src/dashboard/Synapse.Dashboard/wwwroot/index.html +++ b/src/dashboard/Synapse.Dashboard/wwwroot/index.html @@ -148,6 +148,14 @@ </g> <path d="m28 1.6c-1.4-1.4-3.6-1.4-5 0-1 1.1-1.3 2.7-0.6 4l-7.7 7.7c-1.3-0.7-2.9-0.5-4 0.6-1.4 1.4-1.4 3.6 0 5 1.4 1.3 3.6 1.3 5 0 1-1.1 1.3-2.7 0.6-4.1l7.7-7.6c1.3 0.7 2.9 0.4 4-0.7 1.4-1.3 1.4-3.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