Skip to content

Commit 64f0879

Browse files
authored
chore(indexes): do not show rolling indexes UI for flex tier clusters COMPASS-8622 (#6595)
chore(indexes): do not show rolling indexes UI for flex tier clusters
1 parent 5af0a12 commit 64f0879

File tree

2 files changed

+40
-3
lines changed

2 files changed

+40
-3
lines changed

packages/compass-connections/src/utils/connection-supports.spec.ts

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { connectionSupports } from './connection-supports';
22
import { type ConnectionInfo } from '@mongodb-js/connection-storage/provider';
33
import { expect } from 'chai';
44

5-
const mockConnections: ConnectionInfo[] = [
5+
const mockConnections = [
66
{
77
id: 'no-atlasMetadata',
88
connectionOptions: {
@@ -134,9 +134,28 @@ const mockConnections: ConnectionInfo[] = [
134134
},
135135
},
136136
},
137-
];
137+
{
138+
id: 'flex-tier',
139+
connectionOptions: {
140+
connectionString: 'mongodb://flex',
141+
},
142+
atlasMetadata: {
143+
orgId: 'orgId',
144+
projectId: 'projectId',
145+
clusterName: 'clusterName',
146+
regionalBaseUrl: 'https://example.com',
147+
metricsId: 'metricsId',
148+
metricsType: 'replicaSet',
149+
instanceSize: 'FLEX',
150+
clusterType: 'REPLICASET',
151+
clusterUniqueId: 'clusterUniqueId',
152+
},
153+
},
154+
] as const;
138155

139-
function connectionInfoById(connectionId: string): ConnectionInfo {
156+
function connectionInfoById(
157+
connectionId: typeof mockConnections[number]['id']
158+
): ConnectionInfo {
140159
const connectionInfo = mockConnections.find(({ id }) => id === connectionId);
141160
if (!connectionInfo) {
142161
throw new Error(`No connection for id "${connectionId}"`);
@@ -182,6 +201,15 @@ describe('connectionSupports', function () {
182201
).to.be.false;
183202
});
184203

204+
it('should return false for flex tier clusters', function () {
205+
expect(
206+
connectionSupports(
207+
connectionInfoById('flex-tier'),
208+
'rollingIndexCreation'
209+
)
210+
).to.be.false;
211+
});
212+
185213
it('should return true for dedicated replicaSet clusters', function () {
186214
expect(
187215
connectionSupports(

packages/compass-connections/src/utils/connection-supports.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ function isFreeOrSharedTierCluster(instanceSize: string | undefined): boolean {
99
return ['M0', 'M2', 'M5'].includes(instanceSize);
1010
}
1111

12+
function isFlexTier(instanceSize: string | undefined): boolean {
13+
if (!instanceSize) {
14+
return false;
15+
}
16+
17+
return instanceSize === 'FLEX';
18+
}
19+
1220
function supportsRollingIndexCreation(connectionInfo: ConnectionInfo) {
1321
const atlasMetadata = connectionInfo.atlasMetadata;
1422

@@ -19,6 +27,7 @@ function supportsRollingIndexCreation(connectionInfo: ConnectionInfo) {
1927
const { metricsType, instanceSize } = atlasMetadata;
2028
return (
2129
!isFreeOrSharedTierCluster(instanceSize) &&
30+
!isFlexTier(instanceSize) &&
2231
(metricsType === 'cluster' || metricsType === 'replicaSet')
2332
);
2433
}

0 commit comments

Comments
 (0)