@@ -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 && state . recentDeploymentConfig ) {
205205 return state . recentDeploymentConfig . wfrId
206206 }
207207
@@ -245,11 +245,7 @@ export default function CDMaterial({
245245 checkingDiff : false ,
246246 } ) )
247247 } ,
248- ) . catch ( err => {
249- showError ( err )
250- setState ( ( prevState ) => ( { ...prevState , checkingDiff : false } ) )
251-
252- } ) . finally ( ( ) => {
248+ ) . finally ( ( ) => {
253249 setState ( ( prevState ) => ( { ...prevState , checkingDiff : false } ) )
254250 } )
255251 }
@@ -407,20 +403,15 @@ export default function CDMaterial({
407403
408404const getInitialSelectedConfigToDeploy = ( ) => {
409405 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
418408 ) {
419409 return SPECIFIC_TRIGGER_CONFIG_OPTION
420410 }
421411 if ( searchParams . deploy === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG ) {
422412 return LATEST_TRIGGER_CONFIG_OPTION
423413 }
414+ return LAST_SAVED_CONFIG_OPTION
424415}
425416 useEffect ( ( ) => {
426417 setState ( ( prevState ) => ( {
@@ -463,7 +454,7 @@ const getInitialSelectedConfigToDeploy = () => {
463454 const checkForConfigDiff = async ( selectedMaterial : CDMaterialType ) => {
464455 if ( state . isRollbackTrigger && state . selectedMaterial ?. wfrId !== selectedMaterial . wfrId ) {
465456 const isSpecificTriggerConfig =
466- state . selectedConfigToDeploy ? .value === DeploymentWithConfigType . SPECIFIC_TRIGGER_CONFIG
457+ state . selectedConfigToDeploy . value === DeploymentWithConfigType . SPECIFIC_TRIGGER_CONFIG
467458
468459 setState ( ( prevState ) => ( {
469460 ...prevState ,
@@ -749,31 +740,39 @@ const getInitialSelectedConfigToDeploy = () => {
749740 ]
750741
751742 const isConfigPresent = ( ) =>
752- ( state . selectedConfigToDeploy ? .value === DeploymentWithConfigType . SPECIFIC_TRIGGER_CONFIG &&
743+ ( state . selectedConfigToDeploy . value === DeploymentWithConfigType . SPECIFIC_TRIGGER_CONFIG &&
753744 state . specificDeploymentConfig ?. deploymentTemplate &&
754745 state . specificDeploymentConfig . pipelineStrategy ) ||
755- ( state . selectedConfigToDeploy ? .value === DeploymentWithConfigType . LAST_SAVED_CONFIG &&
746+ ( state . selectedConfigToDeploy . value === DeploymentWithConfigType . LAST_SAVED_CONFIG &&
756747 state . latestDeploymentConfig ?. deploymentTemplate &&
757748 state . latestDeploymentConfig . pipelineStrategy )
758749
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+
759762 const canReviewConfig = ( ) =>
760763 ( state . recentDeploymentConfig ?. deploymentTemplate &&
761764 state . recentDeploymentConfig . pipelineStrategy &&
762- ( state . selectedConfigToDeploy ? .value === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG ||
765+ ( state . selectedConfigToDeploy . value === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG ||
763766 isConfigPresent ( ) ) ) ||
764767 ! state . recentDeploymentConfig
765768
766769 const onClickSetInitialParams = ( modeParamValue : string ) => {
767- if ( canReviewConfig ( ) ) {
770+ if ( canReviewConfig ) {
768771 const newParams = {
769772 ...searchParams ,
770773 mode : modeParamValue ,
771774 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 ( ) ,
777776 }
778777
779778 history . push ( {
@@ -783,7 +782,7 @@ const getInitialSelectedConfigToDeploy = () => {
783782 }
784783
785784 const canDeployWithConfig = ( ) =>
786- ( state . selectedConfigToDeploy ? .value === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG &&
785+ ( state . selectedConfigToDeploy . value === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG &&
787786 state . recentDeploymentConfig ?. deploymentTemplate &&
788787 state . recentDeploymentConfig . pipelineStrategy ) ||
789788 isConfigPresent ( )
@@ -795,13 +794,13 @@ const getInitialSelectedConfigToDeploy = () => {
795794 ! selectedImage ||
796795 ! state . areMaterialsPassingFilters ||
797796 ( state . isRollbackTrigger && ( state . checkingDiff || ! canDeployWithConfig ( ) ) ) ||
798- ( state . selectedConfigToDeploy ? .value === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG &&
797+ ( state . selectedConfigToDeploy . value === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG &&
799798 ! state . recentDeploymentConfig )
800799 )
801800 }
802801
803802 const getBaseTemplateConfiguration = ( selected = null ) => {
804- const selectedConfig = selected ?. value || state . selectedConfigToDeploy ? .value
803+ const selectedConfig = selected ?. value || state . selectedConfigToDeploy . value
805804 return selectedConfig === DeploymentWithConfigType . LAST_SAVED_CONFIG
806805 ? state . latestDeploymentConfig
807806 : selectedConfig === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG
@@ -820,7 +819,7 @@ const getInitialSelectedConfigToDeploy = () => {
820819 }
821820
822821 const handleConfigSelection = ( selected ) => {
823- if ( selected ?. value !== state . selectedConfigToDeploy ? .value ) {
822+ if ( selected ?. value !== state . selectedConfigToDeploy . value ) {
824823 const _diffOptions = checkForDiff ( state . recentDeploymentConfig , getBaseTemplateConfiguration ( selected ) )
825824 setState ( ( prevState ) => ( {
826825 ...prevState ,
@@ -952,7 +951,7 @@ const getInitialSelectedConfigToDeploy = () => {
952951 appId ,
953952 Number ( getCDArtifactId ( ) ) ,
954953 e ,
955- state . selectedConfigToDeploy ? .value ,
954+ state . selectedConfigToDeploy . value ,
956955 getWfrId ( ) ,
957956 )
958957 return
@@ -1897,7 +1896,7 @@ const getInitialSelectedConfigToDeploy = () => {
18971896 const renderConfigDiffStatus = ( ) => {
18981897 const _canReviewConfig = canReviewConfig ( ) && state . recentDeploymentConfig !== null
18991898 const isLastDeployedOption =
1900- state . selectedConfigToDeploy ? .value === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG
1899+ state . selectedConfigToDeploy . value === DeploymentWithConfigType . LATEST_TRIGGER_CONFIG
19011900 const statusColorClasses = state . checkingDiff
19021901 ? 'cn-0 bcb-5'
19031902 : ! _canReviewConfig
@@ -1990,7 +1989,7 @@ const getInitialSelectedConfigToDeploy = () => {
19901989 < >
19911990 < h2 className = "fs-12 fw-6 lh-18 m-0" > Selected Config not available!</ h2 >
19921991 < 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 &&
19941993 ( ! state . specificDeploymentConfig ||
19951994 ! state . specificDeploymentConfig . deploymentTemplate ||
19961995 ! state . specificDeploymentConfig . pipelineStrategy )
@@ -2112,29 +2111,36 @@ const getInitialSelectedConfigToDeploy = () => {
21122111 )
21132112 }
21142113
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+
21152134 const renderTriggerBody = ( isApprovalConfigured : boolean ) => (
21162135 < div
21172136 className = { `trigger-modal__body ${ showConfigDiffView && canReviewConfig ( ) ? 'p-0' : '' } ` }
21182137 style = { {
21192138 height : getTriggerBodyHeight ( isApprovalConfigured ) ,
21202139 } }
21212140 >
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 ) }
21382144 </ div >
21392145 )
21402146
@@ -2143,7 +2149,11 @@ const getInitialSelectedConfigToDeploy = () => {
21432149 < div className = "trigger-modal__header" >
21442150 { showConfigDiffView ? (
21452151 < 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+ >
21472157 < BackIcon />
21482158 </ button >
21492159 < div className = "flex column left ml-16" >
0 commit comments