@@ -186,7 +186,7 @@ export default function CDMaterial({
186
186
const userApprovalConfig = materialsResult ?. userApprovalConfig
187
187
const isApprovalConfigured = userApprovalConfig ?. requiredCount > 0
188
188
const canApproverDeploy = materialsResult ?. canApproverDeploy ?? false
189
- const showConfigDiffView = searchParams . mode === "review-config"
189
+ const showConfigDiffView = searchParams . mode === "review-config" && searchParams . deploy && searchParams . config
190
190
/* ------------ Utils required in useEffect ------------*/
191
191
const getSecurityModuleStatus = async ( ) => {
192
192
try {
@@ -201,7 +201,7 @@ export default function CDMaterial({
201
201
}
202
202
203
203
const getWfrId = ( initSelectedMaterial ?: CDMaterialType ) => {
204
- if ( state . selectedConfigToDeploy . value === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG ) {
204
+ if ( state . selectedConfigToDeploy ? .value === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG ) {
205
205
return state . recentDeploymentConfig . wfrId
206
206
}
207
207
@@ -406,7 +406,10 @@ export default function CDMaterial({
406
406
} , [ material ] )
407
407
408
408
const getInitialSelectedConfigToDeploy = ( ) => {
409
- if ( searchParams . deploy === DeploymentWithConfigType . LAST_SAVED_CONFIG ) {
409
+ if (
410
+ searchParams . deploy === DeploymentWithConfigType . LAST_SAVED_CONFIG ||
411
+ ( materialType === MATERIAL_TYPE . inputMaterialList && ! searchParams . deploy )
412
+ ) {
410
413
return LAST_SAVED_CONFIG_OPTION
411
414
}
412
415
if (
@@ -415,10 +418,7 @@ const getInitialSelectedConfigToDeploy = () => {
415
418
) {
416
419
return SPECIFIC_TRIGGER_CONFIG_OPTION
417
420
}
418
- if (
419
- searchParams . deploy === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG ||
420
- ( materialType === MATERIAL_TYPE . inputMaterialList && ! searchParams . deploy )
421
- ) {
421
+ if ( searchParams . deploy === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG ) {
422
422
return LATEST_TRIGGER_CONFIG_OPTION
423
423
}
424
424
}
@@ -432,6 +432,15 @@ const getInitialSelectedConfigToDeploy = () => {
432
432
} ) )
433
433
} , [ materialType ] )
434
434
435
+ useEffect ( ( ) => {
436
+ if ( searchParams . deploy ) {
437
+ setState ( ( prevState ) => ( {
438
+ ...prevState ,
439
+ selectedConfigToDeploy : getInitialSelectedConfigToDeploy ( ) ,
440
+ } ) )
441
+ }
442
+ } , [ searchParams . deploy ] )
443
+
435
444
useEffect ( ( ) => {
436
445
setState ( ( prevState ) => ( {
437
446
...prevState ,
@@ -454,7 +463,7 @@ const getInitialSelectedConfigToDeploy = () => {
454
463
const checkForConfigDiff = async ( selectedMaterial : CDMaterialType ) => {
455
464
if ( state . isRollbackTrigger && state . selectedMaterial ?. wfrId !== selectedMaterial . wfrId ) {
456
465
const isSpecificTriggerConfig =
457
- state . selectedConfigToDeploy . value === DeploymentWithConfigType . SPECIFIC_TRIGGER_CONFIG
466
+ state . selectedConfigToDeploy ? .value === DeploymentWithConfigType . SPECIFIC_TRIGGER_CONFIG
458
467
459
468
setState ( ( prevState ) => ( {
460
469
...prevState ,
@@ -740,17 +749,17 @@ const getInitialSelectedConfigToDeploy = () => {
740
749
]
741
750
742
751
const isConfigPresent = ( ) =>
743
- ( state . selectedConfigToDeploy . value === DeploymentWithConfigType . SPECIFIC_TRIGGER_CONFIG &&
752
+ ( state . selectedConfigToDeploy ? .value === DeploymentWithConfigType . SPECIFIC_TRIGGER_CONFIG &&
744
753
state . specificDeploymentConfig ?. deploymentTemplate &&
745
754
state . specificDeploymentConfig . pipelineStrategy ) ||
746
- ( state . selectedConfigToDeploy . value === DeploymentWithConfigType . LAST_SAVED_CONFIG &&
755
+ ( state . selectedConfigToDeploy ? .value === DeploymentWithConfigType . LAST_SAVED_CONFIG &&
747
756
state . latestDeploymentConfig ?. deploymentTemplate &&
748
757
state . latestDeploymentConfig . pipelineStrategy )
749
758
750
759
const canReviewConfig = ( ) =>
751
760
( state . recentDeploymentConfig ?. deploymentTemplate &&
752
761
state . recentDeploymentConfig . pipelineStrategy &&
753
- ( state . selectedConfigToDeploy . value === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG ||
762
+ ( state . selectedConfigToDeploy ? .value === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG ||
754
763
isConfigPresent ( ) ) ) ||
755
764
! state . recentDeploymentConfig
756
765
@@ -774,7 +783,7 @@ const getInitialSelectedConfigToDeploy = () => {
774
783
}
775
784
776
785
const canDeployWithConfig = ( ) =>
777
- ( state . selectedConfigToDeploy . value === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG &&
786
+ ( state . selectedConfigToDeploy ? .value === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG &&
778
787
state . recentDeploymentConfig ?. deploymentTemplate &&
779
788
state . recentDeploymentConfig . pipelineStrategy ) ||
780
789
isConfigPresent ( )
@@ -786,13 +795,13 @@ const getInitialSelectedConfigToDeploy = () => {
786
795
! selectedImage ||
787
796
! state . areMaterialsPassingFilters ||
788
797
( state . isRollbackTrigger && ( state . checkingDiff || ! canDeployWithConfig ( ) ) ) ||
789
- ( state . selectedConfigToDeploy . value === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG &&
798
+ ( state . selectedConfigToDeploy ? .value === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG &&
790
799
! state . recentDeploymentConfig )
791
800
)
792
801
}
793
802
794
803
const getBaseTemplateConfiguration = ( selected = null ) => {
795
- const selectedConfig = selected ?. value || state . selectedConfigToDeploy . value
804
+ const selectedConfig = selected ?. value || state . selectedConfigToDeploy ? .value
796
805
return selectedConfig === DeploymentWithConfigType . LAST_SAVED_CONFIG
797
806
? state . latestDeploymentConfig
798
807
: selectedConfig === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG
@@ -810,21 +819,8 @@ const getInitialSelectedConfigToDeploy = () => {
810
819
} )
811
820
}
812
821
813
- const getDeploymentConfigSelectedValue = ( ) => {
814
- if ( searchParams . deploy === DeploymentWithConfigType . LAST_SAVED_CONFIG ) {
815
- return getDeployConfigOptions ( state . isRollbackTrigger , state . recentDeploymentConfig !== null ) [ 0 ] . options [ 0 ]
816
- }
817
- if ( searchParams . deploy === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG ) {
818
- return getDeployConfigOptions ( state . isRollbackTrigger , state . recentDeploymentConfig !== null ) [ 0 ] . options [ 1 ]
819
- }
820
-
821
- if ( searchParams . deploy === DeploymentWithConfigType . SPECIFIC_TRIGGER_CONFIG ) {
822
- return getDeployConfigOptions ( state . isRollbackTrigger , state . recentDeploymentConfig !== null ) [ 0 ] . options [ 2 ]
823
- }
824
- }
825
-
826
822
const handleConfigSelection = ( selected ) => {
827
- if ( selected ?. value !== state . selectedConfigToDeploy . value ) {
823
+ if ( selected ?. value !== state . selectedConfigToDeploy ? .value ) {
828
824
const _diffOptions = checkForDiff ( state . recentDeploymentConfig , getBaseTemplateConfiguration ( selected ) )
829
825
setState ( ( prevState ) => ( {
830
826
...prevState ,
@@ -1901,7 +1897,7 @@ const getInitialSelectedConfigToDeploy = () => {
1901
1897
const renderConfigDiffStatus = ( ) => {
1902
1898
const _canReviewConfig = canReviewConfig ( ) && state . recentDeploymentConfig !== null
1903
1899
const isLastDeployedOption =
1904
- state . selectedConfigToDeploy . value === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG
1900
+ state . selectedConfigToDeploy ? .value === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG
1905
1901
const statusColorClasses = state . checkingDiff
1906
1902
? 'cn-0 bcb-5'
1907
1903
: ! _canReviewConfig
@@ -1994,7 +1990,7 @@ const getInitialSelectedConfigToDeploy = () => {
1994
1990
< >
1995
1991
< h2 className = "fs-12 fw-6 lh-18 m-0" > Selected Config not available!</ h2 >
1996
1992
< p className = "fs-12 fw-4 lh-18 m-0" >
1997
- { state . selectedConfigToDeploy . value === DeploymentWithConfigType . SPECIFIC_TRIGGER_CONFIG &&
1993
+ { state . selectedConfigToDeploy ? .value === DeploymentWithConfigType . SPECIFIC_TRIGGER_CONFIG &&
1998
1994
( ! state . specificDeploymentConfig ||
1999
1995
! state . specificDeploymentConfig . deploymentTemplate ||
2000
1996
! state . specificDeploymentConfig . pipelineStrategy )
@@ -2268,7 +2264,7 @@ const getInitialSelectedConfigToDeploy = () => {
2268
2264
{ renderTriggerBody ( isApprovalConfigured ) }
2269
2265
</ >
2270
2266
) : (
2271
- renderCDModal ( isApprovalConfigured )
2267
+ renderCDModal ( isApprovalConfigured )
2272
2268
)
2273
2269
}
2274
2270
0 commit comments