@@ -8,16 +8,14 @@ import {
8
8
CiPipelineResult ,
9
9
Workflow ,
10
10
WorkflowResult ,
11
- PipelineType ,
12
- WorkflowNodeType ,
13
11
AddDimensionsToDownstreamDeploymentsParams ,
14
12
} from './types'
15
13
import { WorkflowTrigger , WorkflowCreate , Offset , WorkflowDimensions , WorkflowDimensionType } from './config'
16
14
import { TriggerType , DEFAULT_STATUS , GIT_BRANCH_NOT_CONFIGURED } from '../../../../config'
17
15
import { isEmpty } from '../../../common'
18
16
import { WebhookDetailsType } from '../../../ciPipeline/Webhook/types'
19
17
import { getExternalCIList } from '../../../ciPipeline/Webhook/webhook.service'
20
- import { TriggerTypeMap } from '@devtron-labs/devtron-fe-common-lib'
18
+ import { CommonNodeAttr , TriggerTypeMap , WorkflowNodeType , PipelineType , DownstreamNodesEnvironmentsType } from '@devtron-labs/devtron-fe-common-lib'
21
19
import { CIPipelineBuildType } from '../../../ciPipeline/types'
22
20
import { BlackListedCI } from '../../../workflowEditor/types'
23
21
@@ -295,6 +293,7 @@ function addDimensions(workflows: WorkflowType[], workflowOffset: Offset, dimens
295
293
dimensions . type === WorkflowDimensionType . CREATE &&
296
294
node . parentPipelineType === PipelineType . WEBHOOK
297
295
) {
296
+ // Maybe need to manipulate it
298
297
node . x = node . x - 40
299
298
}
300
299
node . preNode && finalWorkflow . push ( node . preNode )
@@ -325,6 +324,7 @@ function addDimensions(workflows: WorkflowType[], workflowOffset: Offset, dimens
325
324
workflow . nodes = finalWorkflow
326
325
} )
327
326
327
+ // FIXME: This might be the key to solve scrolling workflows in case one scrolls, all other scrolls
328
328
workflows . forEach ( ( workflow ) => ( workflow . width = maxWorkflowWidth ) )
329
329
}
330
330
@@ -349,10 +349,17 @@ function addDownstreams(workflows: WorkflowType[]) {
349
349
350
350
if ( ! ! parentNode ) {
351
351
const _downstream = type + '-' + node . id
352
+ const environmentDetails : DownstreamNodesEnvironmentsType = {
353
+ environmentId : node . environmentId ,
354
+ environmentName : node . environmentName ,
355
+ }
356
+
352
357
if ( parentNode . postNode ) {
353
358
parentNode . postNode . downstreams . push ( _downstream )
359
+ parentNode . postNode . downstreamEnvironments ?. push ( environmentDetails )
354
360
} else {
355
361
parentNode . downstreams . push ( _downstream )
362
+ parentNode . downstreamEnvironments ?. push ( environmentDetails )
356
363
}
357
364
parentNode . downstreamNodes . push ( node )
358
365
}
@@ -455,6 +462,7 @@ function ciPipelineToNode(ciPipeline: CiPipeline, dimensions: WorkflowDimensions
455
462
url : '' ,
456
463
id : `${ WorkflowNodeType . GIT } -${ materialName } -${ index } ` ,
457
464
downstreams : [ `${ WorkflowNodeType . CI } -${ ciPipeline . id } ` ] ,
465
+ downstreamEnvironments : [ ] ,
458
466
type : WorkflowNodeType . GIT ,
459
467
icon : 'git' ,
460
468
branch : getStaticCurrentBranchName ( ciMaterial ) ,
@@ -488,6 +496,7 @@ function ciPipelineToNode(ciPipeline: CiPipeline, dimensions: WorkflowDimensions
488
496
type : WorkflowNodeType . CI ,
489
497
inputMaterialList : [ ] ,
490
498
downstreams : [ ] ,
499
+ downstreamEnvironments : [ ] ,
491
500
isExternalCI : ciPipeline . isExternal ,
492
501
// Can't rely on pipelineType for legacy pipelines, so using parentCiPipeline as well
493
502
isLinkedCI : ciPipeline . pipelineType !== PipelineType . LINKED_CD && ! ! ciPipeline . parentCiPipeline ,
@@ -519,6 +528,7 @@ function webhookToNode(webhookDetails: WebhookDetailsType, dimensions: WorkflowD
519
528
type : WorkflowNodeType . WEBHOOK ,
520
529
inputMaterialList : [ ] ,
521
530
downstreams : [ ] ,
531
+ downstreamEnvironments : [ ] ,
522
532
isExternalCI : true ,
523
533
isLinkedCI : false ,
524
534
linkedCount : 0 ,
@@ -547,6 +557,7 @@ function cdPipelineToNode(cdPipeline: CdPipeline, dimensions: WorkflowDimensions
547
557
activeIn : false ,
548
558
activeOut : false ,
549
559
downstreams : [ `${ WorkflowNodeType . CD } -${ cdPipeline . id } ` ] ,
560
+ downstreamEnvironments : [ ] ,
550
561
type : WorkflowNodeType . PRE_CD ,
551
562
status : cdPipeline . preDeployStage ?. status || cdPipeline . preStage ?. status || DEFAULT_STATUS ,
552
563
triggerType : TriggerTypeMap [ trigger ] ,
@@ -583,6 +594,7 @@ function cdPipelineToNode(cdPipeline: CdPipeline, dimensions: WorkflowDimensions
583
594
activeIn : false ,
584
595
activeOut : false ,
585
596
downstreams : cdDownstreams ,
597
+ downstreamEnvironments : [ ] ,
586
598
type : WorkflowNodeType . CD ,
587
599
status : DEFAULT_STATUS ,
588
600
triggerType : TriggerTypeMap [ trigger ] ,
@@ -606,7 +618,8 @@ function cdPipelineToNode(cdPipeline: CdPipeline, dimensions: WorkflowDimensions
606
618
isVirtualEnvironment : cdPipeline . isVirtualEnvironment ,
607
619
deploymentAppType : cdPipeline . deploymentAppType ,
608
620
helmPackageName : cdPipeline ?. helmPackageName || '' ,
609
- isLast : isLast
621
+ isLast : isLast ,
622
+ deploymentAppCreated : cdPipeline ?. deploymentAppCreated ,
610
623
} as NodeAttr
611
624
stageIndex ++
612
625
@@ -625,6 +638,7 @@ function cdPipelineToNode(cdPipeline: CdPipeline, dimensions: WorkflowDimensions
625
638
activeIn : false ,
626
639
activeOut : false ,
627
640
downstreams : [ ] ,
641
+ downstreamEnvironments : [ ] ,
628
642
type : WorkflowNodeType . POST_CD ,
629
643
status : cdPipeline . postDeployStage ?. status || cdPipeline . postStage ?. status || DEFAULT_STATUS ,
630
644
triggerType : TriggerTypeMap [ trigger ] ,
@@ -677,3 +691,34 @@ function getCINodeHeight(dimensionType: WorkflowDimensionType, pipeline: CiPipel
677
691
}
678
692
return WorkflowTrigger . cINodeSizes . nodeHeight
679
693
}
694
+
695
+ export function getAllChildDownstreams ( node : CommonNodeAttr , workflow : any ) : { downstreamNodes : CommonNodeAttr [ ] } {
696
+ let downstreamNodes = [ ]
697
+ // Not using downstreamNodes since they get deleted in service itself
698
+ if ( node ?. downstreams ?. length ) {
699
+ node . downstreams . forEach ( ( downstreamData ) => {
700
+ // separating id and type from downstreamData by splitting on -
701
+ const [ type , id ] = downstreamData . split ( '-' )
702
+ const _node = workflow . nodes ?. find ( ( wfNode ) => String ( wfNode . id ) === id && wfNode . type === type )
703
+ if ( _node ) {
704
+ const { downstreamNodes : _downstreamNodes } = getAllChildDownstreams ( _node , workflow )
705
+ downstreamNodes = [ ...downstreamNodes , ..._downstreamNodes ]
706
+ }
707
+ } )
708
+ }
709
+ return { downstreamNodes : [ ...downstreamNodes , node ] }
710
+ }
711
+
712
+ export function getMaxYFromFirstLevelDownstream ( node : CommonNodeAttr , workflow : any ) : number {
713
+ let maxY = 0
714
+ if ( node ?. downstreams ?. length ) {
715
+ node . downstreams . forEach ( ( downstreamData ) => {
716
+ const [ type , id ] = downstreamData . split ( '-' )
717
+ const _node = workflow . nodes ?. find ( ( wfNode ) => String ( wfNode . id ) === id && wfNode . type === type )
718
+ if ( _node ) {
719
+ maxY = Math . max ( maxY , _node . y )
720
+ }
721
+ } )
722
+ }
723
+ return maxY
724
+ }
0 commit comments