Skip to content

Commit 619dbc2

Browse files
Merge remote-tracking branch 'origin/main' into beta-releases
2 parents cc54d9d + c1eb3c8 commit 619dbc2

File tree

279 files changed

+7503
-7668
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

279 files changed

+7503
-7668
lines changed

THIRD-PARTY-NOTICES.md

Lines changed: 776 additions & 469 deletions
Large diffs are not rendered by default.

package-lock.json

Lines changed: 2120 additions & 1328 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/atlas-service/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"depcheck": "^1.4.1",
6666
"eslint": "^7.25.0",
6767
"mocha": "^10.2.0",
68-
"mongodb": "^6.0.0",
68+
"mongodb": "^6.3.0",
6969
"mongodb-schema": "^12.1.0",
7070
"nyc": "^15.1.0",
7171
"prettier": "^2.7.1",

packages/compass-aggregations/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"@mongodb-js/mongodb-constants": "^0.8.7",
5050
"@mongodb-js/mongodb-redux-common": "^2.0.15",
5151
"@mongodb-js/my-queries-storage": "^0.2.1",
52-
"bson": "^6.0.0",
52+
"bson": "^6.2.0",
5353
"compass-preferences-model": "^2.15.6",
5454
"hadron-app-registry": "^9.0.14",
5555
"hadron-document": "^8.4.3",
@@ -75,14 +75,14 @@
7575
"@types/semver": "^7.3.9",
7676
"chai": "^4.3.6",
7777
"depcheck": "^1.4.1",
78-
"ejson-shell-parser": "^1.2.4",
78+
"ejson-shell-parser": "^2.0.0",
7979
"enzyme": "^3.11.0",
8080
"eslint": "^7.25.0",
8181
"lodash": "^4.17.21",
8282
"mocha": "^10.2.0",
83-
"mongodb": "^6.0.0",
83+
"mongodb": "^6.3.0",
8484
"mongodb-ns": "^2.4.0",
85-
"mongodb-query-parser": "^3.1.3",
85+
"mongodb-query-parser": "^4.0.0",
8686
"mongodb-schema": "^12.0.0",
8787
"nyc": "^15.1.0",
8888
"prettier": "^2.7.1",
@@ -109,7 +109,7 @@
109109
"@mongodb-js/mongodb-constants": "^0.8.7",
110110
"@mongodb-js/mongodb-redux-common": "^2.0.15",
111111
"@mongodb-js/my-queries-storage": "^0.2.1",
112-
"bson": "^6.0.0",
112+
"bson": "^6.2.0",
113113
"compass-preferences-model": "^2.15.6",
114114
"hadron-app-registry": "^9.0.13",
115115
"hadron-document": "^8.4.3",

