Skip to content

Commit 9be2f41

Browse files
committed
Merge branch 'feat/cluster-env' of https://github.com/devtron-labs/dashboard into feat/cluster-map
2 parents d2f5299 + 9260744 commit 9be2f41

File tree

5 files changed

+58
-47
lines changed

5 files changed

+58
-47
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,3 +292,17 @@ export const DeleteCluster = ({ clusterList, reloadClusterList, handleClose }: E
292292
/>
293293
)
294294
}
295+
296+
export const ClusterEnvLoader = () => (
297+
<>
298+
{Array.from({ length: 3 }).map((_, idx) => (
299+
// eslint-disable-next-line react/no-array-index-key
300+
<div key={idx} className="px-20 py-8 dc__grid environment-row dc__align-items-center">
301+
{Array.from({ length: 5 }).map((_, index) => (
302+
// eslint-disable-next-line react/no-array-index-key
303+
<span key={index} className="shimmer" />
304+
))}
305+
</div>
306+
))}
307+
</>
308+
)

src/Pages/GlobalConfigurations/ClustersAndEnvironments/ClusterList.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,13 @@ import {
6767
EnvListSortableKeys,
6868
} from './cluster.type'
6969
import { parseClusterEnvSearchParams } from './cluster.util'
70-
import { AddEnvironment, ClusterListCellComponent, DeleteCluster, EditCluster } from './ClusterList.components'
70+
import {
71+
AddEnvironment,
72+
ClusterEnvLoader,
73+
ClusterListCellComponent,
74+
DeleteCluster,
75+
EditCluster,
76+
} from './ClusterList.components'
7177
import { ALL_CLUSTER_VALUE } from './constants'
7278
import EnvironmentList from './EnvironmentList'
7379

@@ -272,13 +278,7 @@ const ClusterList = () => {
272278

273279
const renderList = () => {
274280
if (isClusterEnvListLoading) {
275-
return Array.from({ length: 3 }).map(() => (
276-
<div className="px-20 py-8 dc__grid cluster-row dc__align-items-center">
277-
{Array.from({ length: 5 }).map(() => (
278-
<span className="shimmer" />
279-
))}
280-
</div>
281-
))
281+
return <ClusterEnvLoader />
282282
}
283283

284284
if (clusterListError || envListError) {

src/Pages/GlobalConfigurations/ClustersAndEnvironments/EnvironmentList.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import {
3535
} from './cluster.type'
3636
import { environmentNameComparator, getSelectParsedCategory } from './cluster.util'
3737
import { ClusterEnvironmentDrawer } from './ClusterEnvironmentDrawer'
38+
import { ClusterEnvLoader } from './ClusterList.components'
3839
import { ADD_ENVIRONMENT_FORM_LOCAL_STORAGE_KEY } from './constants'
3940

4041
import './cluster.scss'
@@ -129,13 +130,7 @@ const ClustersEnvironmentsList = ({
129130

130131
const renderNamespaceEnvList = () => {
131132
if (namespaceListLoading) {
132-
return Array.from({ length: 3 }).map(() => (
133-
<div className="px-20 py-8 dc__grid environment-row dc__align-items-center">
134-
{Array.from({ length: 5 }).map(() => (
135-
<span className="shimmer" />
136-
))}
137-
</div>
138-
))
133+
return <ClusterEnvLoader />
139134
}
140135

141136
if (namespaceListError) {
@@ -405,7 +400,6 @@ const EnvironmentList = ({
405400
<SortableTableHeaderCell title="DESCRIPTION" isSortable={false} />
406401
</div>
407402
{clusterList
408-
.sort((a, b) => stringComparatorBySortOrder(a.clusterName, b.clusterName))
409403
.filter(({ clusterId }) => !filterClusterId || filterClusterId === String(clusterId))
410404
.map(({ clusterId, clusterName, isProd, isVirtualCluster }) => (
411405
<ClustersEnvironmentsList

src/Pages/GlobalConfigurations/ClustersAndEnvironments/cluster.scss

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,6 @@
6565
}
6666
}
6767

68-
.cluster-list-row {
69-
display: grid;
70-
grid-template-columns: 24px minmax(278px, 346px) 120px 130px 190px minmax(80px, 90px);
71-
grid-column-gap: 16px;
72-
}
73-
7468
.saved-cluster-list-row {
7569
display: grid;
7670
grid-template-columns: 300px 100px 1fr;

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

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

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

1926
import { Routes } from '@Config/constants'
2027

@@ -50,30 +57,32 @@ export const getClusterList = async (clusterIds?: number[]): Promise<Cluster[]>
5057
const { result } = await get<ClusterDTO[]>(url)
5158

5259
// eslint-disable-next-line camelcase
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-
)
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))
7786
}
7887

7988
export function getCluster(id: number) {

0 commit comments

Comments
 (0)