Skip to content

Commit 8d224d3

Browse files
Merge pull request #2935 from devtron-labs/chore/move-cluster-status-and-service
chore: move cluster status and service
2 parents 0074e7d + 6e3f883 commit 8d224d3

File tree

9 files changed

+27
-130
lines changed

9 files changed

+27
-130
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"homepage": "/dashboard",
66
"dependencies": {
7-
"@devtron-labs/devtron-fe-common-lib": "1.20.3-pre-4",
7+
"@devtron-labs/devtron-fe-common-lib": "1.20.3-pre-7",
88
"@esbuild-plugins/node-globals-polyfill": "0.2.3",
99
"@rjsf/core": "^5.13.3",
1010
"@rjsf/utils": "^5.13.3",

src/Pages/GlobalConfigurations/ClustersAndEnvironments/ClusterEnvironmentDrawer/ClusterEnvironmentDrawer.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
ComponentSizeType,
2525
CustomInput,
2626
Drawer,
27+
getDetailedClusterList as getClusterDetails,
2728
getSelectPickerOptionByValue,
2829
Icon,
2930
ModalSidebarPanel,
@@ -47,12 +48,7 @@ import { getClusterListing } from '@Components/ResourceBrowser/ResourceBrowser.s
4748
import { getNamespaceFromLocalStorage } from '@Pages/GlobalConfigurations/ClustersAndEnvironments/cluster.util'
4849
import { ADD_ENVIRONMENT_FORM_LOCAL_STORAGE_KEY } from '@Pages/GlobalConfigurations/ClustersAndEnvironments/constants'
4950

50-
import {
51-
deleteEnvironment,
52-
getClusterList as getClusterDetails,
53-
saveEnvironment,
54-
updateEnvironment,
55-
} from '../cluster.service'
51+
import { deleteEnvironment, saveEnvironment, updateEnvironment } from '../cluster.service'
5652
import { EnvironmentDeleteComponent } from '../EnvironmentDeleteComponent'
5753
import { clusterEnvironmentDrawerFormValidationSchema } from './schema'
5854
import { ClusterNamespacesDTO, EnvDrawerProps, EnvironmentFormType } from './types'

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

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ import {
2323
Button,
2424
ButtonStyleType,
2525
ButtonVariantType,
26-
ClusterStatusType,
26+
ClusterDetailListType,
27+
ClusterStatusIcon,
2728
ComponentSizeType,
2829
Drawer,
2930
FiltersTypeEnum,
@@ -43,42 +44,19 @@ import { importComponentFromFELibrary } from '@Components/common'
4344
import { URLS } from '@Config/routes'
4445

4546
import {
46-
Cluster,
4747
ClusterEnvTabs,
4848
ClusterListFields,
4949
ClusterRowData,
5050
DEFAULT_CLUSTER_ID,
5151
EditDeleteClusterProps,
5252
} from './cluster.type'
53-
import { getBulletColorAccToStatus } from './cluster.util'
5453
import { ClusterEnvironmentDrawer } from './ClusterEnvironmentDrawer'
5554
import DeleteClusterConfirmationModal from './DeleteClusterConfirmationModal'
5655
import EditClusterDrawerContent from './EditClusterDrawerContent'
5756

5857
const HibernationRulesModal = importComponentFromFELibrary('HibernationRulesModal', null, 'function')
5958
const VirtualClusterForm = importComponentFromFELibrary('VirtualClusterForm', null, 'function')
6059

61-
export const ClusterIconWithStatus = ({
62-
clusterStatus,
63-
isVirtualCluster,
64-
}: {
65-
clusterStatus: ClusterStatusType
66-
isVirtualCluster: boolean
67-
}) => {
68-
const statusColor = getBulletColorAccToStatus(clusterStatus)
69-
return (
70-
<span className="dc__position-rel dc__overflow-hidden icon-dim-24">
71-
<Icon name="ic-bg-cluster" color={null} size={24} />
72-
{!isVirtualCluster && (
73-
<span
74-
className={`dc__position-abs dc__top-16 icon-dim-10 dc__border-radius-50-per dc__right-2--neg ${statusColor}`}
75-
style={{ border: '2px solid var(--N0)' }}
76-
/>
77-
)}
78-
</span>
79-
)
80-
}
81-
8260
export const ClusterActions = ({ clusterId, isVirtualCluster }: { clusterId: number; isVirtualCluster: boolean }) => {
8361
const { push } = useHistory()
8462
const { search } = useLocation()
@@ -241,7 +219,7 @@ export const ClusterListCellComponent: FunctionComponent<
241219
case ClusterListFields.ICON:
242220
return (
243221
<div className="flex left py-10">
244-
<ClusterIconWithStatus clusterStatus={status} isVirtualCluster={isVirtualCluster} />
222+
<ClusterStatusIcon clusterStatus={status} isVirtualCluster={isVirtualCluster} />
245223
</div>
246224
)
247225
case ClusterListFields.CLUSTER_NAME:
@@ -314,7 +292,7 @@ export const AddEnvironmentFromClusterName = ({
314292
handleClose,
315293
clusterList,
316294
}: {
317-
clusterList: Cluster[]
295+
clusterList: ClusterDetailListType[]
318296
reloadEnvironments: () => void
319297
handleClose: () => void
320298
}) => {

src/Pages/GlobalConfigurations/ClustersAndEnvironments/ClusterList.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
FiltersTypeEnum,
3232
GenericEmptyState,
3333
GenericFilterEmptyState,
34+
getDetailedClusterList,
3435
getSelectPickerOptionByValue,
3536
Icon,
3637
numberComparatorBySortOrder,
@@ -54,7 +55,7 @@ import { importComponentFromFELibrary } from '@Components/common'
5455
import { URLS } from '@Config/routes'
5556
import AddClusterButton from '@Pages/Shared/AddEditCluster/AddClusterButton'
5657

57-
import { getClusterList, getEnvironmentList } from './cluster.service'
58+
import { getEnvironmentList } from './cluster.service'
5859
import {
5960
ClusterEnvFilterType,
6061
ClusterEnvTabs,
@@ -103,7 +104,7 @@ const ClusterList = () => {
103104
})
104105

105106
const [clusterListLoading, clusterListResult, clusterListError, reloadClusterList] = useAsync(
106-
getClusterList,
107+
getDetailedClusterList,
107108
[],
108109
isSuperAdmin,
109110
)

src/Pages/GlobalConfigurations/ClustersAndEnvironments/EnvironmentList.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
Button,
2222
ButtonStyleType,
2323
ButtonVariantType,
24+
ClusterStatusIcon,
2425
ComponentSizeType,
2526
DC_DELETE_SUBTITLES,
2627
DeleteConfirmationModal,
@@ -52,7 +53,7 @@ import {
5253
} from './cluster.type'
5354
import { environmentNameComparator, getNamespaceCount, getSelectParsedCategory } from './cluster.util'
5455
import { ClusterEnvironmentDrawer } from './ClusterEnvironmentDrawer'
55-
import { ClusterActions, ClusterEnvLoader, ClusterIconWithStatus } from './ClusterList.components'
56+
import { ClusterActions, ClusterEnvLoader } from './ClusterList.components'
5657
import { ADD_ENVIRONMENT_FORM_LOCAL_STORAGE_KEY } from './constants'
5758

5859
import './cluster.scss'
@@ -302,7 +303,7 @@ const ClustersEnvironmentsList = ({
302303
className="dc__zi-1 px-20 py-6 bg__secondary dc__grid dc__align-items-center cluster-metadata-header dc__gap-16 dc__content-start fs-12 lh-20 cn-7 dc__position-sticky"
303304
style={{ top: '37px' }}
304305
>
305-
<ClusterIconWithStatus clusterStatus={status} isVirtualCluster={isVirtualCluster} />
306+
<ClusterStatusIcon clusterStatus={status} isVirtualCluster={isVirtualCluster} />
306307
<Tooltip
307308
content={`${clusterName} (${environments.length} Environments)`}
308309
alwaysShowTippyOnHover

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

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,11 @@
1414
* limitations under the License.
1515
*/
1616

17-
import {
18-
get,
19-
getUrlWithSearchParams,
20-
post,
21-
put,
22-
stringComparatorBySortOrder,
23-
trash,
24-
} from '@devtron-labs/devtron-fe-common-lib'
17+
import { get, post, put, trash } from '@devtron-labs/devtron-fe-common-lib'
2518

2619
import { Routes } from '@Config/constants'
2720

28-
import { Cluster, ClusterDTO, DeleteClusterPayload, Environment, EnvironmentDTO } from './cluster.type'
21+
import { DeleteClusterPayload, Environment, EnvironmentDTO } from './cluster.type'
2922

3023
export const getEnvironmentList = async (): Promise<Environment[]> => {
3124
const { result } = await get<EnvironmentDTO[]>(Routes.ENVIRONMENT)
@@ -52,39 +45,6 @@ export const getEnvironmentList = async (): Promise<Environment[]> => {
5245
)
5346
}
5447

55-
export const getClusterList = async (clusterIds?: number[]): Promise<Cluster[]> => {
56-
const url = getUrlWithSearchParams(Routes.CLUSTER, { clusterId: clusterIds?.join() })
57-
const { result } = await get<ClusterDTO[]>(url)
58-
59-
// eslint-disable-next-line camelcase
60-
return (result ?? [])
61-
.map(
62-
({
63-
id,
64-
server_url: serverUrl,
65-
cluster_name: clusterName,
66-
prometheus_url: prometheusUrl,
67-
category,
68-
clusterStatus,
69-
...res
70-
}) => ({
71-
...res,
72-
clusterId: id,
73-
serverUrl,
74-
clusterName,
75-
prometheusUrl,
76-
category: category?.name
77-
? {
78-
label: category.name,
79-
value: category.id,
80-
}
81-
: null,
82-
status: clusterStatus,
83-
}),
84-
)
85-
.sort((a, b) => stringComparatorBySortOrder(a.clusterName, b.clusterName))
86-
}
87-
8848
export function getCluster(id: number) {
8949
const URL = `${Routes.CLUSTER}?id=${id}`
9050
return get(URL)

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

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import { Dispatch, SetStateAction } from 'react'
1818
import { RouteComponentProps } from 'react-router-dom'
1919

2020
import {
21+
ClusterDetailListType,
2122
ClusterEnvironmentCategoryType,
22-
ClusterStatusType,
2323
EnvListMinDTO,
2424
FiltersTypeEnum,
2525
OptionType,
@@ -216,7 +216,7 @@ export interface AddClusterFormPrefilledInfoType {
216216
export interface AddEnvironmentFormPrefilledInfoType {
217217
namespace: string
218218
}
219-
export interface DeleteClusterConfirmationModalProps extends Pick<Cluster, 'clusterName'> {
219+
export interface DeleteClusterConfirmationModalProps extends Pick<ClusterDetailListType, 'clusterName'> {
220220
clusterId: string
221221
handleClose: () => void
222222
installationId: string
@@ -236,7 +236,7 @@ export interface UserNameDropDownListProps {
236236

237237
export interface EditClusterDrawerContentProps
238238
extends Pick<
239-
Cluster,
239+
ClusterDetailListType,
240240
| 'sshTunnelConfig'
241241
| 'insecureSkipTlsVerify'
242242
| 'category'
@@ -280,35 +280,8 @@ export interface Environment
280280
clusterName: EnvironmentDTO['cluster_name']
281281
}
282282

283-
export interface ClusterDTO {
284-
category: ClusterEnvironmentCategoryType
285-
cluster_name: string
286-
description: string
287-
id: number
288-
insecureSkipTlsVerify: boolean
289-
installationId: number
290-
isProd: boolean
291-
isVirtualCluster: boolean
292-
server_url: string
293-
sshTunnelConfig: any
294-
prometheus_url: string
295-
proxyUrl: string
296-
toConnectWithSSHTunnel: boolean
297-
clusterStatus: ClusterStatusType
298-
}
299-
300-
export interface Cluster
301-
extends Omit<ClusterDTO, 'server_url' | 'cluster_name' | 'prometheus_url' | 'id' | 'category' | 'clusterStatus'> {
302-
serverUrl: ClusterDTO['server_url']
303-
clusterName: ClusterDTO['cluster_name']
304-
prometheusUrl: ClusterDTO['prometheus_url']
305-
clusterId: ClusterDTO['id']
306-
category: SelectPickerOptionType
307-
status: ClusterStatusType
308-
}
309-
310283
export interface ClusterRowData
311-
extends Pick<Cluster, 'clusterId' | 'clusterName' | 'serverUrl' | 'isVirtualCluster' | 'status'> {
284+
extends Pick<ClusterDetailListType, 'clusterId' | 'clusterName' | 'serverUrl' | 'isVirtualCluster' | 'status'> {
312285
envCount: number
313286
clusterType: string
314287
clusterCategory: string
@@ -358,7 +331,7 @@ export type EnvNamespaceRowType = {
358331

359332
export interface EnvironmentListProps {
360333
isLoading: boolean
361-
clusterList: Cluster[]
334+
clusterList: ClusterDetailListType[]
362335
clusterIdVsEnvMap: Record<number, Environment[]>
363336
showUnmappedEnvs: boolean
364337
filterConfig: Pick<UseUrlFiltersReturnType<EnvListSortableKeys>, 'sortBy' | 'sortOrder' | 'searchKey'>
@@ -373,7 +346,7 @@ export type EditEnvConfigType = Pick<EnvNamespaceRowType, 'envId' | 'clusterId'>
373346

374347
export interface ClusterEnvListProps
375348
extends Pick<EnvironmentListProps, 'filterConfig' | 'showUnmappedEnvs' | 'filterClusterId'> {
376-
clusterDetails: Cluster
349+
clusterDetails: ClusterDetailListType
377350
environments: Environment[]
378351
setDeleteEnvConfig: Dispatch<SetStateAction<DeleteEnvConfigType>>
379352
setEditEnvConfig: Dispatch<SetStateAction<EditEnvConfigType>>
@@ -390,7 +363,7 @@ export interface EditEnvProps {
390363
export interface DeleteEnvProps extends Omit<EditEnvProps, 'isVirtualCluster'> {}
391364

392365
export interface EditDeleteClusterProps {
393-
clusterList: Cluster[]
366+
clusterList: ClusterDetailListType[]
394367
reloadClusterList: () => void
395368
handleClose: () => void
396369
}

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

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

1717
import {
1818
ClusterEnvironmentCategoryType,
19-
ClusterStatusType,
2019
NodeTaintType,
2120
OptionType,
2221
SelectPickerOptionType,
@@ -125,17 +124,6 @@ export const environmentNameComparator = (a: string, b: string, sortOrder: Sorti
125124
return stringComparatorBySortOrder(a, b, sortOrder)
126125
}
127126

128-
export const getBulletColorAccToStatus = (status: ClusterStatusType) => {
129-
switch (status) {
130-
case ClusterStatusType.HEALTHY:
131-
return 'bcg-5'
132-
case ClusterStatusType.UNHEALTHY:
133-
return 'bcy-5'
134-
default:
135-
return 'bcr-5'
136-
}
137-
}
138-
139127
export const getNamespaceCount = ({
140128
isVirtualCluster,
141129
envList,

yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,9 +1722,9 @@ __metadata:
17221722
languageName: node
17231723
linkType: hard
17241724

1725-
"@devtron-labs/devtron-fe-common-lib@npm:1.20.3-pre-4":
1726-
version: 1.20.3-pre-4
1727-
resolution: "@devtron-labs/devtron-fe-common-lib@npm:1.20.3-pre-4"
1725+
"@devtron-labs/devtron-fe-common-lib@npm:1.20.3-pre-7":
1726+
version: 1.20.3-pre-7
1727+
resolution: "@devtron-labs/devtron-fe-common-lib@npm:1.20.3-pre-7"
17281728
dependencies:
17291729
"@codemirror/autocomplete": "npm:6.18.6"
17301730
"@codemirror/lang-json": "npm:6.0.1"
@@ -1776,7 +1776,7 @@ __metadata:
17761776
react-select: 5.8.0
17771777
rxjs: ^7.8.1
17781778
yaml: ^2.4.1
1779-
checksum: 10c0/f168245cf827a8e2508b248dd45f5140cf195992bf3ee2af2589af2ede657fac9fc370d88b6fdc18161bbc86b27d99fc9e745b568f2e0af953c27d1963246cbd
1779+
checksum: 10c0/79b11aab5005cc115b8274d70ece90cae24d9190eb6eaeef56cd7b6d73dd8b7ae6c021a225407ebe74cdace3018174c8688dcceb7f08dcd3019e9cace2cd748e
17801780
languageName: node
17811781
linkType: hard
17821782

@@ -5730,7 +5730,7 @@ __metadata:
57305730
version: 0.0.0-use.local
57315731
resolution: "dashboard@workspace:."
57325732
dependencies:
5733-
"@devtron-labs/devtron-fe-common-lib": "npm:1.20.3-pre-4"
5733+
"@devtron-labs/devtron-fe-common-lib": "npm:1.20.3-pre-7"
57345734
"@esbuild-plugins/node-globals-polyfill": "npm:0.2.3"
57355735
"@playwright/test": "npm:^1.32.1"
57365736
"@rjsf/core": "npm:^5.13.3"

0 commit comments

Comments
 (0)