@@ -296,7 +296,6 @@ export const Details: React.FC<DetailsType> = ({
296296 const appDetailsAbortRef = useRef ( null )
297297 const shouldFetchTimelineRef = useRef ( false )
298298
299-
300299 const [ deploymentStatusDetailsBreakdownData , setDeploymentStatusDetailsBreakdownData ] =
301300 useState < DeploymentStatusDetailsBreakdownDataType > ( {
302301 ...( isVirtualEnvRef . current && processVirtualEnvironmentDeploymentData
@@ -408,7 +407,7 @@ export const Details: React.FC<DetailsType> = ({
408407
409408 async function callAppDetailsAPI ( fetchExternalLinks ?: boolean ) {
410409 appDetailsAPI ( params . appId , params . envId , interval - 5000 , appDetailsAbortRef . current . signal )
411- . then ( ( response ) => {
410+ . then ( async ( response ) => {
412411 isVirtualEnvRef . current = response . result ?. isVirtualEnvironment
413412 // This means the CD is not triggered and the app is not helm migrated i.e. Empty State
414413 if (
@@ -428,25 +427,31 @@ export const Details: React.FC<DetailsType> = ({
428427 IndexStore . publishAppDetails ( appDetailsRef . current , AppType . DEVTRON_APP )
429428 setAppDetails ( appDetailsRef . current )
430429
431- const isIsolatedEnv = isVirtualEnvRef . current && ! ! appDetailsRef . current . resourceTree
432-
433- _getDeploymentStatusDetail ( appDetailsRef . current . deploymentAppType , isIsolatedEnv , isIsolatedEnv ? appDetailsRef . current ?. resourceTree ?. wfrId : null )
434-
435430 if ( fetchExternalLinks && response . result ?. clusterId ) {
436431 getExternalLinksAndTools ( response . result . clusterId )
437432 }
438433 pollResourceTreeRef . current = true
434+
435+ if ( pollResourceTreeRef . current ) {
436+ // Need to wait for the resource tree to check if the env is isolated or not
437+ await fetchResourceTree ( )
438+ }
439+
440+ const isIsolatedEnv = isVirtualEnvRef . current && ! ! appDetailsRef . current . resourceTree
441+
442+ _getDeploymentStatusDetail (
443+ appDetailsRef . current . deploymentAppType ,
444+ isIsolatedEnv ,
445+ isIsolatedEnv ? appDetailsRef . current ?. resourceTree ?. wfrId : null ,
446+ )
439447 } )
440448 . catch ( handleAppDetailsCallError )
441449 . finally ( ( ) => {
442450 setLoadingDetails ( false )
443451 } )
444- if ( pollResourceTreeRef . current ) {
445- fetchResourceTree ( )
446- }
447452 }
448453
449- const fetchResourceTree = ( ) => {
454+ const fetchResourceTree = ( ) =>
450455 fetchResourceTreeInTime ( params . appId , params . envId , interval - 5000 , appDetailsAbortRef . current . signal )
451456 . then ( ( response ) => {
452457 if (
@@ -473,9 +478,12 @@ export const Details: React.FC<DetailsType> = ({
473478 . finally ( ( ) => {
474479 setLoadingResourceTree ( false )
475480 } )
476- }
477481
478- function _getDeploymentStatusDetail ( deploymentAppType : DeploymentAppTypes , isIsolatedEnv : boolean , triggerIdToFetch ?: number ) {
482+ function _getDeploymentStatusDetail (
483+ deploymentAppType : DeploymentAppTypes ,
484+ isIsolatedEnv : boolean ,
485+ triggerIdToFetch ?: number ,
486+ ) {
479487 const shouldFetchTimeline = shouldFetchTimelineRef . current
480488
481489 // triggerIdToFetch represents the wfrId to fetch for any specific deployment
@@ -944,7 +952,7 @@ export const EnvSelector = ({
944952 </ div >
945953 < div data-testid = "app-deployed-env-name" className = "app-details__selector w-200" >
946954 < SelectPicker
947- inputId = ' app-environment-select'
955+ inputId = " app-environment-select"
948956 placeholder = "Select Environment"
949957 options = { groupList }
950958 value = { envId ? { value : + envId , label : environmentName } : null }
0 commit comments