packages/compass-aggregations/src/components/aggregation-side-panel/stage-wizard-use-cases/use-case-card.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export const UseCaseCardLayout = React.forwardRef(function UseCaseCardLayout(
7979
onKeyDown={handleKeyDown}
8080
{...props}
8181
>
82-
<Body data-testid={`use-case-${id}`} className={cardBodyStyles}>
82+
<Body as="div" data-testid={`use-case-${id}`} className={cardBodyStyles}>
8383
{title} <Badge>{stageOperator}</Badge>
8484
</Body>
8585
</KeylineCard>

packages/compass-aggregations/src/components/focus-mode/focus-mode-stage-preview.spec.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { type ComponentProps } from 'react';
2+
import HadronDocument from 'hadron-document';
23
import type { Document } from 'mongodb';
34
import { render, screen, within } from '@testing-library/react';
45
import { expect } from 'chai';
@@ -34,6 +35,8 @@ const renderFocusModePreview = (
3435
stageOperator={null}
3536
documents={null}
3637
isMissingAtlasOnlyStageSupport={false}
38+
onExpand={() => {}}
39+
onCollapse={() => {}}
3740
{...props}
3841
/>
3942
</Provider>
@@ -42,14 +45,14 @@ const renderFocusModePreview = (
4245

4346
describe('FocusModeStagePreview', function () {
4447
it('renders stage input', function () {
45-
render(<InputPreview />);
48+
render(<InputPreview onExpand={() => {}} onCollapse={() => {}} />);
4649
const preview = screen.getByTestId('focus-mode-stage-preview');
4750
expect(preview).to.exist;
4851
expect(within(preview).getByText(/stage input/i)).to.exist;
4952
});
5053

5154
it('renders stage output', function () {
52-
render(<OutputPreview />);
55+
render(<OutputPreview onExpand={() => {}} onCollapse={() => {}} />);
5356
const preview = screen.getByTestId('focus-mode-stage-preview');
5457
expect(preview).to.exist;
5558
expect(within(preview).getByText(/stage output/i)).to.exist;
@@ -67,7 +70,10 @@ describe('FocusModeStagePreview', function () {
6770
it('renders list of documents', function () {
6871
renderFocusModePreview({
6972
isLoading: false,
70-
documents: [{ _id: 12345 }, { _id: 54321 }],
73+
documents: [
74+
new HadronDocument({ _id: 12345 }),
75+
new HadronDocument({ _id: 54321 }),
76+
],
7177
});
7278
const preview = screen.getByTestId('focus-mode-stage-preview');
7379
expect(within(preview).getByText(/12345/i)).to.exist;

packages/compass-aggregations/src/components/focus-mode/focus-mode-stage-preview.tsx

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import React, { useState } from 'react';
1+
import React, { useCallback } from 'react';
22
import {
33
Body,
44
css,
55
SpinLoader,
66
spacing,
77
Overline,
88
} from '@mongodb-js/compass-components';
9-
import type { Document } from 'mongodb';
9+
import type HadronDocument from 'hadron-document';
1010
import { DocumentListView } from '@mongodb-js/compass-crud';
1111
import { PipelineOutputOptionsMenu } from '../pipeline-output-options-menu';
1212
import type { PipelineOutputOption } from '../pipeline-output-options-menu';
@@ -19,6 +19,10 @@ import {
1919
isMissingAtlasStageSupport,
2020
isOutputStage,
2121
} from '../../utils/stage';
22+
import {
23+
collapsePreviewDocsForStage,
24+
expandPreviewDocsForStage,
25+
} from '../../modules/pipeline-builder/stage-editor';
2226
import type { StoreStage } from '../../modules/pipeline-builder/stage-editor';
2327

2428
const containerStyles = css({
@@ -73,10 +77,12 @@ const loaderStyles = css({
7377
type FocusModePreviewProps = {
7478
title: string;
7579
isLoading?: boolean;
76-
documents?: Document[] | null;
80+
documents?: HadronDocument[] | null;
7781
stageIndex?: number;
7882
stageOperator?: string | null;
7983
isMissingAtlasOnlyStageSupport?: boolean;
84+
onExpand: (stageIdx: number) => void;
85+
onCollapse: (stageIdx: number) => void;
8086
};
8187

8288
export const FocusModePreview = ({
@@ -86,10 +92,24 @@ export const FocusModePreview = ({
8692
stageIndex = -1,
8793
stageOperator = '',
8894
isMissingAtlasOnlyStageSupport = false,
95+
onExpand,
96+
onCollapse,
8997
}: FocusModePreviewProps) => {
90-
const [pipelineOutputOption, setPipelineOutputOption] =
91-
useState<PipelineOutputOption>('collapse');
92-
const isExpanded = pipelineOutputOption === 'expand';
98+
const copyToClipboard = useCallback((doc: HadronDocument) => {
99+
const str = doc.toEJSON();
100+
void navigator.clipboard.writeText(str);
101+
}, []);
102+
103+
const handlePipelineOutputOptionChanged = useCallback(
104+
(option: PipelineOutputOption) => {
105+
if (option === 'expand') {
106+
onExpand(stageIndex);
107+
} else if (option === 'collapse') {
108+
onCollapse(stageIndex);
109+
}
110+
},
111+
[onExpand, onCollapse, stageIndex]
112+
);
93113

94114
const docCount = documents?.length ?? 0;
95115
const docText = docCount === 1 ? 'document' : 'documents';
@@ -123,13 +143,9 @@ export const FocusModePreview = ({
123143
} else if (documents && documents.length > 0) {
124144
content = (
125145
<DocumentListView
126-
docs={documents}
127-
copyToClipboard={(doc) => {
128-
const str = doc.toEJSON();
129-
void navigator.clipboard.writeText(str);
130-
}}
131146
isEditable={false}
132-
isExpanded={isExpanded}
147+
docs={documents ?? []}
148+
copyToClipboard={copyToClipboard}
133149
className={documentListStyles}
134150
/>
135151
);
@@ -156,8 +172,7 @@ export const FocusModePreview = ({
156172
{isPipelineOptionsMenuVisible && (
157173
<PipelineOutputOptionsMenu
158174
buttonText="Options"
159-
option={pipelineOutputOption}
160-
onChangeOption={setPipelineOutputOption}
175+
onChangeOption={handlePipelineOutputOptionChanged}
161176
/>
162177
)}
163178
</div>
@@ -228,6 +243,10 @@ export const FocusModeStageInput = connect(
228243
stageOperator: previousStage.stageOperator,
229244
isMissingAtlasOnlyStageSupport,
230245
};
246+
},
247+
{
248+
onExpand: expandPreviewDocsForStage,
249+
onCollapse: collapsePreviewDocsForStage,
231250
}
232251
)(InputPreview);
233252

@@ -256,5 +275,9 @@ export const FocusModeStageOutput = connect(
256275
stageOperator: stage.stageOperator,
257276
isMissingAtlasOnlyStageSupport,
258277
};
278+
},
279+
{
280+
onExpand: expandPreviewDocsForStage,
281+
onCollapse: collapsePreviewDocsForStage,
259282
}
260283
)(OutputPreview);

packages/compass-aggregations/src/components/pipeline-builder-workspace/pipeline-as-text-workspace/pipeline-preview.spec.tsx

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import userEvent from '@testing-library/user-event';
88
import configureStore from '../../../../test/configure-store';
99

1010
import { PipelinePreview } from './pipeline-preview';
11+
import HadronDocument from 'hadron-document';
1112

1213
const renderPipelineEditor = (
1314
props: Partial<ComponentProps<typeof PipelinePreview>> = {},
@@ -23,6 +24,8 @@ const renderPipelineEditor = (
2324
previewDocs={null}
2425
isMissingAtlasSupport={false}
2526
atlasOperator=""
27+
onExpand={() => {}}
28+
onCollapse={() => {}}
2629
{...props}
2730
/>
2831
</Provider>
@@ -56,7 +59,11 @@ describe('PipelinePreview', function () {
5659
});
5760

5861
it('renders document list', function () {
59-
renderPipelineEditor({ previewDocs: [{ _id: 1 }, { _id: 2 }] });
62+
renderPipelineEditor({
63+
previewDocs: [{ _id: 1 }, { _id: 2 }].map(
64+
(doc) => new HadronDocument(doc)
65+
),
66+
});
6067
const container = screen.getByTestId('pipeline-as-text-preview');
6168
expect(
6269
container.querySelectorAll('[data-testid="document-list-item"]')
@@ -65,7 +72,7 @@ describe('PipelinePreview', function () {
6572

6673
it('renders pipeline output menu', function () {
6774
const previewDocs = [
68-
{
75+
new HadronDocument({
6976
_id: 1,
7077
score: [
7178
{ number: 1 },
@@ -79,9 +86,17 @@ describe('PipelinePreview', function () {
7986
},
8087
},
8188
],
82-
},
89+
}),
8390
];
84-
renderPipelineEditor({ previewDocs });
91+
renderPipelineEditor({
92+
previewDocs,
93+
onExpand: () => {
94+
previewDocs[0].expand();
95+
},
96+
onCollapse: () => {
97+
previewDocs[0].collapse();
98+
},
99+
});
85100

86101
const docList = screen.getByTestId('document-list-item');
87102

@@ -138,7 +153,9 @@ describe('PipelinePreview', function () {
138153
it('renders output stage preview', function () {
139154
renderPipelineEditor(
140155
{
141-
previewDocs: [{ _id: 1 }, { _id: 2 }, { _id: 3 }],
156+
previewDocs: [{ _id: 1 }, { _id: 2 }, { _id: 3 }].map(
157+
(doc) => new HadronDocument(doc)
158+
),
142159
isOutStage: true,
143160
},
144161
{
@@ -175,7 +192,10 @@ describe('PipelinePreview', function () {
175192
});
176193

177194
it('renders stale banner when preview is stale', function () {
178-
renderPipelineEditor({ isPreviewStale: true, previewDocs: [{ _id: 1 }] });
195+
renderPipelineEditor({
196+
isPreviewStale: true,
197+
previewDocs: [new HadronDocument({ _id: 1 })],
198+
});
179199
expect(screen.getByText(staleMessage)).to.exist;
180200
});
181201
});

0 commit comments

Comments
 (0)