Skip to content

Commit daf2db3

Browse files
committed
Merge branch 'fix/cd-trigger' of https://github.com/devtron-labs/dashboard into test/cd-trigger
2 parents c2cc743 + 9721438 commit daf2db3

File tree

2 files changed

+28
-24
lines changed

2 files changed

+28
-24
lines changed

src/components/ApplicationGroup/AppGroup.utils.ts

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -96,28 +96,37 @@ export const processWorkflowStatuses = (
9696
}
9797
})
9898
}
99-
// Update Workflow using maps
100-
const _workflows = workflowsList.map((wf) => {
101-
wf.nodes = wf.nodes.map((node) => {
99+
// Update Workflow using maps, returning new objects for reactivity
100+
const _workflows = workflowsList.map((wf) => ({
101+
...wf,
102+
nodes: wf.nodes.map((node) => {
102103
switch (node.type) {
103104
case 'CI':
104-
node.status = ciMap[node.id]?.status
105-
node.storageConfigured = ciMap[node.id]?.storageConfigured
106-
break
105+
return {
106+
...node,
107+
status: ciMap[node.id]?.status,
108+
storageConfigured: ciMap[node.id]?.storageConfigured,
109+
}
107110
case 'PRECD':
108-
node.status = preCDMap[node.id]
109-
break
111+
return {
112+
...node,
113+
status: preCDMap[node.id],
114+
}
110115
case 'POSTCD':
111-
node.status = postCDMap[node.id]
112-
break
116+
return {
117+
...node,
118+
status: postCDMap[node.id],
119+
}
113120
case 'CD':
114-
node.status = cdMap[node.id]
115-
break
121+
return {
122+
...node,
123+
status: cdMap[node.id],
124+
}
125+
default:
126+
return { ...node }
116127
}
117-
return node
118128
})
119-
return wf
120-
})
129+
}))
121130
return { cicdInProgress, workflows: _workflows }
122131
}
123132

src/components/app/details/triggerView/TriggerView.service.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useRef } from 'react'
22

3-
import { DEFAULT_ENV, getEnvironmentListMinPublic, useQuery, useQueryClient } from '@devtron-labs/devtron-fe-common-lib'
3+
import { DEFAULT_ENV, getEnvironmentListMinPublic, useQuery } from '@devtron-labs/devtron-fe-common-lib'
44

55
import { getWorkflowStatus } from '@Components/app/service'
66
import { processWorkflowStatuses } from '@Components/ApplicationGroup/AppGroup.utils'
@@ -14,7 +14,6 @@ const DEFAULT_POLLING_INTERVAL = 30000
1414
const PROGRESSING_POLLING_INTERVAL = 10000
1515

1616
export const useTriggerViewServices = ({ appId, isJobView, filteredEnvIds }: UseTriggerViewServicesParams) => {
17-
const queryClient = useQueryClient()
1817
const refetchIntervalRef = useRef<number>(DEFAULT_POLLING_INTERVAL)
1918

2019
const { data: hostUrlConfig } = useQuery({
@@ -57,6 +56,7 @@ export const useTriggerViewServices = ({ appId, isJobView, filteredEnvIds }: Use
5756
isFetching: isWorkflowsLoading,
5857
data: wfData,
5958
error: workflowsError,
59+
refetch: refetchWorkflows,
6060
} = useQuery({
6161
queryKey: [appId, isJobView, filteredEnvIds, 'triggerViewWorkflowList'],
6262
queryFn: async () => {
@@ -76,7 +76,7 @@ export const useTriggerViewServices = ({ appId, isJobView, filteredEnvIds }: Use
7676

7777
const { workflows, filteredCIPipelines } = wfData ?? { workflows: [], filteredCIPipelines: [] }
7878

79-
const { data: updatedWfWithStatus } = useQuery({
79+
const { data: updatedWfWithStatus, refetch: reloadWorkflowStatus } = useQuery({
8080
queryKey: [appId, 'triggerViewWorkflowStatus'],
8181
queryFn: ({ signal }) => getWorkflowStatus(+appId, { signal }),
8282
select: (response) => {
@@ -97,13 +97,8 @@ export const useTriggerViewServices = ({ appId, isJobView, filteredEnvIds }: Use
9797

9898
const isLoading = isEnvListLoading || isWorkflowsLoading
9999

100-
const reloadWorkflowStatus = async () => {
101-
await queryClient.invalidateQueries({ queryKey: [appId, 'triggerViewWorkflowStatus'] })
102-
}
103-
104100
const reloadWorkflows = async () => {
105-
await queryClient.invalidateQueries({ queryKey: [appId, isJobView, filteredEnvIds, 'triggerViewWorkflowList'] })
106-
// Invalidate status query to refetch workflow status
101+
await refetchWorkflows()
107102
await reloadWorkflowStatus()
108103
}
109104

0 commit comments

Comments
 (0)