@@ -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 && state . recentDeploymentConfig ) {
205
205
return state . recentDeploymentConfig . wfrId
206
206
}
207
207
@@ -245,11 +245,7 @@ export default function CDMaterial({
245
245
checkingDiff : false ,
246
246
} ) )
247
247
} ,
248
- ) . catch ( err => {
249
- showError ( err )
250
- setState ( ( prevState ) => ( { ...prevState , checkingDiff : false } ) )
251
-
252
- } ) . finally ( ( ) => {
248
+ ) . finally ( ( ) => {
253
249
setState ( ( prevState ) => ( { ...prevState , checkingDiff : false } ) )
254
250
} )
255
251
}
@@ -407,20 +403,15 @@ export default function CDMaterial({
407
403
408
404
const getInitialSelectedConfigToDeploy = ( ) => {
409
405
if (
410
- searchParams . deploy === DeploymentWithConfigType . LAST_SAVED_CONFIG ||
411
- ( materialType === MATERIAL_TYPE . inputMaterialList && ! searchParams . deploy )
412
- ) {
413
- return LAST_SAVED_CONFIG_OPTION
414
- }
415
- if (
416
- searchParams . deploy === DeploymentWithConfigType . SPECIFIC_TRIGGER_CONFIG ||
417
- ( materialType === MATERIAL_TYPE . rollbackMaterialList && ! searchParams . deploy )
406
+ ( materialType === MATERIAL_TYPE . rollbackMaterialList && ! searchParams . deploy ) ||
407
+ searchParams . deploy === DeploymentWithConfigType . SPECIFIC_TRIGGER_CONFIG
418
408
) {
419
409
return SPECIFIC_TRIGGER_CONFIG_OPTION
420
410
}
421
411
if ( searchParams . deploy === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG ) {
422
412
return LATEST_TRIGGER_CONFIG_OPTION
423
413
}
414
+ return LAST_SAVED_CONFIG_OPTION
424
415
}
425
416
useEffect ( ( ) => {
426
417
setState ( ( prevState ) => ( {
@@ -463,7 +454,7 @@ const getInitialSelectedConfigToDeploy = () => {
463
454
const checkForConfigDiff = async ( selectedMaterial : CDMaterialType ) => {
464
455
if ( state . isRollbackTrigger && state . selectedMaterial ?. wfrId !== selectedMaterial . wfrId ) {
465
456
const isSpecificTriggerConfig =
466
- state . selectedConfigToDeploy ? .value === DeploymentWithConfigType . SPECIFIC_TRIGGER_CONFIG
457
+ state . selectedConfigToDeploy . value === DeploymentWithConfigType . SPECIFIC_TRIGGER_CONFIG
467
458
468
459
setState ( ( prevState ) => ( {
469
460
...prevState ,
@@ -749,31 +740,39 @@ const getInitialSelectedConfigToDeploy = () => {
749
740
]
750
741
751
742
const isConfigPresent = ( ) =>
752
- ( state . selectedConfigToDeploy ? .value === DeploymentWithConfigType . SPECIFIC_TRIGGER_CONFIG &&
743
+ ( state . selectedConfigToDeploy . value === DeploymentWithConfigType . SPECIFIC_TRIGGER_CONFIG &&
753
744
state . specificDeploymentConfig ?. deploymentTemplate &&
754
745
state . specificDeploymentConfig . pipelineStrategy ) ||
755
- ( state . selectedConfigToDeploy ? .value === DeploymentWithConfigType . LAST_SAVED_CONFIG &&
746
+ ( state . selectedConfigToDeploy . value === DeploymentWithConfigType . LAST_SAVED_CONFIG &&
756
747
state . latestDeploymentConfig ?. deploymentTemplate &&
757
748
state . latestDeploymentConfig . pipelineStrategy )
758
749
750
+ const getConfigToDeployValue = ( ) => {
751
+ if ( searchParams . deploy ) {
752
+ return searchParams . deploy
753
+ } else {
754
+ if ( materialType === MATERIAL_TYPE . rollbackMaterialList ) {
755
+ return DeploymentWithConfigType . SPECIFIC_TRIGGER_CONFIG
756
+ } else {
757
+ return DeploymentWithConfigType . LAST_SAVED_CONFIG
758
+ }
759
+ }
760
+ }
761
+
759
762
const canReviewConfig = ( ) =>
760
763
( state . recentDeploymentConfig ?. deploymentTemplate &&
761
764
state . recentDeploymentConfig . pipelineStrategy &&
762
- ( state . selectedConfigToDeploy ? .value === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG ||
765
+ ( state . selectedConfigToDeploy . value === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG ||
763
766
isConfigPresent ( ) ) ) ||
764
767
! state . recentDeploymentConfig
765
768
766
769
const onClickSetInitialParams = ( modeParamValue : string ) => {
767
- if ( canReviewConfig ( ) ) {
770
+ if ( canReviewConfig ) {
768
771
const newParams = {
769
772
...searchParams ,
770
773
mode : modeParamValue ,
771
774
config : DEPLOYMENT_CONFIGURATION_NAV_MAP . DEPLOYMENT_TEMPLATE . key ,
772
- deploy : searchParams . deploy
773
- ? searchParams . deploy
774
- : materialType === MATERIAL_TYPE . rollbackMaterialList
775
- ? DeploymentWithConfigType . SPECIFIC_TRIGGER_CONFIG
776
- : DeploymentWithConfigType . LAST_SAVED_CONFIG ,
775
+ deploy : getConfigToDeployValue ( ) ,
777
776
}
778
777
779
778
history . push ( {
@@ -783,7 +782,7 @@ const getInitialSelectedConfigToDeploy = () => {
783
782
}
784
783
785
784
const canDeployWithConfig = ( ) =>
786
- ( state . selectedConfigToDeploy ? .value === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG &&
785
+ ( state . selectedConfigToDeploy . value === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG &&
787
786
state . recentDeploymentConfig ?. deploymentTemplate &&
788
787
state . recentDeploymentConfig . pipelineStrategy ) ||
789
788
isConfigPresent ( )
@@ -795,13 +794,13 @@ const getInitialSelectedConfigToDeploy = () => {
795
794
! selectedImage ||
796
795
! state . areMaterialsPassingFilters ||
797
796
( state . isRollbackTrigger && ( state . checkingDiff || ! canDeployWithConfig ( ) ) ) ||
798
- ( state . selectedConfigToDeploy ? .value === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG &&
797
+ ( state . selectedConfigToDeploy . value === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG &&
799
798
! state . recentDeploymentConfig )
800
799
)
801
800
}
802
801
803
802
const getBaseTemplateConfiguration = ( selected = null ) => {
804
- const selectedConfig = selected ?. value || state . selectedConfigToDeploy ? .value
803
+ const selectedConfig = selected ?. value || state . selectedConfigToDeploy . value
805
804
return selectedConfig === DeploymentWithConfigType . LAST_SAVED_CONFIG
806
805
? state . latestDeploymentConfig
807
806
: selectedConfig === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG
@@ -820,7 +819,7 @@ const getInitialSelectedConfigToDeploy = () => {
820
819
}
821
820
822
821
const handleConfigSelection = ( selected ) => {
823
- if ( selected ?. value !== state . selectedConfigToDeploy ? .value ) {
822
+ if ( selected ?. value !== state . selectedConfigToDeploy . value ) {
824
823
const _diffOptions = checkForDiff ( state . recentDeploymentConfig , getBaseTemplateConfiguration ( selected ) )
825
824
setState ( ( prevState ) => ( {
826
825
...prevState ,
@@ -952,7 +951,7 @@ const getInitialSelectedConfigToDeploy = () => {
952
951
appId ,
953
952
Number ( getCDArtifactId ( ) ) ,
954
953
e ,
955
- state . selectedConfigToDeploy ? .value ,
954
+ state . selectedConfigToDeploy . value ,
956
955
getWfrId ( ) ,
957
956
)
958
957
return
@@ -1897,7 +1896,7 @@ const getInitialSelectedConfigToDeploy = () => {
1897
1896
const renderConfigDiffStatus = ( ) => {
1898
1897
const _canReviewConfig = canReviewConfig ( ) && state . recentDeploymentConfig !== null
1899
1898
const isLastDeployedOption =
1900
- state . selectedConfigToDeploy ? .value === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG
1899
+ state . selectedConfigToDeploy . value === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG
1901
1900
const statusColorClasses = state . checkingDiff
1902
1901
? 'cn-0 bcb-5'
1903
1902
: ! _canReviewConfig
@@ -1990,7 +1989,7 @@ const getInitialSelectedConfigToDeploy = () => {
1990
1989
< >
1991
1990
< h2 className = "fs-12 fw-6 lh-18 m-0" > Selected Config not available!</ h2 >
1992
1991
< p className = "fs-12 fw-4 lh-18 m-0" >
1993
- { state . selectedConfigToDeploy ? .value === DeploymentWithConfigType . SPECIFIC_TRIGGER_CONFIG &&
1992
+ { state . selectedConfigToDeploy . value === DeploymentWithConfigType . SPECIFIC_TRIGGER_CONFIG &&
1994
1993
( ! state . specificDeploymentConfig ||
1995
1994
! state . specificDeploymentConfig . deploymentTemplate ||
1996
1995
! state . specificDeploymentConfig . pipelineStrategy )
@@ -2112,29 +2111,36 @@ const getInitialSelectedConfigToDeploy = () => {
2112
2111
)
2113
2112
}
2114
2113
2114
+ const renderTriggerViewConfifDiff = ( ) => {
2115
+ if ( state . checkingDiff ) {
2116
+ return < Progressing pageLoader />
2117
+ }
2118
+
2119
+ return (
2120
+ < TriggerViewConfigDiff
2121
+ currentConfiguration = { state . recentDeploymentConfig }
2122
+ baseTemplateConfiguration = { getBaseTemplateConfiguration ( ) }
2123
+ selectedConfigToDeploy = { state . selectedConfigToDeploy }
2124
+ handleConfigSelection = { handleConfigSelection }
2125
+ isConfigAvailable = { isConfigAvailable }
2126
+ diffOptions = { state . diffOptions }
2127
+ isRollbackTriggerSelected = { state . isRollbackTrigger }
2128
+ isRecentConfigAvailable = { state . recentDeploymentConfig !== null }
2129
+ canReviewConfig = { canReviewConfig }
2130
+ />
2131
+ )
2132
+ }
2133
+
2115
2134
const renderTriggerBody = ( isApprovalConfigured : boolean ) => (
2116
2135
< div
2117
2136
className = { `trigger-modal__body ${ showConfigDiffView && canReviewConfig ( ) ? 'p-0' : '' } ` }
2118
2137
style = { {
2119
2138
height : getTriggerBodyHeight ( isApprovalConfigured ) ,
2120
2139
} }
2121
2140
>
2122
- { state . checkingDiff ? < Progressing pageLoader /> : showConfigDiffView && canReviewConfig ( ) ? (
2123
- < TriggerViewConfigDiff
2124
- currentConfiguration = { state . recentDeploymentConfig }
2125
- baseTemplateConfiguration = { getBaseTemplateConfiguration ( ) }
2126
- selectedConfigToDeploy = { state . selectedConfigToDeploy }
2127
- handleConfigSelection = { handleConfigSelection }
2128
- isConfigAvailable = { isConfigAvailable }
2129
- diffOptions = { state . diffOptions }
2130
- isRollbackTriggerSelected = { state . isRollbackTrigger }
2131
- isRecentConfigAvailable = { state . recentDeploymentConfig !== null }
2132
- history = { history }
2133
- canReviewConfig = { canReviewConfig }
2134
- />
2135
- ) : (
2136
- renderMaterialList ( isApprovalConfigured )
2137
- ) }
2141
+ { showConfigDiffView && canReviewConfig ( )
2142
+ ? renderTriggerViewConfifDiff ( )
2143
+ : renderMaterialList ( isApprovalConfigured ) }
2138
2144
</ div >
2139
2145
)
2140
2146
@@ -2143,7 +2149,11 @@ const getInitialSelectedConfigToDeploy = () => {
2143
2149
< div className = "trigger-modal__header" >
2144
2150
{ showConfigDiffView ? (
2145
2151
< div className = "flex left" >
2146
- < button type = "button" className = "dc__transparent icon-dim-24" onClick = { ( ) => onClickSetInitialParams ( 'list' ) } >
2152
+ < button
2153
+ type = "button"
2154
+ className = "dc__transparent icon-dim-24"
2155
+ onClick = { ( ) => onClickSetInitialParams ( 'list' ) }
2156
+ >
2147
2157
< BackIcon />
2148
2158
</ button >
2149
2159
< div className = "flex column left ml-16" >
0 commit comments