@@ -135,8 +135,7 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
135
135
const [ selectAllValue , setSelectAllValue ] = useState < CHECKBOX_VALUE > ( CHECKBOX_VALUE . CHECKED )
136
136
const [ isConfigPresent , setConfigPresent ] = useState < boolean > ( false )
137
137
const [ isDefaultConfigPresent , setDefaultConfig ] = useState < boolean > ( false )
138
- // TODO: Add types
139
- const [ skippedResources , setSkippedResources ] = useState ( [ ] )
138
+ const [ skippedResources , setSkippedResources ] = useState < ResponseRowType [ ] > ( [ ] )
140
139
141
140
// ref to make sure that on initial mount after we fetch workflows we handle modal based on url
142
141
const handledLocation = useRef ( false )
@@ -1005,6 +1004,10 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
1005
1004
setFilteredWorkflows ( _workflows )
1006
1005
}
1007
1006
1007
+ const isBuildAndBranchTriggerAllowed = ( node : NodeAttr ) : boolean => (
1008
+ ! node . isLinkedCI && ! node . isLinkedCD && node . type !== WorkflowNodeType . WEBHOOK
1009
+ )
1010
+
1008
1011
const changeBranch = ( value ) : void => {
1009
1012
const appIds = [ ]
1010
1013
const _skippedResources = [ ]
@@ -1016,8 +1019,7 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
1016
1019
( node ) => node . type === WorkflowNodeType . CI || node . type === WorkflowNodeType . WEBHOOK ,
1017
1020
)
1018
1021
if ( _ciNode ) {
1019
- // Need to add check for webhook if its source type is git
1020
- if ( ! _ciNode . isLinkedCI && ! _ciNode . isLinkedCD && _ciNode . type !== WorkflowNodeType . WEBHOOK ) {
1022
+ if ( isBuildAndBranchTriggerAllowed ( _ciNode ) ) {
1021
1023
appIds . push ( wf . appId )
1022
1024
appNameMap . set ( wf . appId , wf . name )
1023
1025
}
@@ -1026,7 +1028,7 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
1026
1028
appId : wf . appId ,
1027
1029
appName : wf . name ,
1028
1030
statusText : SKIPPED_RESOURCES_STATUS_TEXT ,
1029
- status : GetBranchChangeStatus ( BulkResponseStatus . SKIP ) ,
1031
+ status : BulkResponseStatus . SKIP ,
1030
1032
envId : + envId ,
1031
1033
message : SKIPPED_RESOURCES_MESSAGE ,
1032
1034
} )
@@ -1039,7 +1041,8 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
1039
1041
toast . error ( 'No valid application present' )
1040
1042
return
1041
1043
}
1042
-
1044
+
1045
+ setSkippedResources ( _skippedResources )
1043
1046
setIsBranchChangeLoading ( true )
1044
1047
triggerBranchChange ( appIds , + envId , value )
1045
1048
. then ( ( response : any ) => {
@@ -1055,13 +1058,13 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
1055
1058
} )
1056
1059
} )
1057
1060
updateResponseListData ( _responseList )
1058
- setSkippedResources ( _skippedResources )
1059
1061
setCDLoading ( false )
1060
1062
setCILoading ( false )
1061
1063
preventBodyScroll ( false )
1062
1064
} )
1063
1065
. catch ( ( error ) => {
1064
1066
showError ( error )
1067
+ setSkippedResources ( [ ] )
1065
1068
} )
1066
1069
. finally ( ( ) => {
1067
1070
setIsBranchChangeLoading ( false )
@@ -1422,7 +1425,6 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
1422
1425
setCILoading ( false )
1423
1426
setShowBulkCIModal ( false )
1424
1427
setResponseList ( [ ] )
1425
- setSkippedResources ( [ ] )
1426
1428
}
1427
1429
}
1428
1430
@@ -1446,18 +1448,28 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
1446
1448
ReactGA . event ( ENV_TRIGGER_VIEW_GA_EVENTS . BulkCITriggered )
1447
1449
setCILoading ( true )
1448
1450
let node
1451
+ const _skippedResources = [ ]
1449
1452
const nodeList : NodeAttr [ ] = [ ] ,
1450
1453
triggeredAppList : { appId : number ; appName : string } [ ] = [ ]
1451
1454
for ( const _wf of filteredWorkflows ) {
1452
1455
if ( _wf . isSelected && ( ! appsToRetry || appsToRetry [ _wf . appId ] ) ) {
1453
1456
node = _wf . nodes . find ( ( node ) => {
1454
- return node . type === WorkflowNodeType . CI
1457
+ return node . type === WorkflowNodeType . CI || node . type === WorkflowNodeType . WEBHOOK
1455
1458
} )
1456
- // Maybe we dont need to push webhook as well
1457
- if ( node && ! node . isLinkedCI && ! node . isLinkedCD ) {
1459
+
1460
+ if ( node && isBuildAndBranchTriggerAllowed ( node ) ) {
1458
1461
triggeredAppList . push ( { appId : _wf . appId , appName : _wf . name } )
1459
1462
nodeList . push ( node )
1460
1463
}
1464
+ else if ( node && ! isBuildAndBranchTriggerAllowed ( node ) ) {
1465
+ _skippedResources . push ( {
1466
+ appId : _wf . appId ,
1467
+ appName : _wf . name ,
1468
+ statusText : SKIPPED_RESOURCES_STATUS_TEXT ,
1469
+ status : BulkResponseStatus . SKIP ,
1470
+ message : SKIPPED_RESOURCES_MESSAGE ,
1471
+ } )
1472
+ }
1461
1473
}
1462
1474
}
1463
1475
const _CITriggerPromiseList = [ ]
@@ -1499,12 +1511,17 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
1499
1511
}
1500
1512
_CITriggerPromiseList . push ( triggerCINode ( payload ) )
1501
1513
} )
1502
- if ( ! _CITriggerPromiseList . length ) {
1514
+
1515
+ if ( ! _CITriggerPromiseList . length && ! appsToRetry && ! _skippedResources . length ) {
1503
1516
toast . error ( 'No valid CI pipeline found' )
1504
1517
setCDLoading ( false )
1505
1518
setCILoading ( false )
1506
1519
return
1507
1520
}
1521
+ if ( ! appsToRetry ) {
1522
+ setSkippedResources ( _skippedResources )
1523
+ }
1524
+
1508
1525
handleBulkTrigger ( _CITriggerPromiseList , triggeredAppList , WorkflowNodeType . CI )
1509
1526
}
1510
1527
@@ -1836,7 +1853,7 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
1836
1853
webhookPayloads = { webhookPayloads }
1837
1854
isWebhookPayloadLoading = { isWebhookPayloadLoading }
1838
1855
isShowRegexModal = { isShowRegexModal }
1839
- responseList = { responseList }
1856
+ responseList = { [ ... responseList , ... skippedResources ] }
1840
1857
isLoading = { isCILoading }
1841
1858
setLoading = { setCILoading }
1842
1859
/>
@@ -1851,8 +1868,7 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
1851
1868
return (
1852
1869
< BulkSourceChange
1853
1870
closePopup = { hideChangeSourceModal }
1854
- responseList = { responseList }
1855
- skippedResources = { skippedResources }
1871
+ responseList = { [ ...responseList , ...skippedResources ] }
1856
1872
changeBranch = { changeBranch }
1857
1873
loading = { isBranchChangeLoading }
1858
1874
selectedAppCount = { selectedAppList . length }
0 commit comments