Skip to content

Commit e895ef4

Browse files
Merge remote-tracking branch 'origin/main' into beta-releases
2 parents 58526f9 + 89b0f48 commit e895ef4

File tree

22 files changed

+308
-172
lines changed

22 files changed

+308
-172
lines changed

THIRD-PARTY-NOTICES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
The following third-party software is used by and included in **Mongodb Compass**.
2-
This document was automatically generated on Fri Feb 28 2025.
2+
This document was automatically generated on Sun Mar 02 2025.
33

44
## List of dependencies
55

docs/tracking-plan.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
> the tracking plan for the specific Compass version you can use the following
88
> URL: `https://github.com/mongodb-js/compass/blob/<compass version>/docs/tracking-plan.md`
99
10-
Generated on Fri, Feb 28, 2025
10+
Generated on Sun, Mar 2, 2025
1111

1212
## Table of Contents
1313

@@ -1927,7 +1927,7 @@ This event is fired when user shares the schema.
19271927

19281928
- **has_schema** (required): `boolean`
19291929
- Indicates whether the schema was analyzed before sharing.
1930-
- **format** (required): `"standardJSON" | "mongoDBJSON" | "extendedJSON" | "legacyJSON"`
1930+
- **format** (required): `"standardJSON" | "mongoDBJSON" | "expandedJSON" | "legacyJSON"`
19311931
- **source** (required): `"app_menu" | "schema_tab"`
19321932
- **schema_width** (required): `number`
19331933
- The number of fields at the top level.
@@ -1950,7 +1950,7 @@ This event is fired when user shares the schema.
19501950
- **has_schema** (required): `boolean`
19511951
- Indicates whether the schema was analyzed before sharing.
19521952
- **schema_length** (required): `number`
1953-
- **format** (required): `"standardJSON" | "mongoDBJSON" | "extendedJSON" | "legacyJSON"`
1953+
- **format** (required): `"standardJSON" | "mongoDBJSON" | "expandedJSON" | "legacyJSON"`
19541954
- **stage** (required): `string`
19551955
- **is_compass_web** (optional): `true | undefined`
19561956
- **connection_id** (optional): `string | undefined`

packages/atlas-service/src/atlas-service.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,21 @@ function shouldAddCSRFHeaders(method = 'get') {
3636
return !/^(get|head|options|trace)$/.test(method.toLowerCase());
3737
}
3838

