Skip to content

Commit b3a2e40

Browse files
committed
fix: stop polling resource tree for app not deployed
1 parent e7ab296 commit b3a2e40

File tree

5 files changed

+31
-12
lines changed

5 files changed

+31
-12
lines changed

src/components/app/details/appDetails/AppDetails.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -507,19 +507,22 @@ const Details: React.FC<DetailsType> = ({
507507
const response = await appDetailsAPI(params.appId, params.envId, interval - 5000, appDetailsAbortRef)
508508
// eslint-disable-next-line no-param-reassign
509509
isVirtualEnvRef.current = response.result?.isVirtualEnvironment
510-
// This means the CD is not triggered and the app is not helm migrated i.e. Empty State
511-
if (!response.result.isPipelineTriggered && response.result.releaseMode === ReleaseMode.NEW_DEPLOYMENT) {
512-
setResourceTreeFetchTimeOut(false)
513-
setLoadingResourceTree(false)
514-
pollResourceTreeRef.current = false
515-
}
510+
516511
appDetailsRef.current = {
517512
...appDetailsRef.current,
518513
...response.result,
519514
}
520515
IndexStore.publishAppDetails(appDetailsRef.current, AppType.DEVTRON_APP)
521516
setAppDetails(appDetailsRef.current)
522517

518+
// This means the CD is not triggered and the app is not helm migrated i.e. Empty State
519+
if (!response.result.isPipelineTriggered && response.result.releaseMode === ReleaseMode.NEW_DEPLOYMENT) {
520+
setResourceTreeFetchTimeOut(false)
521+
setLoadingResourceTree(false)
522+
pollResourceTreeRef.current = false
523+
return
524+
}
525+
523526
if (fetchExternalLinks && response.result?.clusterId) {
524527
getExternalLinksAndTools(response.result.clusterId)
525528
}
@@ -610,6 +613,7 @@ const Details: React.FC<DetailsType> = ({
610613
}}
611614
isForEmptyState
612615
handleSuccess={callAppDetailsAPI}
616+
isAppView={isAppView}
613617
/>
614618
)
615619

@@ -848,7 +852,7 @@ const AppDetail = ({ detailsType, filteredResourceIds }: AppDetailProps) => {
848852
const envList = useMemo(
849853
() =>
850854
(otherEnvsResult?.result ?? [])
851-
.filter((env) => !filteredEntityMap || filteredEntityMap.get(env.environmentId))
855+
.filter((env) => !isAppView || !filteredEntityMap || filteredEntityMap.get(env.environmentId))
852856
.sort((a, b) => stringComparatorBySortOrder(a.environmentName, b.environmentName)),
853857
[filteredResourceIds, otherEnvsResult],
854858
)

src/components/app/details/appDetails/AppDetailsCDButton.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import { AppDetailsCDButtonType } from '../../types'
3838
import CDMaterial from '../triggerView/cdMaterial'
3939
import { TRIGGER_VIEW_PARAMS } from '../triggerView/Constants'
4040
import { MATERIAL_TYPE } from '../triggerView/types'
41-
import { DA_APP_DETAILS_GA_EVENTS } from './constants'
41+
import { AG_APP_DETAILS_GA_EVENTS, DA_APP_DETAILS_GA_EVENTS } from './constants'
4242
import { getDeployButtonConfig } from './utils'
4343

4444
const ApprovalMaterialModal = importComponentFromFELibrary('ApprovalMaterialModal')
@@ -54,6 +54,7 @@ const AppDetailsCDButton = ({
5454
environmentName,
5555
isForEmptyState = false,
5656
handleSuccess,
57+
isAppView,
5758
}: AppDetailsCDButtonType): JSX.Element => {
5859
const history = useHistory()
5960
const { searchParams } = useSearchString()
@@ -72,7 +73,9 @@ const AppDetailsCDButton = ({
7273
search: new URLSearchParams(newParams).toString(),
7374
})
7475

75-
ReactGA.event(DA_APP_DETAILS_GA_EVENTS.DeployButtonClicked)
76+
ReactGA.event(
77+
isAppView ? DA_APP_DETAILS_GA_EVENTS.DeployButtonClicked : AG_APP_DETAILS_GA_EVENTS.DeployButtonClicked,
78+
)
7679
}
7780

7881
const closeCDModal = (e: React.MouseEvent): void => {

src/components/app/details/appDetails/SourceInfo.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ import { ReactComponent as Trash } from '../../../../assets/icons/ic-delete-dots
5353
import { ReactComponent as ScaleDown } from '../../../../assets/icons/ic-scale-down.svg'
5454
import HelmAppConfigApplyStatusCard from '@Components/v2/appDetails/sourceInfo/environmentStatus/HelmAppConfigApplyStatusCard'
5555
import { HibernationModalTypes } from './appDetails.type'
56-
import { DA_APP_DETAILS_GA_EVENTS } from './constants'
56+
import { AG_APP_DETAILS_GA_EVENTS, DA_APP_DETAILS_GA_EVENTS } from './constants'
5757
import AppEnvSelector from './AppDetails.components'
5858

5959
const AppDetailsDownloadCard = importComponentFromFELibrary('AppDetailsDownloadCard')
@@ -160,7 +160,7 @@ export const SourceInfo = ({
160160
}
161161

162162
const onClickSliderVerticalButton = () => {
163-
ReactGA.event(DA_APP_DETAILS_GA_EVENTS.GoToEnvironmentConfiguration)
163+
ReactGA.event(isAppView ? DA_APP_DETAILS_GA_EVENTS.GoToEnvironmentConfiguration: AG_APP_DETAILS_GA_EVENTS.GoToEnvironmentConfiguration)
164164
}
165165

166166
const renderDevtronAppsEnvironmentSelector = () => {
@@ -336,6 +336,7 @@ export const SourceInfo = ({
336336
deploymentUserActionState: deploymentUserActionState,
337337
triggerType: appDetails.triggerType,
338338
}}
339+
isAppView={isAppView}
339340
/>
340341
</div>
341342
)}

src/components/app/details/appDetails/constants.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,14 @@ export const DA_APP_DETAILS_GA_EVENTS: Record<string, Parameters<typeof ReactGA.
3636
action: 'DA_APP_DETAIL_METRICS_PRESET_TIME_RANGE',
3737
},
3838
}
39+
40+
export const AG_APP_DETAILS_GA_EVENTS: Record<string, Parameters<typeof ReactGA.event>[0]> = {
41+
DeployButtonClicked: {
42+
category: 'App Details',
43+
action: 'AG_APP_DETAIL_DEPLOY',
44+
},
45+
GoToEnvironmentConfiguration: {
46+
category: 'App Details',
47+
action: 'AG_APP_DETAIL_GO_TO_ENV_CONFIG',
48+
},
49+
}

src/components/app/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ export interface AppDetailsCDButtonType
594594
AppDetails,
595595
'appId' | 'environmentId' | 'isVirtualEnvironment' | 'deploymentAppType' | 'environmentName'
596596
>,
597-
Pick<SourceInfoType, 'deploymentUserActionState' | 'loadingDetails'> {
597+
Pick<SourceInfoType, 'deploymentUserActionState' | 'loadingDetails' | 'isAppView'> {
598598
isRedirectedFromAppDetails?: boolean
599599
cdModal: CDModalProps
600600
isForEmptyState?: boolean

0 commit comments

Comments
 (0)