@@ -1437,6 +1437,33 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
1437
1437
return true
1438
1438
}
1439
1439
1440
+ // Helper to get selected CD nodes
1441
+ const getSelectedCDNodesWithArtifacts = ( selectedWorkflows : WorkflowType [ ] ) : { node : CommonNodeAttr ; wf : WorkflowType } [ ] =>
1442
+ selectedWorkflows
1443
+ . filter ( ( wf ) => wf . isSelected )
1444
+ . map ( ( wf ) => {
1445
+ const _cdNode = wf . nodes . find (
1446
+ ( node ) => node . type === WorkflowNodeType . CD && node . environmentId === + envId ,
1447
+ )
1448
+ if ( ! _cdNode ) return null
1449
+
1450
+ let _selectedNode : CommonNodeAttr | undefined
1451
+ if ( bulkTriggerType === DeploymentNodeType . PRECD ) {
1452
+ _selectedNode = _cdNode . preNode
1453
+ } else if ( bulkTriggerType === DeploymentNodeType . CD ) {
1454
+ _selectedNode = _cdNode
1455
+ } else if ( bulkTriggerType === DeploymentNodeType . POSTCD ) {
1456
+ _selectedNode = _cdNode . postNode
1457
+ }
1458
+
1459
+ const selectedArtifacts = _selectedNode ?. [ materialType ] ?. filter ( ( artifact ) => artifact . isSelected ) || [ ]
1460
+ if ( _selectedNode && selectedArtifacts . length > 0 ) {
1461
+ return { node : _selectedNode , wf }
1462
+ }
1463
+ return null
1464
+ } )
1465
+ . filter ( Boolean )
1466
+
1440
1467
const onClickTriggerBulkCD = (
1441
1468
skipIfHibernated : boolean ,
1442
1469
pipelineIdVsStrategyMap : PipelineIdsVsDeploymentStrategyMap ,
@@ -1452,27 +1479,14 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
1452
1479
const nodeList : CommonNodeAttr [ ] = [ ]
1453
1480
const triggeredAppList : { appId : number ; envId ?: number ; appName : string } [ ] = [ ]
1454
1481
1455
- for ( const _wf of filteredWorkflows ) {
1456
- if ( _wf . isSelected && ( ! appsToRetry || appsToRetry [ _wf . appId ] ) ) {
1457
- const _cdNode = _wf . nodes . find (
1458
- ( node ) => node . type === WorkflowNodeType . CD && node . environmentId === + envId ,
1459
- )
1460
- let _selectedNode : CommonNodeAttr
1461
- if ( bulkTriggerType === DeploymentNodeType . PRECD ) {
1462
- _selectedNode = _cdNode . preNode
1463
- } else if ( bulkTriggerType === DeploymentNodeType . CD ) {
1464
- _selectedNode = _cdNode
1465
- } else if ( bulkTriggerType === DeploymentNodeType . POSTCD ) {
1466
- _selectedNode = _cdNode . postNode
1467
- }
1468
-
1469
- if ( _selectedNode ?. [ materialType ] ?. length ) {
1470
- nodeList . push ( _selectedNode )
1471
- _appIdMap . set ( _selectedNode . id , _wf . appId . toString ( ) )
1472
- triggeredAppList . push ( { appId : _wf . appId , appName : _wf . name , envId : _selectedNode . environmentId } )
1473
- }
1474
- }
1475
- }
1482
+ const eligibleNodes = getSelectedCDNodesWithArtifacts (
1483
+ filteredWorkflows . filter ( ( wf ) => ! appsToRetry || appsToRetry [ wf . appId ] ) ,
1484
+ )
1485
+ eligibleNodes . forEach ( ( { node : eligibleNode , wf } ) => {
1486
+ nodeList . push ( eligibleNode )
1487
+ _appIdMap . set ( eligibleNode . id , wf . appId . toString ( ) )
1488
+ triggeredAppList . push ( { appId : wf . appId , appName : wf . name , envId : eligibleNode . environmentId } )
1489
+ } )
1476
1490
1477
1491
const _CDTriggerPromiseFunctionList = [ ]
1478
1492
nodeList . forEach ( ( node , index ) => {
@@ -2067,12 +2081,15 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
2067
2081
2068
2082
const { uniqueReleaseTags } = bulkCDDetailTypeResponse
2069
2083
2084
+ const feasiblePipelineIds = new Set ( getSelectedCDNodesWithArtifacts ( filteredWorkflows ) . map ( ( { node } ) => + node . id ) )
2085
+
2070
2086
// Have to look for its each prop carefully
2071
2087
// No need to send uniqueReleaseTags will get those in BulkCDTrigger itself
2072
2088
return (
2073
2089
< BulkCDTrigger
2074
2090
stage = { bulkTriggerType }
2075
2091
appList = { _selectedAppWorkflowList }
2092
+ feasiblePipelineIds = { feasiblePipelineIds }
2076
2093
closePopup = { hideBulkCDModal }
2077
2094
updateBulkInputMaterial = { updateBulkCDInputMaterial }
2078
2095
onClickTriggerBulkCD = { onClickTriggerBulkCD }
0 commit comments