Skip to content

Commit 43c4cc1

Browse files
committed
refactor: update AppStatusModal components to improve error handling and layout, including adjustments to ErrorBar and AppStatusContent styling
1 parent 53de3f0 commit 43c4cc1

File tree

11 files changed

+30
-17
lines changed

11 files changed

+30
-17
lines changed

src/Shared/Components/AppStatusModal/AppStatusBody.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ export const AppStatusBody = ({ appDetails, type, handleShowConfigDriftModal }:
7474
))}
7575
</div>
7676

77-
{/* TODO: Test */}
78-
<ErrorBar appDetails={appDetails} />
77+
<ErrorBar appDetails={appDetails} useParentMargin={false} />
7978

8079
<AppStatusContent appDetails={appDetails} handleShowConfigDriftModal={handleShowConfigDriftModal} />
8180
</div>

src/Shared/Components/AppStatusModal/AppStatusContent.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,4 @@
44
grid-template-columns: 150px 200px 100px auto;
55
}
66
}
7-
8-
.info-card-item {
9-
grid-template-columns: 140px 1fr;
10-
}
117
}

src/Shared/Components/AppStatusModal/AppStatusContent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ const AppStatusContent = ({
9191
<span className="dc__word-break">{nodeDetails.name}</span>
9292

9393
<div
94-
className={`app-summary__status-name f-${getNodeStatus(nodeDetails)?.toLowerCase() || ''} dc__first-letter-capitalize--imp fs-13 fw-4 lh-20`}
94+
className={`app-summary__status-name f-${getNodeStatus(nodeDetails)?.toLowerCase() || ''} dc__first-letter-capitalize--imp fs-13 fw-4 lh-20 dc__word-break`}
9595
>
9696
{getNodeStatus(nodeDetails)}
9797
</div>

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import { AppStatusBody } from './AppStatusBody'
1717
import { getAppDetails } from './service'
1818
import { AppStatusModalProps } from './types'
1919

20+
import './AppStatusModal.scss'
21+
2022
const AppStatusModal = ({
2123
title,
2224
handleClose,
@@ -47,7 +49,7 @@ const AppStatusModal = ({
4749
fetchedAppDetailsError,
4850
reloadInitialAppDetails,
4951
setFetchedAppDetails,
50-
] = useAsync(getAppDetailsWrapper, [appId, envId, type], type === 'release')
52+
] = useAsync(getAppDetailsWrapper, [appId, envId], type === 'release')
5153

5254
const handleExternalSync = async () => {
5355
try {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.app-status-modal {
2+
.info-card-item {
3+
grid-template-columns: 140px 1fr;
4+
}
5+
}

src/Shared/Components/AppStatusModal/service.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,33 @@
11
import { get, getIsRequestAborted } from '@Common/API'
22
import { ROUTES } from '@Common/Constants'
3-
import { showError } from '@Common/Helper'
3+
import { getUrlWithSearchParams, showError } from '@Common/Helper'
44
import { APIOptions } from '@Common/Types'
5+
import { AppDetails, AppType } from '@Shared/types'
56

67
export const getAppDetails = async (
78
appId: number,
89
envId: number,
910
abortControllerRef: APIOptions['abortControllerRef'],
10-
) => {
11+
): Promise<AppDetails> => {
1112
try {
13+
const queryParams = getUrlWithSearchParams('', {
14+
'app-id': appId,
15+
'env-id': envId,
16+
})
17+
1218
const [appDetails, resourceTree] = await Promise.all([
13-
get(`${ROUTES.APP_DETAIL}/v2?app-id=${appId}&env-id=${envId}`, {
19+
get(`${ROUTES.APP_DETAIL}/v2?${queryParams}`, {
1420
abortControllerRef,
1521
}),
16-
get(`${ROUTES.APP_DETAIL}/resource-tree?app-id=${appId}&env-id=${envId}`, {
22+
get(`${ROUTES.APP_DETAIL}/resource-tree?${queryParams}`, {
1723
abortControllerRef,
1824
}),
1925
])
2026

2127
return {
2228
...(appDetails.result || {}),
2329
resourceTree: resourceTree.result,
30+
appType: AppType.DEVTRON_APP,
2431
}
2532
} catch (error) {
2633
if (getIsRequestAborted(error)) {

src/Shared/Components/AppStatusModal/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export type AppStatusModalProps = {
1818
envId: number
1919
}
2020
| {
21-
type: 'devtron-app' | 'external-apps' | 'stack-manager'
21+
type: 'devtron-app' | 'other-apps' | 'stack-manager'
2222
appId?: never
2323
envId?: never
2424
}

src/Shared/Components/AppStatusModal/utils.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export const getAppStatusModalTitle = (segments: string[]) => {
7171
const filteredSegments = (segments || []).filter((segment) => !!segment)
7272

7373
return (
74-
<h2 className="m-0 dc__truncate fs-16 fw-6 lh-1-5">
74+
<h2 className="m-0 dc__truncate fs-16 fw-6 lh-1-5 dc__gap-4">
7575
{filteredSegments?.map((segment, index) => (
7676
<Fragment key={segment}>
7777
{segment}

src/Shared/Components/Error/ErrorBar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { AppType } from '../../types'
2222
import { ErrorBarType } from './types'
2323
import { getIsImagePullBackOff, renderErrorHeaderMessage } from './utils'
2424

25-
const ErrorBar = ({ appDetails }: ErrorBarType) => {
25+
const ErrorBar = ({ appDetails, useParentMargin = true }: ErrorBarType) => {
2626
if (
2727
!appDetails ||
2828
appDetails.appType !== AppType.DEVTRON_APP ||
@@ -37,7 +37,7 @@ const ErrorBar = ({ appDetails }: ErrorBarType) => {
3737

3838
return (
3939
isImagePullBackOff && (
40-
<div className="er-2 bw-1 br-4 m-20 fs-13">
40+
<div className={`er-2 bw-1 br-4 ${useParentMargin ? 'm-20' : ''} fs-13`}>
4141
<div className="bcr-1 pl-12 pr-12 pt-8 pb-8 dc__border-bottom-r2 flex left">
4242
<ErrorInfo className="icon-dim-24 mr-8" /> <span className="mr-8">IMAGEPULLBACKOFF:</span>
4343
{renderErrorHeaderMessage(appDetails, 'error-bar')}

src/Shared/Components/Error/types.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ import { AppDetails } from '../../types'
1818

1919
export interface ErrorBarType {
2020
appDetails: AppDetails
21+
/**
22+
* @default true
23+
*/
24+
useParentMargin?: boolean
2125
}
2226

2327
export enum AppDetailsErrorType {

0 commit comments

Comments
 (0)