@@ -57,6 +57,8 @@ import {
57
57
BULK_CD_RESPONSE_STATUS_TEXT ,
58
58
BULK_VIRTUAL_RESPONSE_STATUS ,
59
59
GetBranchChangeStatus ,
60
+ SKIPPED_RESOURCES_STATUS_TEXT ,
61
+ SKIPPED_RESOURCES_MESSAGE ,
60
62
} from '../../Constants'
61
63
import { ReactComponent as DeployIcon } from '../../../../assets/icons/ic-nav-rocket.svg'
62
64
import { ReactComponent as Close } from '../../../../assets/icons/ic-cross.svg'
@@ -1001,8 +1003,13 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
1001
1003
setFilteredWorkflows ( _workflows )
1002
1004
}
1003
1005
1006
+ const isBuildAndBranchTriggerAllowed = ( node : NodeAttr ) : boolean => (
1007
+ ! node . isLinkedCI && ! node . isLinkedCD && node . type !== WorkflowNodeType . WEBHOOK
1008
+ )
1009
+
1004
1010
const changeBranch = ( value ) : void => {
1005
1011
const appIds = [ ]
1012
+ const skippedResources = [ ]
1006
1013
const appNameMap = new Map ( )
1007
1014
1008
1015
filteredWorkflows . forEach ( ( wf ) => {
@@ -1011,21 +1018,39 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
1011
1018
( node ) => node . type === WorkflowNodeType . CI || node . type === WorkflowNodeType . WEBHOOK ,
1012
1019
)
1013
1020
if ( _ciNode ) {
1014
- // Need to add check for webhook if its source type is git
1015
- if ( ! _ciNode . isLinkedCI && ! _ciNode . isLinkedCD ) {
1021
+ if ( isBuildAndBranchTriggerAllowed ( _ciNode ) ) {
1016
1022
appIds . push ( wf . appId )
1017
1023
appNameMap . set ( wf . appId , wf . name )
1018
1024
}
1025
+ else {
1026
+ skippedResources . push ( {
1027
+ appId : wf . appId ,
1028
+ appName : wf . name ,
1029
+ statusText : SKIPPED_RESOURCES_STATUS_TEXT ,
1030
+ status : BulkResponseStatus . SKIP ,
1031
+ envId : + envId ,
1032
+ message : SKIPPED_RESOURCES_MESSAGE ,
1033
+ } )
1034
+ }
1019
1035
}
1020
1036
}
1021
1037
} )
1022
1038
1023
- if ( ! appIds . length ) {
1039
+ if ( ! appIds . length && ! skippedResources . length ) {
1024
1040
toast . error ( 'No valid application present' )
1025
1041
return
1026
1042
}
1027
-
1028
1043
setIsBranchChangeLoading ( true )
1044
+
1045
+ if ( ! appIds . length ) {
1046
+ updateResponseListData ( skippedResources )
1047
+ setIsBranchChangeLoading ( false )
1048
+ setCDLoading ( false )
1049
+ setCILoading ( false )
1050
+ preventBodyScroll ( true )
1051
+ return
1052
+ }
1053
+
1029
1054
triggerBranchChange ( appIds , + envId , value )
1030
1055
. then ( ( response : any ) => {
1031
1056
const _responseList = [ ]
@@ -1039,10 +1064,10 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
1039
1064
message : res . message ,
1040
1065
} )
1041
1066
} )
1042
- updateResponseListData ( _responseList )
1067
+ updateResponseListData ( [ ... _responseList , ... skippedResources ] )
1043
1068
setCDLoading ( false )
1044
1069
setCILoading ( false )
1045
- preventBodyScroll ( false )
1070
+ preventBodyScroll ( true )
1046
1071
} )
1047
1072
. catch ( ( error ) => {
1048
1073
showError ( error )
@@ -1206,6 +1231,7 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
1206
1231
setIsBranchChangeLoading ( false )
1207
1232
setShowBulkSourceChangeModal ( false )
1208
1233
setResponseList ( [ ] )
1234
+ preventBodyScroll ( false )
1209
1235
}
1210
1236
1211
1237
const onShowChangeSourceModal = ( ) => {
@@ -1324,10 +1350,11 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
1324
1350
promiseList : any [ ] ,
1325
1351
triggeredAppList : { appId : number ; envId ?: number ; appName : string } [ ] ,
1326
1352
type : WorkflowNodeType ,
1353
+ skippedResources : ResponseRowType [ ] = [ ] ,
1327
1354
) : void => {
1355
+ const _responseList = skippedResources
1328
1356
if ( promiseList . length ) {
1329
1357
Promise . allSettled ( promiseList ) . then ( ( responses : any ) => {
1330
- const _responseList = [ ]
1331
1358
responses . forEach ( ( response , index ) => {
1332
1359
if ( response . status === 'fulfilled' ) {
1333
1360
const statusType = filterStatusType (
@@ -1399,10 +1426,15 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
1399
1426
} )
1400
1427
} else {
1401
1428
setCDLoading ( false )
1402
- setShowBulkCDModal ( false )
1403
1429
setCILoading ( false )
1404
- setShowBulkCIModal ( false )
1405
- setResponseList ( [ ] )
1430
+ if ( ! skippedResources . length ) {
1431
+ setShowBulkCDModal ( false )
1432
+ setShowBulkCIModal ( false )
1433
+ setResponseList ( [ ] )
1434
+ }
1435
+ else {
1436
+ updateResponseListData ( _responseList )
1437
+ }
1406
1438
}
1407
1439
}
1408
1440
@@ -1426,18 +1458,29 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
1426
1458
ReactGA . event ( ENV_TRIGGER_VIEW_GA_EVENTS . BulkCITriggered )
1427
1459
setCILoading ( true )
1428
1460
let node
1461
+ const skippedResources = [ ]
1429
1462
const nodeList : NodeAttr [ ] = [ ] ,
1430
1463
triggeredAppList : { appId : number ; appName : string } [ ] = [ ]
1431
1464
for ( const _wf of filteredWorkflows ) {
1432
1465
if ( _wf . isSelected && ( ! appsToRetry || appsToRetry [ _wf . appId ] ) ) {
1433
1466
node = _wf . nodes . find ( ( node ) => {
1434
- return node . type === WorkflowNodeType . CI
1467
+ return node . type === WorkflowNodeType . CI || node . type === WorkflowNodeType . WEBHOOK
1435
1468
} )
1436
- // Maybe we dont need to push webhook as well
1437
- if ( node && ! node . isLinkedCI && ! node . isLinkedCD ) {
1469
+
1470
+ if ( node && isBuildAndBranchTriggerAllowed ( node ) ) {
1438
1471
triggeredAppList . push ( { appId : _wf . appId , appName : _wf . name } )
1439
1472
nodeList . push ( node )
1440
1473
}
1474
+ else if ( node && ! isBuildAndBranchTriggerAllowed ( node ) ) {
1475
+ // skipped can never be in appsToRetry
1476
+ skippedResources . push ( {
1477
+ appId : _wf . appId ,
1478
+ appName : _wf . name ,
1479
+ statusText : SKIPPED_RESOURCES_STATUS_TEXT ,
1480
+ status : BulkResponseStatus . SKIP ,
1481
+ message : SKIPPED_RESOURCES_MESSAGE ,
1482
+ } )
1483
+ }
1441
1484
}
1442
1485
}
1443
1486
const _CITriggerPromiseList = [ ]
@@ -1479,13 +1522,15 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
1479
1522
}
1480
1523
_CITriggerPromiseList . push ( triggerCINode ( payload ) )
1481
1524
} )
1482
- if ( ! _CITriggerPromiseList . length ) {
1525
+
1526
+ if ( ! _CITriggerPromiseList . length && ! skippedResources . length ) {
1483
1527
toast . error ( 'No valid CI pipeline found' )
1484
1528
setCDLoading ( false )
1485
1529
setCILoading ( false )
1486
1530
return
1487
1531
}
1488
- handleBulkTrigger ( _CITriggerPromiseList , triggeredAppList , WorkflowNodeType . CI )
1532
+
1533
+ handleBulkTrigger ( _CITriggerPromiseList , triggeredAppList , WorkflowNodeType . CI , skippedResources )
1489
1534
}
1490
1535
1491
1536
// Would only set data no need to get data related to materials from it, we will get that in bulk trigger
0 commit comments