Skip to content

Commit 74f7fe1

Browse files
committed
feat: add cluster status cell from fe-lib
1 parent 1ddc3e0 commit 74f7fe1

File tree

7 files changed

+68
-52
lines changed

7 files changed

+68
-52
lines changed

src/components/ClusterNodes/ClusterList/ClusterListRow.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@ import { ReactComponent as Error } from '@Icons/ic-error-exclamation.svg'
2121
import { importComponentFromFELibrary } from '@Components/common'
2222
import { getClusterChangeRedirectionUrl } from '@Components/ResourceBrowser/Utils'
2323

24-
import { ClusterMapInitialStatus } from '../ClusterMapInitialStatus'
2524
import { CLUSTER_PROD_TYPE } from '../constants'
25+
import { ClusterStatus } from './ClusterStatus'
2626
import { ClusterListRowTypes } from './types'
2727

2828
const CompareClusterButton = importComponentFromFELibrary('CompareClusterButton', null, 'function')
29-
const ClusterStatusCell = importComponentFromFELibrary('ClusterStatus', null, 'function')
3029
const KubeConfigButton = importComponentFromFELibrary('KubeConfigButton', null, 'function')
3130
const KubeConfigRowCheckbox = importComponentFromFELibrary('KubeConfigRowCheckbox', null, 'function')
3231

@@ -49,15 +48,11 @@ const ClusterListRow = ({
4948
}
5049

5150
const renderClusterStatus = ({ errorInNodeListing, status }: ClusterDetail) => {
52-
if (!status && !errorInNodeListing) {
51+
if (!status) {
5352
return null
5453
}
5554

56-
if (ClusterStatusCell && status) {
57-
return <ClusterStatusCell status={status} errorInNodeListing={errorInNodeListing} />
58-
}
59-
60-
return <ClusterMapInitialStatus errorInNodeListing={errorInNodeListing} />
55+
return <ClusterStatus status={status} errorInNodeListing={errorInNodeListing} />
6156
}
6257

6358
const isIdentifierSelected = !!bulkSelectionState[clusterData.name]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright (c) 2024. Devtron Inc.
3+
*/
4+
5+
import { StatusComponent, Tooltip } from '@devtron-labs/devtron-fe-common-lib'
6+
7+
import { ClusterStatusProps } from './types'
8+
import { getClusterStatus } from './utils'
9+
10+
export const ClusterStatus = ({ status, errorInNodeListing }: ClusterStatusProps) => (
11+
<Tooltip alwaysShowTippyOnHover={!!errorInNodeListing} content={errorInNodeListing} interactive>
12+
{/* This div is added to render the tooltip, otherwise it is not visible. */}
13+
<div className="flex left">
14+
<StatusComponent status={getClusterStatus(status)} hideIconTooltip message={status} />
15+
</div>
16+
</Tooltip>
17+
)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/*
2+
* Copyright (c) 2024. Devtron Inc.
3+
*/
4+
5+
export * from './ClusterStatus'
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*
2+
* Copyright (c) 2024. Devtron Inc.
3+
*/
4+
5+
import { ClusterStatusType } from '@devtron-labs/devtron-fe-common-lib'
6+
7+
export interface ClusterStatusProps {
8+
status: ClusterStatusType
9+
errorInNodeListing?: string
10+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (c) 2024. Devtron Inc.
3+
*/
4+
5+
import { ClusterStatusType, InstallationClusterStatus, StatusType } from '@devtron-labs/devtron-fe-common-lib'
6+
7+
export const getClusterStatus = (status: ClusterStatusType | InstallationClusterStatus) => {
8+
switch (status) {
9+
case InstallationClusterStatus.Installed:
10+
case InstallationClusterStatus.Updated:
11+
return StatusType.SUCCEEDED
12+
13+
case InstallationClusterStatus.Deleting:
14+
return StatusType.DELETING
15+
16+
case InstallationClusterStatus.Deleted:
17+
return 'deleted'
18+
19+
case InstallationClusterStatus.Creating:
20+
case InstallationClusterStatus.Updating:
21+
return StatusType.PROGRESSING
22+
23+
case ClusterStatusType.CONNECTION_FAILED:
24+
case InstallationClusterStatus.Failed:
25+
return StatusType.FAILED
26+
27+
case ClusterStatusType.HEALTHY:
28+
return StatusType.HEALTHY
29+
30+
default:
31+
return StatusType.DEGRADED
32+
}
33+
}

src/components/ClusterNodes/ClusterMapInitialStatus.tsx

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/components/ClusterNodes/types.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,6 @@ export interface ClusterOverviewProps {
279279
addTab: UseTabsReturnType['addTab']
280280
}
281281

282-
export interface ClusterMapInitialStatusType {
283-
errorInNodeListing: string
284-
}
285-
286282
export enum TaintsTableHeaderKeys {
287283
KEY = 'key',
288284
VALUE = 'value',

0 commit comments

Comments
 (0)