Skip to content

Commit eec4352

Browse files
authored
fix(web): fix deployment types; resolve deployment item for sharded from sharded and not clusters CLOUDP-253915 (#5906)
fix(web): fix deployment types; resolve deployment item for sharded from sharded and not clusters
1 parent f644656 commit eec4352

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

packages/compass-web/src/connection-storage.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ const deployment = {
1010
},
1111
},
1212
],
13-
clusters: [
13+
sharding: [
1414
{
15-
_id: 'sharded-xxx',
15+
name: 'sharded-xxx',
1616
state: {
1717
clusterId: '123abc',
1818
},

packages/compass-web/src/connection-storage.tsx

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,36 @@ type ClusterDescriptionWithDataProcessingRegion = ClusterDescription & {
2828
dataProcessingRegion: { regionalUrl: string };
2929
};
3030

31-
type DeploymentItem = {
31+
type ReplicaSetDeploymentItem = {
3232
_id: string;
3333
state: {
3434
clusterId: string;
3535
};
3636
};
3737

38+
type ShardingDeploymentItem = {
39+
name: string;
40+
state: {
41+
clusterId: string;
42+
};
43+
};
44+
3845
type Deployment = {
39-
replicaSets?: DeploymentItem[];
40-
clusters?: DeploymentItem[];
46+
replicaSets?: ReplicaSetDeploymentItem[];
47+
sharding?: ShardingDeploymentItem[];
4148
};
4249

4350
function findDeploymentItemByClusterName(
4451
description: ClusterDescription,
4552
deployment: Deployment
46-
): DeploymentItem | undefined {
47-
return (
48-
(isSharded(description) ? deployment.clusters : deployment.replicaSets) ??
49-
[]
50-
).find((item) => {
53+
): ReplicaSetDeploymentItem | ShardingDeploymentItem | undefined {
54+
if (isSharded(description)) {
55+
return (deployment.sharding ?? []).find((item) => {
56+
return item.name === description.deploymentItemName;
57+
});
58+
}
59+
60+
return (deployment.replicaSets ?? []).find((item) => {
5161
return item._id === description.deploymentItemName;
5262
});
5363
}
@@ -66,7 +76,7 @@ function isSharded(clusterDescription: ClusterDescription) {
6676
// eslint-disable-next-line @typescript-eslint/no-unused-vars
6777
function getMetricsIdAndType(
6878
clusterDescription: ClusterDescription,
69-
deploymentItem?: DeploymentItem
79+
deploymentItem?: ReplicaSetDeploymentItem | ShardingDeploymentItem
7080
): {
7181
clusterId: string;
7282
clusterType: 'serverless' | 'replicaSet' | 'cluster';

0 commit comments

Comments
 (0)