39+
function getAutomationAgentClusterId(
40+
atlasMetadata: Pick<
41+
AtlasClusterMetadata,
42+
'clusterUniqueId' | 'metricsId' | 'metricsType'
43+
>
44+
): { clusterId: string } | { serverlessId: string } | { flexId: string } {
45+
if (atlasMetadata.metricsType === 'flex') {
46+
return { flexId: atlasMetadata.clusterUniqueId };
47+
}
48+
if (atlasMetadata.metricsType === 'serverless') {
49+
return { serverlessId: atlasMetadata.clusterUniqueId };
50+
}
51+
return { clusterId: atlasMetadata.metricsId };
52+
}
53+
3954
export class AtlasService {
4055
private config: AtlasServiceConfig;
4156
constructor(
@@ -121,10 +136,7 @@ export class AtlasService {
121136
opType: string,
122137
opBody: Record<string, unknown>
123138
): Promise<{ _id: string; requestType: string } | undefined> {
124-
const opBodyClusterId =
125-
atlasMetadata.metricsType === 'serverless'
126-
? { serverlessId: atlasMetadata.clusterUniqueId }
127-
: { clusterId: atlasMetadata.metricsId };
139+
const opBodyClusterId = getAutomationAgentClusterId(atlasMetadata);
128140
const requestUrl = this.regionalizedCloudEndpoint(
129141
atlasMetadata,
130142
`/explorer/v1/groups/${atlasMetadata.projectId}/requests/${opType}`

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ const mockConnections = [
145145
clusterName: 'clusterName',
146146
regionalBaseUrl: 'https://example.com',
147147
metricsId: 'metricsId',
148-
metricsType: 'replicaSet',
148+
metricsType: 'flex',
149149
instanceSize: 'FLEX',
150150
clusterType: 'REPLICASET',
151151
clusterUniqueId: 'clusterUniqueId',

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

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,6 @@ 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-
2012
function supportsRollingIndexCreation(connectionInfo: ConnectionInfo) {
2113
const atlasMetadata = connectionInfo.atlasMetadata;
2214

@@ -26,9 +18,8 @@ function supportsRollingIndexCreation(connectionInfo: ConnectionInfo) {
2618

2719
const { metricsType, instanceSize } = atlasMetadata;
2820
return (
29-
!isFreeOrSharedTierCluster(instanceSize) &&
30-
!isFlexTier(instanceSize) &&
31-
(metricsType === 'cluster' || metricsType === 'replicaSet')
21+
(metricsType === 'cluster' || metricsType === 'replicaSet') &&
22+
!isFreeOrSharedTierCluster(instanceSize)
3223
);
3324
}
3425

packages/compass-e2e-tests/helpers/selectors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,7 @@ export const ExportSchemaButton = '[data-testid="open-schema-export-button"]';
10261026
export const ExportSchemaFormatOptions =
10271027
'[data-testid="export-schema-format-type-box-group"]';
10281028
export const exportSchemaFormatOption = (
1029-
option: 'standardJSON' | 'mongoDBJSON' | 'extendedJSON'
1029+
option: 'standardJSON' | 'mongoDBJSON' | 'expandedJSON'
10301030
) => `label[for="export-schema-format-${option}-button"]`;
10311031
export const ExportSchemaOutput = '[data-testid="export-schema-content"]';
10321032
export const ExportSchemaDownloadButton =

packages/compass-e2e-tests/tests/collection-schema-tab.test.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -208,17 +208,19 @@ describe('Collection schema tab', function () {
208208

209209
const content = readFileSync(filePath, 'utf-8');
210210
expect(JSON.parse(content)).to.deep.equal({
211-
bsonType: 'object',
212-
required: ['_id', 'i', 'j'],
213-
properties: {
214-
_id: {
215-
bsonType: 'objectId',
216-
},
217-
i: {
218-
bsonType: 'int',
219-
},
220-
j: {
221-
bsonType: 'int',
211+
$jsonSchema: {
212+
bsonType: 'object',
213+
required: ['_id', 'i', 'j'],
214+
properties: {
215+
_id: {
216+
bsonType: 'objectId',
217+
},
218+
i: {
219+
bsonType: 'int',
220+
},
221+
j: {
222+
bsonType: 'int',
223+
},
222224
},
223225
},
224226
});

packages/compass-indexes/src/modules/rolling-indexes-service.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,12 @@ export class RollingIndexesService {
6767

6868
// Not possible to do through UI, doing a pre-check here to avoid dealing
6969
// with payload variations based on metricsType later
70-
if (atlasMetadata.metricsType === 'serverless') {
70+
if (
71+
atlasMetadata.metricsType === 'serverless' ||
72+
atlasMetadata.metricsType === 'flex'
73+
) {
7174
throw new Error(
72-
"Serverless clusters don't support rolling index build creation"
75+
'Flex clusters do not support rolling index build creation'
7376
);
7477
}
7578

packages/compass-schema/src/components/compass-schema.tsx

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useCallback } from 'react';
1+
import React, { useCallback, useState } from 'react';
22
import type { Schema as MongodbSchema } from 'mongodb-schema';
33
import { connect } from 'react-redux';
44
import type { AnalysisState } from '../constants/analysis-states';
@@ -7,11 +7,9 @@ import {
77
ANALYSIS_STATE_ANALYZING,
88
ANALYSIS_STATE_COMPLETE,
99
} from '../constants/analysis-states';
10-
11-
import { SchemaToolbar } from './schema-toolbar/schema-toolbar';
10+
import SchemaToolbar from './schema-toolbar';
1211
import Field from './field';
1312
import { ZeroGraphic } from './zero-graphic';
14-
1513
import {
1614
Button,
1715
CancelLoader,
@@ -36,15 +34,10 @@ import { getAtlasPerformanceAdvisorLink } from '../utils';
3634
import { useIsLastAppliedQueryOutdated } from '@mongodb-js/compass-query-bar';
3735
import { useTelemetry } from '@mongodb-js/compass-telemetry/provider';
3836
import type { RootState } from '../stores/store';
39-
import {
40-
analysisErrorDismissed,
41-
type SchemaAnalysisError,
42-
startAnalysis,
43-
stopAnalysis,
44-
} from '../stores/schema-analysis-reducer';
37+
import { startAnalysis, stopAnalysis } from '../stores/schema-analysis-reducer';
4538
import { openExportSchema } from '../stores/schema-export-reducer';
4639
import ExportSchemaModal from './export-schema-modal';
47-
import ExportSchemaLegacyBanner from './export-schema-legacy-banner';
40+
import ExportSchemaLegacyModal from './export-schema-legacy-modal';
4841

4942
const rootStyles = css({
5043
width: '100%',
@@ -376,29 +369,23 @@ const PerformanceAdvisorBanner = () => {
376369

377370
const Schema: React.FunctionComponent<{
378371
analysisState: AnalysisState;
379-
error?: SchemaAnalysisError;
380-
maxTimeMS?: number;
372+
isExportSchemaModalOpen: boolean;
381373
schema: MongodbSchema | null;
382-
count?: number;
383-
resultId?: string;
384-
onExportSchemaClicked: () => void;
385374
onStartAnalysis: () => Promise<void>;
386375
onStopAnalysis: () => void;
387-
onDismissError: () => void;
388376
}> = ({
389377
analysisState,
390-
error,
378+
isExportSchemaModalOpen,
391379
schema,
392-
resultId,
393-
onExportSchemaClicked,
394380
onStartAnalysis,
395381
onStopAnalysis,
396-
onDismissError,
397382
}) => {
398383
const onApplyClicked = useCallback(() => {
399384
void onStartAnalysis();
400385
}, [onStartAnalysis]);
401386

387+
const [showLegacyExportTooltip, setShowLegacyExportTooltip] = useState(false);
388+
402389
const outdated = useIsLastAppliedQueryOutdated('schema');
403390

404391
const enablePerformanceAdvisorBanner = usePreference(
@@ -414,14 +401,14 @@ const Schema: React.FunctionComponent<{
414401
toolbar={
415402
<SchemaToolbar
416403
onAnalyzeSchemaClicked={onApplyClicked}
417-
onExportSchemaClicked={onExportSchemaClicked}
418404
onResetClicked={onApplyClicked}
419-
analysisState={analysisState}
420-
error={error}
421-
onDismissError={onDismissError}
405+
// Show the tooltip to indicate the new export button when
406+
// the export modal is closed.
407+
showLegacyExportTooltip={
408+
showLegacyExportTooltip && !isExportSchemaModalOpen
409+
}
410+
setShowLegacyExportTooltip={setShowLegacyExportTooltip}
422411
isOutdated={!!outdated}
423-
sampleSize={schema ? schema.count : 0}
424-
schemaResultId={resultId || ''}
425412
/>
426413
}
427414
>
@@ -440,22 +427,24 @@ const Schema: React.FunctionComponent<{
440427
</WorkspaceContainer>
441428
</div>
442429
{enableExportSchema && <ExportSchemaModal />}
443-
{enableExportSchema && <ExportSchemaLegacyBanner />}
430+
{enableExportSchema && (
431+
<ExportSchemaLegacyModal
432+
setShowLegacyExportTooltip={setShowLegacyExportTooltip}
433+
/>
434+
)}
444435
</>
445436
);
446437
};
447438

448439
export default connect(
449440
(state: RootState) => ({
450441
analysisState: state.schemaAnalysis.analysisState,
451-
error: state.schemaAnalysis.error,
442+
isExportSchemaModalOpen: state.schemaExport.isOpen,
452443
schema: state.schemaAnalysis.schema,
453-
resultId: state.schemaAnalysis.resultId,
454444
}),
455445
{
456446
onStartAnalysis: startAnalysis,
457447
onStopAnalysis: () => stopAnalysis(),
458448
onExportSchemaClicked: openExportSchema,
459-
onDismissError: analysisErrorDismissed,
460449
}
461450
)(Schema);

packages/compass-schema/src/components/export-schema-legacy-banner.tsx renamed to packages/compass-schema/src/components/export-schema-legacy-modal.tsx

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
confirmedExportLegacySchemaToClipboard,
1717
switchToSchemaExport,
1818
SchemaExportActions,
19-
stopShowingLegacyBanner,
19+
stopShowingLegacyModal,
2020
} from '../stores/schema-export-reducer';
2121

2222
const SchemaExportSVG = () => (
@@ -463,28 +463,42 @@ const optionHeaderStyles = css({
463463
margin: '0px',
464464
});
465465

466-
const ExportSchemaLegacyBanner: React.FunctionComponent<{
466+
const ExportSchemaLegacyModal: React.FunctionComponent<{
467467
isOpen: boolean;
468468
onClose: () => void;
469469
onLegacyShare: () => void;
470470
onSwitchToSchemaExport: () => void;
471-
stopShowingLegacyBanner: (choice: 'legacy' | 'export') => void;
471+
setShowLegacyExportTooltip: (show: boolean) => void;
472+
stopShowingLegacyModal: (choice: 'legacy' | 'export') => void;
472473
}> = ({
473474
isOpen,
474475
onClose,
475476
onLegacyShare,
476477
onSwitchToSchemaExport,
477-
stopShowingLegacyBanner,
478+
setShowLegacyExportTooltip,
479+
stopShowingLegacyModal,
478480
}) => {
479481
const [dontShowAgainChecked, setDontShowAgainChecked] = useState(false);
480482
const handleLegacyShare = useCallback(() => {
481-
if (dontShowAgainChecked) stopShowingLegacyBanner('legacy');
483+
if (dontShowAgainChecked) stopShowingLegacyModal('legacy');
482484
onLegacyShare();
483-
}, [onLegacyShare, dontShowAgainChecked, stopShowingLegacyBanner]);
485+
setShowLegacyExportTooltip(true);
486+
}, [
487+
onLegacyShare,
488+
dontShowAgainChecked,
489+
stopShowingLegacyModal,
490+
setShowLegacyExportTooltip,
491+
]);
484492
const handleSwitchToNew = useCallback(() => {
485-
if (dontShowAgainChecked) stopShowingLegacyBanner('export');
493+
if (dontShowAgainChecked) stopShowingLegacyModal('export');
494+
setShowLegacyExportTooltip(true);
486495
onSwitchToSchemaExport();
487-
}, [onSwitchToSchemaExport, dontShowAgainChecked, stopShowingLegacyBanner]);
496+
}, [
497+
onSwitchToSchemaExport,
498+
dontShowAgainChecked,
499+
stopShowingLegacyModal,
500+
setShowLegacyExportTooltip,
501+
]);
488502
return (
489503
<Modal open={isOpen} setOpen={onClose} contentClassName={containerStyles}>
490504
<ModalHeader
@@ -535,13 +549,13 @@ const ExportSchemaLegacyBanner: React.FunctionComponent<{
535549

536550
export default connect(
537551
(state: RootState) => ({
538-
isOpen: state.schemaExport.isLegacyBannerOpen,
552+
isOpen: state.schemaExport.isLegacyModalOpen,
539553
}),
540554
(dispatch: SchemaThunkDispatch) => ({
541-
onClose: () => dispatch({ type: SchemaExportActions.closeLegacyBanner }),
555+
onClose: () => dispatch({ type: SchemaExportActions.closeLegacyModal }),
542556
onLegacyShare: () => dispatch(confirmedExportLegacySchemaToClipboard()),
543557
onSwitchToSchemaExport: () => dispatch(switchToSchemaExport()),
544-
stopShowingLegacyBanner: (choice: 'legacy' | 'export') =>
545-
dispatch(stopShowingLegacyBanner(choice)),
558+
stopShowingLegacyModal: (choice: 'legacy' | 'export') =>
559+
dispatch(stopShowingLegacyModal(choice)),
546560
})
547-
)(ExportSchemaLegacyBanner);
561+
)(ExportSchemaLegacyModal);

0 commit comments

Comments
 (0)