@@ -314,11 +314,30 @@ protected virtual NodeViewModel BuildForTaskNode(TaskNodeRenderingContext<ForTas
314
314
protected virtual NodeViewModel BuildForkTaskNode ( TaskNodeRenderingContext < ForkTaskDefinition > context )
315
315
{
316
316
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 ;
322
341
}
323
342
324
343
/// <summary>
@@ -426,9 +445,8 @@ protected virtual NodeViewModel BuildSwitchTaskNode(TaskNodeRenderingContext<Swi
426
445
else context . TaskGroup . AddChild ( node ) ;
427
446
foreach ( var switchCase in context . TaskDefinition . Switch )
428
447
{
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 ) ;
432
450
}
433
451
if ( ! context . TaskDefinition . Switch . Any ( switchCase => string . IsNullOrEmpty ( switchCase . Value . When ) ) )
434
452
{
0 commit comments