@@ -186,7 +186,7 @@ export default function CDMaterial({
186186 const userApprovalConfig = materialsResult ?. userApprovalConfig
187187 const isApprovalConfigured = userApprovalConfig ?. requiredCount > 0
188188 const canApproverDeploy = materialsResult ?. canApproverDeploy ?? false
189- const showConfigDiffView = searchParams . mode === "review-config"
189+ const showConfigDiffView = searchParams . mode === "review-config" && searchParams . deploy && searchParams . config
190190 /* ------------ Utils required in useEffect ------------*/
191191 const getSecurityModuleStatus = async ( ) => {
192192 try {
@@ -201,7 +201,7 @@ export default function CDMaterial({
201201 }
202202
203203 const getWfrId = ( initSelectedMaterial ?: CDMaterialType ) => {
204- if ( state . selectedConfigToDeploy . value === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG ) {
204+ if ( state . selectedConfigToDeploy ? .value === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG ) {
205205 return state . recentDeploymentConfig . wfrId
206206 }
207207
@@ -406,7 +406,10 @@ export default function CDMaterial({
406406 } , [ material ] )
407407
408408const 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+ ) {
410413 return LAST_SAVED_CONFIG_OPTION
411414 }
412415 if (
@@ -415,10 +418,7 @@ const getInitialSelectedConfigToDeploy = () => {
415418 ) {
416419 return SPECIFIC_TRIGGER_CONFIG_OPTION
417420 }
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 ) {
422422 return LATEST_TRIGGER_CONFIG_OPTION
423423 }
424424}
@@ -432,6 +432,15 @@ const getInitialSelectedConfigToDeploy = () => {
432432 } ) )
433433 } , [ materialType ] )
434434
435+ useEffect ( ( ) => {
436+ if ( searchParams . deploy ) {
437+ setState ( ( prevState ) => ( {
438+ ...prevState ,
439+ selectedConfigToDeploy : getInitialSelectedConfigToDeploy ( ) ,
440+ } ) )
441+ }
442+ } , [ searchParams . deploy ] )
443+
435444 useEffect ( ( ) => {
436445 setState ( ( prevState ) => ( {
437446 ...prevState ,
@@ -454,7 +463,7 @@ const getInitialSelectedConfigToDeploy = () => {
454463 const checkForConfigDiff = async ( selectedMaterial : CDMaterialType ) => {
455464 if ( state . isRollbackTrigger && state . selectedMaterial ?. wfrId !== selectedMaterial . wfrId ) {
456465 const isSpecificTriggerConfig =
457- state . selectedConfigToDeploy . value === DeploymentWithConfigType . SPECIFIC_TRIGGER_CONFIG
466+ state . selectedConfigToDeploy ? .value === DeploymentWithConfigType . SPECIFIC_TRIGGER_CONFIG
458467
459468 setState ( ( prevState ) => ( {
460469 ...prevState ,
@@ -740,17 +749,17 @@ const getInitialSelectedConfigToDeploy = () => {
740749 ]
741750
742751 const isConfigPresent = ( ) =>
743- ( state . selectedConfigToDeploy . value === DeploymentWithConfigType . SPECIFIC_TRIGGER_CONFIG &&
752+ ( state . selectedConfigToDeploy ? .value === DeploymentWithConfigType . SPECIFIC_TRIGGER_CONFIG &&
744753 state . specificDeploymentConfig ?. deploymentTemplate &&
745754 state . specificDeploymentConfig . pipelineStrategy ) ||
746- ( state . selectedConfigToDeploy . value === DeploymentWithConfigType . LAST_SAVED_CONFIG &&
755+ ( state . selectedConfigToDeploy ? .value === DeploymentWithConfigType . LAST_SAVED_CONFIG &&
747756 state . latestDeploymentConfig ?. deploymentTemplate &&
748757 state . latestDeploymentConfig . pipelineStrategy )
749758
750759 const canReviewConfig = ( ) =>
751760 ( state . recentDeploymentConfig ?. deploymentTemplate &&
752761 state . recentDeploymentConfig . pipelineStrategy &&
753- ( state . selectedConfigToDeploy . value === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG ||
762+ ( state . selectedConfigToDeploy ? .value === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG ||
754763 isConfigPresent ( ) ) ) ||
755764 ! state . recentDeploymentConfig
756765
@@ -774,7 +783,7 @@ const getInitialSelectedConfigToDeploy = () => {
774783 }
775784
776785 const canDeployWithConfig = ( ) =>
777- ( state . selectedConfigToDeploy . value === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG &&
786+ ( state . selectedConfigToDeploy ? .value === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG &&
778787 state . recentDeploymentConfig ?. deploymentTemplate &&
779788 state . recentDeploymentConfig . pipelineStrategy ) ||
780789 isConfigPresent ( )
@@ -786,13 +795,13 @@ const getInitialSelectedConfigToDeploy = () => {
786795 ! selectedImage ||
787796 ! state . areMaterialsPassingFilters ||
788797 ( state . isRollbackTrigger && ( state . checkingDiff || ! canDeployWithConfig ( ) ) ) ||
789- ( state . selectedConfigToDeploy . value === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG &&
798+ ( state . selectedConfigToDeploy ? .value === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG &&
790799 ! state . recentDeploymentConfig )
791800 )
792801 }
793802
794803 const getBaseTemplateConfiguration = ( selected = null ) => {
795- const selectedConfig = selected ?. value || state . selectedConfigToDeploy . value
804+ const selectedConfig = selected ?. value || state . selectedConfigToDeploy ? .value
796805 return selectedConfig === DeploymentWithConfigType . LAST_SAVED_CONFIG
797806 ? state . latestDeploymentConfig
798807 : selectedConfig === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG
@@ -810,21 +819,8 @@ const getInitialSelectedConfigToDeploy = () => {
810819 } )
811820 }
812821
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-
826822 const handleConfigSelection = ( selected ) => {
827- if ( selected ?. value !== state . selectedConfigToDeploy . value ) {
823+ if ( selected ?. value !== state . selectedConfigToDeploy ? .value ) {
828824 const _diffOptions = checkForDiff ( state . recentDeploymentConfig , getBaseTemplateConfiguration ( selected ) )
829825 setState ( ( prevState ) => ( {
830826 ...prevState ,
@@ -1901,7 +1897,7 @@ const getInitialSelectedConfigToDeploy = () => {
19011897 const renderConfigDiffStatus = ( ) => {
19021898 const _canReviewConfig = canReviewConfig ( ) && state . recentDeploymentConfig !== null
19031899 const isLastDeployedOption =
1904- state . selectedConfigToDeploy . value === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG
1900+ state . selectedConfigToDeploy ? .value === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG
19051901 const statusColorClasses = state . checkingDiff
19061902 ? 'cn-0 bcb-5'
19071903 : ! _canReviewConfig
@@ -1994,7 +1990,7 @@ const getInitialSelectedConfigToDeploy = () => {
19941990 < >
19951991 < h2 className = "fs-12 fw-6 lh-18 m-0" > Selected Config not available!</ h2 >
19961992 < 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 &&
19981994 ( ! state . specificDeploymentConfig ||
19991995 ! state . specificDeploymentConfig . deploymentTemplate ||
20001996 ! state . specificDeploymentConfig . pipelineStrategy )
@@ -2268,7 +2264,7 @@ const getInitialSelectedConfigToDeploy = () => {
22682264 { renderTriggerBody ( isApprovalConfigured ) }
22692265 </ >
22702266 ) : (
2271- renderCDModal ( isApprovalConfigured )
2267+ renderCDModal ( isApprovalConfigured )
22722268 )
22732269 }
22742270
0 commit comments