Skip to content

Commit 89bc6bb

Browse files
committed
refactor: streamline Drawer exports and enhance AppStatusModal title handling
- Updated Drawer export to simplify import paths. - Refactored AppStatusModal to accept title segments as an array, improving title rendering. - Removed unused utility function for title generation. - Cleaned up imports in AppStatusModal for better clarity. - Introduced a new constant for app health dropdown list in CICDHistory.
1 parent 64723a9 commit 89bc6bb

File tree

10 files changed

+35
-48
lines changed

10 files changed

+35
-48
lines changed

src/Common/Drawer/Drawer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import React, { useRef, useEffect } from 'react'
17+
import { useRef, useEffect } from 'react'
1818
import { preventBodyScroll } from '../../Shared'
1919
import { VisibleModal } from '../Modals/VisibleModal'
2020
import './Drawer.scss'

src/Common/Drawer/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './Drawer'

src/Common/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export { default as DevtronCopyright } from './DevtronCopyright'
3232
export * from './DevtronProgressing'
3333
export * from './Dialogs'
3434
export * from './DraggableWrapper'
35-
export * from './Drawer/Drawer'
35+
export * from './Drawer'
3636
export { default as GenericEmptyState } from './EmptyState/GenericEmptyState'
3737
export { default as GenericFilterEmptyState } from './EmptyState/GenericFilterEmptyState'
3838
export { default as ErrorScreenManager } from './ErrorScreenManager'

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

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
import { useEffect, useRef, useState } from 'react'
2-
3-
import {
4-
abortPreviousRequests,
5-
DISCORD_LINK,
6-
Drawer,
7-
getIsRequestAborted,
8-
stopPropagation,
9-
useAsync,
10-
} from '@Common/index'
1+
import { Fragment, useEffect, useRef, useState } from 'react'
2+
3+
import { abortPreviousRequests, getIsRequestAborted } from '@Common/API'
4+
import { DISCORD_LINK } from '@Common/Constants'
5+
import { Drawer } from '@Common/Drawer'
6+
import { stopPropagation, useAsync } from '@Common/Helper'
117
import { ComponentSizeType } from '@Shared/constants'
128

139
import { APIResponseHandler } from '../APIResponseHandler'
@@ -20,7 +16,7 @@ import { AppStatusModalProps } from './types'
2016
import './AppStatusModal.scss'
2117

