Skip to content

Commit d2f5299

Browse files
committed
feat: use cluster map from fe-common
1 parent 7289677 commit d2f5299

File tree

9 files changed

+90
-54
lines changed

9 files changed

+90
-54
lines changed

.env

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ FEATURE_SWAP_TRAFFIC_ENABLE=false
6060
FEATURE_RB_SYNC_CLUSTER_ENABLE=true
6161
FEATURE_BULK_RESTART_WORKLOADS_FROM_RB=deployment,rollout,daemonset,statefulset
6262
FEATURE_DEFAULT_MERGE_STRATEGY=
63-
FEATURE_CLUSTER_MAP_ENABLE=true
6463
FEATURE_DEFAULT_LANDING_RB_ENABLE=false
6564
FEATURE_ACTION_AUDIOS_ENABLE=true
6665
FEATURE_APPLICATION_TEMPLATES_ENABLE=true

src/Pages/GlobalConfigurations/ClustersAndEnvironments/ClusterList.components.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
DEFAULT_CLUSTER_ID,
3232
EditDeleteClusterProps,
3333
} from './cluster.type'
34+
import { getBulletColorAccToStatus } from './cluster.util'
3435
import { ClusterEnvironmentDrawer } from './ClusterEnvironmentDrawer'
3536
import DeleteClusterConfirmationModal from './DeleteClusterConfirmationModal'
3637
import EditClusterDrawerContent from './EditClusterDrawerContent'
@@ -43,7 +44,7 @@ export const ClusterListCellComponent: FunctionComponent<
4344
> = ({
4445
field,
4546
row: {
46-
data: { clusterId, clusterName, clusterType, envCount, serverUrl, clusterCategory, isVirtualCluster },
47+
data: { clusterId, clusterName, clusterType, envCount, serverUrl, clusterCategory, isVirtualCluster, status },
4748
},
4849
isRowActive,
4950
}: TableCellComponentProps<ClusterRowData, FiltersTypeEnum.STATE, {}>) => {
@@ -94,11 +95,17 @@ export const ClusterListCellComponent: FunctionComponent<
9495
}
9596
}
9697

