Skip to content

Commit 65b5aa1

Browse files
committed
feat: Enhance AppStatusModal and related components to support environment ID and improve deployment status handling
1 parent fb7e30b commit 65b5aa1

File tree

6 files changed

+67
-71
lines changed

6 files changed

+67
-71
lines changed

src/Shared/Components/AppStatusModal/AppStatusBody.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ const StatusHeadingContainer = ({
4040
children,
4141
type,
4242
appId,
43-
}: PropsWithChildren<Pick<AppStatusBodyProps, 'type'>> & { appId: number }) => (
43+
envId,
44+
}: PropsWithChildren<Pick<AppStatusBodyProps, 'type'>> & { appId: number; envId?: number }) => (
4445
<div className="flexbox dc__content-space w-100">
4546
{children}
4647
{type === 'release' ? (
@@ -52,7 +53,7 @@ const StatusHeadingContainer = ({
5253
endIcon={<Icon name="ic-arrow-square-out" color={null} />}
5354
text="Visit app"
5455
linkProps={{
55-
to: getAppDetailsURL(appId),
56+
to: getAppDetailsURL(appId, envId),
5657
target: '_blank',
5758
rel: 'noopener noreferrer',
5859
}}
@@ -82,7 +83,7 @@ export const AppStatusBody = ({
8283
id: `app-status-${1}`,
8384
heading: type !== 'stack-manager' ? 'Application Status' : 'Status',
8485
value: (
85-
<StatusHeadingContainer type={type} appId={appDetails.appId}>
86+
<StatusHeadingContainer type={type} appId={appDetails.appId} envId={appDetails.environmentId}>
8687
{appStatus ? <AppStatus status={appStatus} showAnimatedIcon /> : '--'}
8788
</StatusHeadingContainer>
8889
),
@@ -116,7 +117,7 @@ export const AppStatusBody = ({
116117
id: `deployment-status-${1}`,
117118
heading: 'Deployment Status',
118119
value: (
119-
<StatusHeadingContainer type={type} appId={appDetails.appId}>
120+
<StatusHeadingContainer type={type} appId={appDetails.appId} envId={appDetails.environmentId}>
120121
{deploymentStatusDetailsBreakdownData?.deploymentStatus ? (
121122
<DeploymentStatus
122123
status={deploymentStatusDetailsBreakdownData.deploymentStatus}

src/Shared/Components/AppStatusModal/AppStatusModal.component.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { DISCORD_LINK } from '@Common/Constants'
66
import { Drawer } from '@Common/Drawer'
77
import { GenericEmptyState } from '@Common/EmptyState'
88
import { handleUTCTime, stopPropagation, useAsync } from '@Common/Helper'
9-
import { DeploymentAppTypes } from '@Common/Types'
9+
import { DeploymentAppTypes, ImageType } from '@Common/Types'
1010
import { ComponentSizeType } from '@Shared/constants'
1111
import { AppType } from '@Shared/types'
1212

@@ -275,6 +275,7 @@ const AppStatusModal = ({
275275
</div>
276276
}
277277
subTitle={`Triggered at ${handleUTCTime(deploymentStatusDetailsBreakdownData.deploymentTriggerTime)} by ${deploymentStatusDetailsBreakdownData.triggeredBy}`}
278+
imageType={ImageType.Large}
278279
/>
279280
)
280281
}
Lines changed: 32 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { get, getIsRequestAborted } from '@Common/API'
1+
import { get } from '@Common/API'
22
import { ROUTES } from '@Common/Constants'
3-
import { getUrlWithSearchParams, showError } from '@Common/Helper'
3+
import { getUrlWithSearchParams } from '@Common/Helper'
44
import {
55
AppDetails,
66
AppType,
@@ -16,31 +16,24 @@ export const getAppDetails = async ({
1616
envId,
1717
abortControllerRef,
1818
}: GetAppDetailsParamsType): Promise<AppDetails> => {
19-
try {
20-
const queryParams = getUrlWithSearchParams('', {
21-
'app-id': appId,
22-
'env-id': envId,
23-
})
19+
const queryParams = getUrlWithSearchParams('', {
20+
'app-id': appId,
21+
'env-id': envId,
22+
})
2423

25-
const [appDetails, resourceTree] = await Promise.all([
26-
get<Omit<AppDetails, 'resourceTree'>>(`${ROUTES.APP_DETAIL}/v2${queryParams}`, {
27-
abortControllerRef,
28-
}),
29-
get<AppDetails['resourceTree']>(`${ROUTES.APP_DETAIL}/resource-tree${queryParams}`, {
30-
abortControllerRef,
31-
}),
32-
])
24+
const [appDetails, resourceTree] = await Promise.all([
25+
get<Omit<AppDetails, 'resourceTree'>>(`${ROUTES.APP_DETAIL}/v2${queryParams}`, {
26+
abortControllerRef,
27+
}),
28+
get<AppDetails['resourceTree']>(`${ROUTES.APP_DETAIL}/resource-tree${queryParams}`, {
29+
abortControllerRef,
30+
}),
31+
])
3332

34-
return {
35-
...(appDetails.result || ({} as AppDetails)),
36-
resourceTree: resourceTree.result,
37-
appType: AppType.DEVTRON_APP,
38-
}
39-
} catch (error) {
40-
if (!getIsRequestAborted(error)) {
41-
showError(error)
42-
}
43-
throw error
33+
return {
34+
...(appDetails.result || ({} as AppDetails)),
35+
resourceTree: resourceTree.result,
36+
appType: AppType.DEVTRON_APP,
4437
}
4538
}
4639

@@ -52,28 +45,21 @@ export const getDeploymentStatusWithTimeline = async ({
5245
virtualEnvironmentConfig,
5346
isHelmApp,
5447
}: GetDeploymentStatusWithTimelineParamsType): Promise<DeploymentStatusDetailsBreakdownDataType> => {
55-
try {
56-
const baseURL = isHelmApp ? ROUTES.HELM_DEPLOYMENT_STATUS_TIMELINE_INSTALLED_APP : ROUTES.DEPLOYMENT_STATUS
48+
const baseURL = isHelmApp ? ROUTES.HELM_DEPLOYMENT_STATUS_TIMELINE_INSTALLED_APP : ROUTES.DEPLOYMENT_STATUS
5749

58-
const deploymentStatusDetailsResponse = await get<DeploymentStatusDetailsType>(
59-
getUrlWithSearchParams(`${baseURL}/${appId}/${envId}`, {
60-
showTimeline,
61-
...(virtualEnvironmentConfig && {
62-
wfrId: virtualEnvironmentConfig.wfrId,
63-
}),
50+
const deploymentStatusDetailsResponse = await get<DeploymentStatusDetailsType>(
51+
getUrlWithSearchParams(`${baseURL}/${appId}/${envId}`, {
52+
showTimeline,
53+
...(virtualEnvironmentConfig && {
54+
wfrId: virtualEnvironmentConfig.wfrId,
6455
}),
65-
{
66-
abortControllerRef,
67-
},
68-
)
56+
}),
57+
{
58+
abortControllerRef,
59+
},
60+
)
6961

70-
return virtualEnvironmentConfig
71-
? virtualEnvironmentConfig.processVirtualEnvironmentDeploymentData(deploymentStatusDetailsResponse.result)
72-
: processDeploymentStatusDetailsData(deploymentStatusDetailsResponse.result)
73-
} catch (error) {
74-
if (!getIsRequestAborted(error)) {
75-
showError(error)
76-
}
77-
throw error
78-
}
62+
return virtualEnvironmentConfig
63+
? virtualEnvironmentConfig.processVirtualEnvironmentDeploymentData(deploymentStatusDetailsResponse.result)
64+
: processDeploymentStatusDetailsData(deploymentStatusDetailsResponse.result)
7965
}

src/Shared/Components/AppStatusModal/utils.tsx

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@ import NoDeploymentStatusImage from '@Images/no-artifact.webp'
55
import { DeploymentAppTypes, GenericEmptyStateType } from '@Common/Types'
66
import { DEPLOYMENT_STATUS } from '@Shared/constants'
77
import { aggregateNodes } from '@Shared/Helpers'
8-
import { AppDetails, AppType, Node } from '@Shared/types'
8+
import { AppDetails, AppType, DeploymentStatusDetailsBreakdownDataType, Node } from '@Shared/types'
99
import { ReleaseMode } from '@Pages/index'
1010

1111
import { AggregatedNodes, STATUS_SORTING_ORDER } from '../CICDHistory'
12+
import {
13+
FAILED_DEPLOYMENT_STATUS,
14+
PROGRESSING_DEPLOYMENT_STATUS,
15+
SUCCESSFUL_DEPLOYMENT_STATUS,
16+
} from '../DeploymentStatusBreakdown'
1217
import {
1318
AppStatusModalProps,
1419
GetFilteredFlattenedNodesFromAppDetailsParamsType as GetFlattenedNodesFromAppDetailsParamsType,
@@ -105,20 +110,20 @@ export const getShowDeploymentStatusModal = ({
105110
return true
106111
}
107112

108-
export const getEmptyViewImageFromHelmDeploymentStatus = (status: string): GenericEmptyStateType['image'] => {
109-
switch (status?.toLowerCase()) {
110-
case DEPLOYMENT_STATUS.STARTING:
111-
case DEPLOYMENT_STATUS.PROGRESSING:
112-
case DEPLOYMENT_STATUS.INITIATING:
113-
return ICManOnRocket
114-
115-
case DEPLOYMENT_STATUS.SUCCEEDED:
116-
return ICCelebration
113+
export const getEmptyViewImageFromHelmDeploymentStatus = (
114+
status: DeploymentStatusDetailsBreakdownDataType['deploymentStatus'],
115+
): GenericEmptyStateType['image'] => {
116+
if (PROGRESSING_DEPLOYMENT_STATUS.includes(status)) {
117+
return ICManOnRocket
118+
}
117119

118-
case DEPLOYMENT_STATUS.FAILED:
119-
return ICPageNotFound
120+
if (SUCCESSFUL_DEPLOYMENT_STATUS.includes(status)) {
121+
return ICCelebration
122+
}
120123

121-
default:
122-
return NoDeploymentStatusImage
124+
if (FAILED_DEPLOYMENT_STATUS.includes(status)) {
125+
return ICPageNotFound
123126
}
127+
128+
return NoDeploymentStatusImage
124129
}

src/Shared/Components/CICDHistory/DeploymentDetailSteps.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,13 @@ const DeploymentDetailSteps = ({
153153
{renderDeploymentApprovalInfo &&
154154
getIsApprovalPolicyConfigured(userApprovalMetadata?.approvalConfigData) &&
155155
renderDeploymentApprovalInfo(userApprovalMetadata)}
156-
<DeploymentStatusDetailBreakdown
157-
deploymentStatusDetailsBreakdownData={deploymentStatusDetailsBreakdownData}
158-
isVirtualEnvironment={isVirtualEnv.current}
159-
appDetails={appDetails}
160-
/>
156+
<div className="p-20 w-100">
157+
<DeploymentStatusDetailBreakdown
158+
deploymentStatusDetailsBreakdownData={deploymentStatusDetailsBreakdownData}
159+
isVirtualEnvironment={isVirtualEnv.current}
160+
appDetails={appDetails}
161+
/>
162+
</div>
161163
</div>
162164
)
163165

src/Shared/Components/DeploymentStatusBreakdown/utils.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ export const processDeploymentStatusDetailsData = (
245245
// After initial processing will mark all unavailable timelines [present before last invalid state] as success
246246
PHYSICAL_ENV_DEPLOYMENT_TIMELINE_ORDER.forEach((timelineStatusType, index) => {
247247
const element = findRight(data.timelines, getPredicate(timelineStatusType))
248+
248249
const timelineData = deploymentData.deploymentStatusBreakdown[timelineStatusType]
249250

250251
if (!element) {
@@ -290,6 +291,7 @@ export const processDeploymentStatusDetailsData = (
290291
case TIMELINE_STATUS.ARGOCD_SYNC:
291292
timelineData.time = element.statusTime
292293
timelineData.icon = 'success'
294+
timelineData.displaySubText = ''
293295

294296
// These are singular events so either their success will come or failure
295297
if (
@@ -337,7 +339,6 @@ export const processDeploymentStatusDetailsData = (
337339
break
338340
}
339341

340-
// TODO: Should we add in progress check here?
341342
if (timelineData.icon === 'success' && index !== PHYSICAL_ENV_DEPLOYMENT_TIMELINE_ORDER.length - 1) {
342343
// Moving the next timeline to inprogress
343344
const nextTimelineStatus = PHYSICAL_ENV_DEPLOYMENT_TIMELINE_ORDER[index + 1]

0 commit comments

Comments
 (0)