Skip to content

Commit 04f7d19

Browse files
committed
feat: enhance AppStatusModal by adding ErrorBar component and refactor DeploymentStatusDetailRow for cleaner code
1 parent b1322a3 commit 04f7d19

File tree

4 files changed

+29
-23
lines changed

4 files changed

+29
-23
lines changed

src/Shared/Components/AppStatusModal/AppStatusBody.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { ComponentProps, ReactNode, useMemo } from 'react'
22

33
import { Tooltip } from '@Common/Tooltip'
44

5+
import { ErrorBar } from '../Error'
56
import { ShowMoreText } from '../ShowMoreText'
67
import { AppStatus } from '../StatusComponent'
78
import { APP_STATUS_CUSTOM_MESSAGES } from './constants'
@@ -55,6 +56,8 @@ export const AppStatusBody = ({ appDetails, type }: Pick<AppStatusModalProps, 'a
5556
/>
5657
))}
5758
</div>
59+
60+
<ErrorBar appDetails={appDetails} />
5861
</div>
5962
)
6063
}

src/Shared/Components/CICDHistory/DeploymentStatusDetailRow.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ import { getManualSync } from './service'
3131
import { DeploymentStatusDetailRowType } from './types'
3232
import { renderIcon } from './utils'
3333

34+
const appHealthDropDownlist = ['inprogress', 'failed', 'disconnect', 'timed_out']
35+
3436
export const DeploymentStatusDetailRow = ({
3537
type,
3638
hideVerticalConnector,
@@ -39,7 +41,7 @@ export const DeploymentStatusDetailRow = ({
3941
const { appId, envId } = useParams<{ appId: string; envId: string }>()
4042
const statusBreakDownType = deploymentDetailedData.deploymentStatusBreakdown[type]
4143
const [collapsed, toggleCollapsed] = useState<boolean>(statusBreakDownType.isCollapsed)
42-
const appHealthDropDownlist = ['inprogress', 'failed', 'disconnect', 'timed_out']
44+
4345
const isHelmManifestPushFailed =
4446
type === TIMELINE_STATUS.HELM_MANIFEST_PUSHED_TO_HELM_REPO &&
4547
deploymentDetailedData.deploymentStatus === statusIcon.failed
@@ -50,8 +52,7 @@ export const DeploymentStatusDetailRow = ({
5052

5153
async function manualSyncData() {
5254
try {
53-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
54-
const response = await getManualSync({ appId, envId })
55+
await getManualSync({ appId, envId })
5556
} catch (error) {
5657
showError(error)
5758
}

src/Shared/Components/Error/ErrorBar.tsx

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,16 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { useMemo } from 'react'
1817
import { NavLink } from 'react-router-dom'
1918

2019
import { ReactComponent as ErrorInfo } from '../../../Assets/Icon/ic-errorInfo.svg'
2120
import { URLS } from '../../../Common'
2221
import { AppType } from '../../types'
23-
import { AppDetailsErrorType, ErrorBarType } from './types'
24-
import { renderErrorHeaderMessage } from './utils'
22+
import { ErrorBarType } from './types'
23+
import { getIsImagePullBackOff, renderErrorHeaderMessage } from './utils'
2524

2625
const ErrorBar = ({ appDetails }: ErrorBarType) => {
27-
const isImagePullBackOff = useMemo(() => {
28-
if (appDetails?.appType === AppType.DEVTRON_APP && appDetails?.resourceTree?.nodes?.length) {
29-
appDetails.resourceTree.nodes.some(
30-
(node) =>
31-
!!node.info?.some((info) => {
32-
const infoValueLowerCase = info?.value?.toLowerCase()
33-
return (
34-
infoValueLowerCase === AppDetailsErrorType.ERRIMAGEPULL ||
35-
infoValueLowerCase === AppDetailsErrorType.IMAGEPULLBACKOFF
36-
)
37-
}),
38-
)
39-
}
40-
41-
return false
42-
}, [appDetails])
26+
const isImagePullBackOff = getIsImagePullBackOff(appDetails)
4327

4428
if (
4529
!appDetails ||

src/Shared/Components/Error/utils.tsx

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

17-
import { AppDetails } from '../../types'
17+
import { AppDetails, AppType } from '../../types'
18+
import { AppDetailsErrorType } from './types'
19+
20+
export const getIsImagePullBackOff = (appDetails: AppDetails): boolean => {
21+
if (appDetails?.appType === AppType.DEVTRON_APP && appDetails?.resourceTree?.nodes?.length) {
22+
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+
}),
31+
)
32+
}
33+
34+
return false
35+
}
1836

1937
export const renderErrorHeaderMessage = (appDetails: AppDetails, key: string, onClickActionButton?): JSX.Element => (
2038
<div>

0 commit comments

Comments
 (0)