98+
const statusColor = getBulletColorAccToStatus(status)
99+
97100
switch (field) {
98101
case ClusterListFields.ICON:
99102
return (
100-
<span className="flex py-8">
103+
<span className="flex py-8 dc__position-rel dc__overflow-hidden">
101104
<Icon name="ic-bg-cluster" color={null} size={24} />
105+
<span
106+
className={`dc__position-abs icon-dim-10 dc__border-radius-50-per dc__right-2--neg dc__bottom-7 ${statusColor}`}
107+
style={{ border: '2px solid var(--N0)' }}
108+
/>
102109
</span>
103110
)
104111
case ClusterListFields.CLUSTER_NAME:

src/Pages/GlobalConfigurations/ClustersAndEnvironments/ClusterList.tsx

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
ButtonComponentType,
2525
ButtonStyleType,
2626
ButtonVariantType,
27+
ClusterMap,
2728
ComponentSizeType,
2829
ErrorScreenManager,
2930
ErrorScreenNotAuthorized,
@@ -208,7 +209,7 @@ const ClusterList = () => {
208209
},
209210
],
210211
tableRows: filteredClusterList.map(
211-
({ clusterId, clusterName, isProd, category, serverUrl, isVirtualCluster }) => {
212+
({ clusterId, clusterName, isProd, category, serverUrl, isVirtualCluster, status }) => {
212213
const envCount = clusterIdVsEnvMap[clusterId]?.length
213214
return {
214215
id: `${clusterName}-${clusterId}`,
@@ -220,6 +221,7 @@ const ClusterList = () => {
220221
envCount: envCount ?? 0,
221222
clusterCategory: (category?.label as string) ?? '',
222223
isVirtualCluster,
224+
status,
223225
},
224226
}
225227
},
@@ -303,18 +305,21 @@ const ClusterList = () => {
303305
}
304306

305307
return (
306-
<Table<ClusterRowData, FiltersTypeEnum.STATE, {}>
307-
id="table__cluster-list"
308-
columns={tableColumns}
309-
rows={tableRows}
310-
filtersVariant={FiltersTypeEnum.STATE}
311-
paginationVariant={PaginationEnum.NOT_PAGINATED}
312-
emptyStateConfig={null}
313-
filter={() => true}
314-
additionalFilterProps={{
315-
initialSortKey: 'clusterName',
316-
}}
317-
/>
308+
<>
309+
<ClusterMap isLoading={isClusterEnvListLoading} filteredList={filteredClusterList} />
310+
<Table<ClusterRowData, FiltersTypeEnum.STATE, {}>
311+
id="table__cluster-list"
312+
columns={tableColumns}
313+
rows={tableRows}
314+
filtersVariant={FiltersTypeEnum.STATE}
315+
paginationVariant={PaginationEnum.NOT_PAGINATED}
316+
emptyStateConfig={null}
317+
filter={() => true}
318+
additionalFilterProps={{
319+
initialSortKey: 'clusterName',
320+
}}
321+
/>
322+
</>
318323
)
319324
}
320325

src/Pages/GlobalConfigurations/ClustersAndEnvironments/cluster.service.ts

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,20 @@ export const getEnvironmentList = async (): Promise<Environment[]> => {
2525

2626
return (result ?? []).map(
2727
// eslint-disable-next-line camelcase
28-
({ environment_name, cluster_id, cluster_name, prometheus_endpoint, default: isProd, namespace, ...res }) => ({
28+
({
29+
environment_name: environmentName,
30+
cluster_id: clusterId,
31+
cluster_name: clusterName,
32+
prometheus_endpoint: prometheusEndpoint,
33+
default: isProd,
34+
namespace,
35+
...res
36+
}) => ({
2937
...res,
30-
// id,
31-
// eslint-disable-next-line camelcase
32-
environmentName: environment_name,
33-
// eslint-disable-next-line camelcase
34-
clusterId: cluster_id,
35-
// eslint-disable-next-line camelcase
36-
clusterName: cluster_name,
37-
// eslint-disable-next-line camelcase
38-
prometheusEndpoint: prometheus_endpoint ?? '',
38+
environmentName,
39+
clusterId,
40+
clusterName,
41+
prometheusEndpoint: prometheusEndpoint ?? '',
3942
isProd,
4043
namespace: namespace ?? '',
4144
}),
@@ -47,22 +50,30 @@ export const getClusterList = async (clusterIds?: number[]): Promise<Cluster[]>
4750
const { result } = await get<ClusterDTO[]>(url)
4851

4952
// eslint-disable-next-line camelcase
50-
return (result ?? []).map(({ id, server_url, cluster_name, prometheus_url, category, ...res }) => ({
51-
...res,
52-
clusterId: id,
53-
// eslint-disable-next-line camelcase
54-
serverUrl: server_url,
55-
// eslint-disable-next-line camelcase
56-
clusterName: cluster_name,
57-
// eslint-disable-next-line camelcase
58-
prometheusUrl: prometheus_url,
59-
category: category?.name
60-
? {
61-
label: category.name,
62-
value: category.id,
63-
}
64-
: null,
65-
}))
53+
return (result ?? []).map(
54+
({
55+
id,
56+
server_url: serverUrl,
57+
cluster_name: clusterName,
58+
prometheus_url: prometheusUrl,
59+
category,
60+
clusterStatus,
61+
...res
62+
}) => ({
63+
...res,
64+
clusterId: id,
65+
serverUrl,
66+
clusterName,
67+
prometheusUrl,
68+
category: category?.name
69+
? {
70+
label: category.name,
71+
value: category.id,
72+
}
73+
: null,
74+
status: clusterStatus,
75+
}),
76+
)
6677
}
6778

6879
export function getCluster(id: number) {

src/Pages/GlobalConfigurations/ClustersAndEnvironments/cluster.type.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,15 +302,17 @@ export interface ClusterDTO {
302302
}
303303

304304
export interface Cluster
305-
extends Omit<ClusterDTO, 'server_url' | 'cluster_name' | 'prometheus_url' | 'id' | 'category'> {
305+
extends Omit<ClusterDTO, 'server_url' | 'cluster_name' | 'prometheus_url' | 'id' | 'category' | 'clusterStatus'> {
306306
serverUrl: ClusterDTO['server_url']
307307
clusterName: ClusterDTO['cluster_name']
308308
prometheusUrl: ClusterDTO['prometheus_url']
309309
clusterId: ClusterDTO['id']
310310
category: SelectPickerOptionType
311+
status: ClusterStatusType
311312
}
312313

313-
export interface ClusterRowData extends Pick<Cluster, 'clusterId' | 'clusterName' | 'serverUrl' | 'isVirtualCluster'> {
314+
export interface ClusterRowData
315+
extends Pick<Cluster, 'clusterId' | 'clusterName' | 'serverUrl' | 'isVirtualCluster' | 'status'> {
314316
envCount: number
315317
clusterType: string
316318
clusterCategory: string

src/Pages/GlobalConfigurations/ClustersAndEnvironments/cluster.util.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import {
1818
ClusterEnvironmentCategoryType,
19+
ClusterStatusType,
1920
Icon,
2021
NodeTaintType,
2122
OptionType,
@@ -157,3 +158,14 @@ export const environmentNameComparator = (a: string, b: string, sortOrder: Sorti
157158
if (bIsEmpty) return sortOrder === SortingOrder.ASC ? -1 : 1
158159
return stringComparatorBySortOrder(a, b, sortOrder)
159160
}
161+
162+
export const getBulletColorAccToStatus = (status: ClusterStatusType) => {
163+
switch (status) {
164+
case ClusterStatusType.HEALTHY:
165+
return 'bcg-5'
166+
case ClusterStatusType.UNHEALTHY:
167+
return 'bcy-5'
168+
default:
169+
return 'bcr-5'
170+
}
171+
}

src/components/ClusterNodes/ClusterList/ClusterSelectionBody.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
BulkSelectionIdentifiersType,
2222
ClusterDetail,
2323
ClusterFiltersType,
24+
ClusterMap,
2425
GenericEmptyState,
2526
useBulkSelection,
2627
useUrlFilters,
@@ -38,7 +39,6 @@ import { ClusterSelectionBodyTypes } from './types'
3839

3940
import '../clusterNodes.scss'
4041

41-
const ClusterMap = importComponentFromFELibrary('ClusterMap', null, 'function')
4242
const ClusterBulkSelectionActionWidget = importComponentFromFELibrary(
4343
'ClusterBulkSelectionActionWidget',
4444
null,
@@ -94,14 +94,7 @@ const ClusterSelectionBody: React.FC<ClusterSelectionBodyTypes> = ({
9494

9595
const renderClusterList = () => (
9696
<div className="cluster-list-main-container flex-grow-1 flexbox-col bg__primary dc__overflow-auto">
97-
{ClusterMap && window._env_.FEATURE_CLUSTER_MAP_ENABLE && (
98-
<ClusterMap
99-
isLoading={clusterListLoader}
100-
filteredList={filteredList}
101-
clusterListLoader={clusterListLoader}
102-
isProportional
103-
/>
104-
)}
97+
<ClusterMap isLoading={clusterListLoader} filteredList={filteredList} />
10598
{!filteredList?.length ? (
10699
<div className="flex-grow-1">
107100
<ClusterNodeEmptyState actionHandler={clearFilters} />

src/css/base.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,10 @@ a:focus {
386386
bottom: 0;
387387
}
388388

389+
.dc__bottom-7 {
390+
bottom: 7px;
391+
}
392+
389393
.dc__bottom-16 {
390394
bottom: 16px;
391395
}
@@ -406,6 +410,10 @@ a:focus {
406410
right: 0;
407411
}
408412

413+
.dc__right-2--neg {
414+
right: -2px;
415+
}
416+
409417
.dc__right-3--neg {
410418
right: -3px;
411419
}

src/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ if (!window || !window._env_) {
167167
FEATURE_PROMO_EMBEDDED_IFRAME_URL: '',
168168
FEATURE_DEFAULT_MERGE_STRATEGY: OverrideMergeStrategyType.PATCH,
169169
FEATURE_DEFAULT_LANDING_RB_ENABLE: false,
170-
FEATURE_CLUSTER_MAP_ENABLE: true,
171170
FEATURE_ACTION_AUDIOS_ENABLE: true,
172171
FEATURE_APPLICATION_TEMPLATES_ENABLE: true,
173172
FEATURE_DEFAULT_AUTHENTICATED_VIEW_ENABLE: false,

0 commit comments

Comments
 (0)