2218
const AppStatusModal = ({
23-
title,
19+
titleSegments,
2420
handleClose,
2521
type,
2622
appDetails: appDetailsProp,
@@ -119,6 +115,8 @@ const AppStatusModal = ({
119115
)
120116
}
121117

118+
const filteredTitleSegments = (titleSegments || []).filter((segment) => !!segment)
119+
122120
return (
123121
<Drawer position="right" width="1024px" onClose={handleClose} onEscape={handleClose}>
124122
<div
@@ -127,7 +125,14 @@ const AppStatusModal = ({
127125
>
128126
<div className="flexbox-col px-20 border__primary--bottom dc__no-shrink">
129127
<div className="flexbox py-12 dc__content-space">
130-
{title}
128+
<h2 className="m-0 dc__truncate fs-16 fw-6 lh-1-5 dc__gap-4">
129+
{filteredTitleSegments.map((segment, index) => (
130+
<Fragment key={segment}>
131+
{segment}
132+
{index !== titleSegments.length - 1 && <span className="cn-6 fs-16 fw-4">/</span>}
133+
</Fragment>
134+
))}
135+
</h2>
131136

132137
<Button
133138
dataTestId="close-modal-header-icon-button"
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
export { default as AppStatusContent } from './AppStatusContent'
22
export { default as AppStatusModal } from './AppStatusModal.component'
3-
export { getAppStatusModalTitle } from './utils'

src/Shared/Components/AppStatusModal/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { FunctionComponent, ReactNode } from 'react'
1+
import { FunctionComponent } from 'react'
22

33
import { AppDetails, ConfigDriftModalProps } from '@Shared/types'
44

55
export type AppStatusModalProps = {
6-
title: ReactNode
6+
titleSegments: string[]
77
handleClose: () => void
88
/**
99
* If given would not poll for app details and resource tree, Polling for gitops timeline would still be done

src/Shared/Components/AppStatusModal/utils.tsx

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { Fragment } from 'react'
2-
31
import { DEPLOYMENT_STATUS } from '@Shared/constants'
42
import { aggregateNodes } from '@Shared/Helpers'
53
import { AppDetails, Node } from '@Shared/types'
@@ -66,18 +64,3 @@ export const getFlattenedNodesFromAppDetails = ({
6664
}
6765

6866
export const getResourceKey = (nodeDetails: Node) => `${nodeDetails.kind}/${nodeDetails.name}`
69-
70-
export const getAppStatusModalTitle = (segments: string[]) => {
71-
const filteredSegments = (segments || []).filter((segment) => !!segment)
72-
73-
return (
74-
<h2 className="m-0 dc__truncate fs-16 fw-6 lh-1-5 dc__gap-4">
75-
{filteredSegments?.map((segment, index) => (
76-
<Fragment key={segment}>
77-
{segment}
78-
{index !== segments.length - 1 && <span className="cn-6 fs-16 fw-4">/</span>}
79-
</Fragment>
80-
))}
81-
</h2>
82-
)
83-
}

src/Shared/Components/CICDHistory/DeploymentStatusDetailRow.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,12 @@ import { ReactComponent as DropDownIcon } from '../../../Assets/Icon/ic-chevron-
2626
import { DATE_TIME_FORMATS, showError } from '../../../Common'
2727
import { DEPLOYMENT_STATUS, statusIcon, TIMELINE_STATUS } from '../../constants'
2828
import { AppStatusContent } from '../AppStatusModal'
29-
import { MANIFEST_STATUS_HEADERS, TERMINAL_STATUS_MAP } from './constants'
29+
import { APP_HEALTH_DROP_DOWN_LIST, MANIFEST_STATUS_HEADERS, TERMINAL_STATUS_MAP } from './constants'
3030
import { ErrorInfoStatusBar } from './ErrorInfoStatusBar'
3131
import { getManualSync } from './service'
3232
import { DeploymentStatusDetailRowType } from './types'
3333
import { renderIcon } from './utils'
3434

35-
const appHealthDropDownlist = ['inprogress', 'failed', 'disconnect', 'timed_out']
36-
3735
export const DeploymentStatusDetailRow = ({
3836
type,
3937
hideVerticalConnector,
@@ -204,7 +202,7 @@ export const DeploymentStatusDetailRow = ({
204202
)}
205203
{((type === TIMELINE_STATUS.KUBECTL_APPLY && statusBreakDownType.kubeList?.length) ||
206204
(type === TIMELINE_STATUS.APP_HEALTH &&
207-
appHealthDropDownlist.includes(statusBreakDownType.icon)) ||
205+
APP_HEALTH_DROP_DOWN_LIST.includes(statusBreakDownType.icon)) ||
208206
((type === TIMELINE_STATUS.GIT_COMMIT || type === TIMELINE_STATUS.ARGOCD_SYNC) &&
209207
statusBreakDownType.icon === 'failed')) && (
210208
<DropDownIcon

src/Shared/Components/CICDHistory/constants.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,5 @@ export const FAILED_WORKFLOW_STAGE_STATUS_MAP: Record<
168168
[WorkflowStageStatusType.FAILED]: true,
169169
[WorkflowStageStatusType.TIMEOUT]: true,
170170
}
171+
172+
export const APP_HEALTH_DROP_DOWN_LIST = ['inprogress', 'failed', 'disconnect', 'timed_out']

src/Shared/Components/Error/utils.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,15 @@ import { AppDetails, AppType } from '../../types'
1818
import { AppDetailsErrorType } from './types'
1919

2020
export const getIsImagePullBackOff = (appDetails: AppDetails): boolean => {
21-
if (appDetails?.appType === AppType.DEVTRON_APP && appDetails?.resourceTree?.nodes?.length) {
22-
return appDetails.resourceTree.nodes.some(
23-
(node) =>
24-
!!node.info?.some((info) => {
25-
const infoValueLowerCase = info?.value?.toLowerCase()
26-
return (
27-
infoValueLowerCase === AppDetailsErrorType.ERRIMAGEPULL ||
28-
infoValueLowerCase === AppDetailsErrorType.IMAGEPULLBACKOFF
29-
)
30-
}),
21+
if (appDetails?.appType === AppType.DEVTRON_APP && appDetails.resourceTree?.nodes?.length) {
22+
return appDetails.resourceTree.nodes.some((node) =>
23+
(node.info || []).some((info) => {
24+
const infoValueLowerCase = info.value?.toLowerCase()
25+
return (
26+
infoValueLowerCase === AppDetailsErrorType.ERRIMAGEPULL ||
27+
infoValueLowerCase === AppDetailsErrorType.IMAGEPULLBACKOFF
28+
)
29+
}),
3130
)
3231
}
3332

0 commit comments

Comments
 (0)