Skip to content

Commit 61173bc

Browse files
committed
Merge branch 'main' into 1.31-releases
2 parents add0195 + cc8ddc4 commit 61173bc

File tree

92 files changed

+1825
-414
lines changed

Some content is hidden

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

92 files changed

+1825
-414
lines changed

configs/webpack-config-compass/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
lessLoader,
2020
assetsLoader,
2121
resourceLoader,
22+
sharedObjectLoader,
2223
} from './loaders';
2324
import {
2425
entriesToNamedEntries,
@@ -58,6 +59,7 @@ export function createElectronMainConfig(
5859
javascriptLoader(opts),
5960
nodeLoader(opts),
6061
resourceLoader(opts),
62+
sharedObjectLoader(opts),
6163
sourceLoader(opts),
6264
],
6365
},
@@ -124,6 +126,7 @@ export function createElectronRendererConfig(
124126
cssLoader(opts),
125127
lessLoader(opts),
126128
assetsLoader(opts),
129+
sharedObjectLoader(opts),
127130
sourceLoader(opts),
128131
],
129132
},

configs/webpack-config-compass/src/loaders.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,23 @@ export const resourceLoader = (_args: ConfigArgs) => ({
162162
type: 'asset/resource',
163163
});
164164

165+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
166+
export const sharedObjectLoader = (_args: ConfigArgs) => ({
167+
test: /\.(dylib|so|dll)(\?.+?)?$/,
168+
// asset/resource always compiles imports to paths to files, this is a good
169+
// strategy for electron main (node.js) process where handling data uris might
170+
// be more work than handling files
171+
type: 'asset/resource',
172+
});
173+
165174
export const sourceLoader = (args: ConfigArgs) => ({
166175
exclude: [
167176
javascriptLoader(args).test,
168177
nodeLoader(args).test,
169178
cssLoader(args).test,
170179
lessLoader(args).test,
171180
assetsLoader(args).test,
181+
sharedObjectLoader(args).test,
172182
// Produced by html-webpack-plugin and should not be handled
173183
/\.(ejs|html)$/,
174184
// Handled nicely by Webpack by default, no need to load it as raw source

package-lock.json

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

packages/compass-aggregations/src/components/pipeline-builder-workspace/pipeline-builder-workspace.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ class PipelineWorkspace extends PureComponent {
104104
sourceName={this.props.sourceName}
105105
stage={stage.stage}
106106
stageOperator={stage.stageOperator}
107-
snippet={stage.snippet}
108107
error={stage.error}
109108
syntaxError={stage.syntaxError}
110109
isValid={stage.isValid}
@@ -115,7 +114,6 @@ class PipelineWorkspace extends PureComponent {
115114
isExpanded={stage.isExpanded}
116115
isCommenting={this.props.isCommenting}
117116
isAutoPreviewing={this.props.isAutoPreviewing}
118-
fromStageOperators={stage.fromStageOperators || false}
119117
previewDocuments={stage.previewDocuments}
120118
runStage={this.props.runStage}
121119
openLink={this.props.openLink}

packages/compass-aggregations/src/components/pipeline-builder-workspace/pipeline-builder-workspace.spec.jsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ const PIPELINE_1 = [
1818
'syntaxError': null,
1919
'error': null,
2020
'projections': [],
21-
'snippet': '/**\n * query: The query in MQL.\n */\n{\n ${1:query}\n}',
22-
'fromStageOperators': false,
2321
'executor': {
2422
'$match': {
2523
'x': 1
@@ -39,8 +37,6 @@ const PIPELINE_1 = [
3937
'syntaxError': null,
4038
'error': null,
4139
'projections': [],
42-
'snippet': '/**\n * Provide the number of documents to limit.\n */\n${1:number}',
43-
'fromStageOperators': false,
4440
'executor': {
4541
'$limit': 3
4642
}

packages/compass-aggregations/src/components/stage-editor/stage-editor.jsx

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import { StageAutoCompleter } from 'mongodb-ace-autocompleter';
66

77
import styles from './stage-editor.module.less';
88

9-
const INDEX_STATS = '$indexStats';
10-
119
/**
1210
* Edit a single stage in the aggregation pipeline.
1311
*/
@@ -17,7 +15,6 @@ class StageEditor extends Component {
1715
static propTypes = {
1816
stage: PropTypes.string,
1917
stageOperator: PropTypes.string,
20-
snippet: PropTypes.string,
2118
error: PropTypes.string,
2219
syntaxError: PropTypes.string,
2320
runStage: PropTypes.func.isRequired,
@@ -27,7 +24,6 @@ class StageEditor extends Component {
2724
stageChanged: PropTypes.func.isRequired,
2825
isAutoPreviewing: PropTypes.bool.isRequired,
2926
isValid: PropTypes.bool.isRequired,
30-
fromStageOperators: PropTypes.bool.isRequired,
3127
setIsModified: PropTypes.func.isRequired,
3228
projections: PropTypes.array.isRequired,
3329
projectionsChanged: PropTypes.func.isRequired,
@@ -76,8 +72,6 @@ class StageEditor extends Component {
7672
}
7773

7874
/**
79-
* On update if the stage operator is changed insert the snippet and focus on the editor.
80-
*
8175
* @param {Object} prevProps - The previous properties.
8276
*/
8377
componentDidUpdate(prevProps) {
@@ -87,9 +81,13 @@ class StageEditor extends Component {
8781
);
8882
this.completer.version = this.props.serverVersion;
8983
if (this.props.stageOperator !== prevProps.stageOperator && this.editor) {
90-
this.editor.setValue('');
91-
this.editor.insertSnippet(this.props.snippet || '');
84+
// Focus the editor when the stage operator has changed.
9285
this.editor.focus();
86+
87+
// When the underlying stage operator changes, re-run the preview.
88+
if (this.props.isAutoPreviewing) {
89+
this.debounceRun();
90+
}
9391
}
9492
}
9593

@@ -110,11 +108,7 @@ class StageEditor extends Component {
110108
this.props.projectionsChanged();
111109
this.props.setIsModified(true);
112110

113-
if (
114-
(this.props.fromStageOperators === false ||
115-
this.props.stageOperator === INDEX_STATS) &&
116-
this.props.isAutoPreviewing
117-
) {
111+
if (this.props.isAutoPreviewing) {
118112
this.debounceRun();
119113
}
120114
};

packages/compass-aggregations/src/components/stage-editor/stage-editor.spec.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ describe('StageEditor [Component]', function() {
2525
isValid={isValid}
2626
index={0}
2727
isAutoPreviewing
28-
fromStageOperators={false}
2928
fields={[]}
3029
serverVersion="3.6.0"
3130
runStage={runStageSpy}

packages/compass-aggregations/src/components/stage/stage.jsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ class Stage extends Component {
5050
sourceName: PropTypes.string,
5151
stage: PropTypes.string.isRequired,
5252
stageOperator: PropTypes.string,
53-
snippet: PropTypes.string,
5453
error: PropTypes.string,
5554
syntaxError: PropTypes.string,
5655
isValid: PropTypes.bool.isRequired,
@@ -60,7 +59,6 @@ class Stage extends Component {
6059
isComplete: PropTypes.bool.isRequired,
6160
// Can be undefined on the initial render
6261
isMissingAtlasOnlyStageSupport: PropTypes.bool,
63-
fromStageOperators: PropTypes.bool.isRequired,
6462
previewDocuments: PropTypes.array.isRequired,
6563
index: PropTypes.number.isRequired,
6664
isCommenting: PropTypes.bool.isRequired,
@@ -89,7 +87,6 @@ class Stage extends Component {
8987
shouldComponentUpdate(nextProps) {
9088
const should = (
9189
nextProps.stageOperator !== this.props.stageOperator ||
92-
nextProps.snippet !== this.props.snippet ||
9390
nextProps.error !== this.props.error ||
9491
nextProps.syntaxError !== this.props.syntaxError ||
9592
nextProps.isValid !== this.props.isValid ||
@@ -98,7 +95,6 @@ class Stage extends Component {
9895
nextProps.isLoading !== this.props.isLoading ||
9996
nextProps.isComplete !== this.props.isComplete ||
10097
nextProps.isMissingAtlasOnlyStageSupport !== this.props.isMissingAtlasOnlyStageSupport ||
101-
nextProps.fromStageOperators !== this.props.fromStageOperators ||
10298
nextProps.index !== this.props.index ||
10399
nextProps.isCommenting !== this.props.isCommenting ||
104100
nextProps.isAutoPreviewing !== this.props.isAutoPreviewing ||
@@ -150,11 +146,9 @@ class Stage extends Component {
150146
<StageEditor
151147
stage={this.props.stage}
152148
stageOperator={this.props.stageOperator}
153-
snippet={this.props.snippet}
154149
error={this.props.error}
155150
syntaxError={this.props.syntaxError}
156151
isValid={this.props.isValid}
157-
fromStageOperators={this.props.fromStageOperators}
158152
runStage={this.props.runStage}
159153
index={this.props.index}
160154
serverVersion={this.props.serverVersion}

packages/compass-aggregations/src/modules/pipeline.spec.js

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import _reducer, {
1717
STAGE_PREVIEW_UPDATED,
1818
LOADING_STAGE_RESULTS,
1919
STAGE_TOGGLED,
20-
replaceAceTokens,
20+
replaceOperatorSnippetTokens,
2121
INITIAL_STATE,
2222
} from './pipeline';
2323
import { generatePipelineStages } from './pipeline';
@@ -120,11 +120,7 @@ describe('pipeline module', function () {
120120
expect(
121121
newState[0].stage,
122122
`${name} stage on ${env} env.`
123-
).to.equal(`${comment}${snippet}`);
124-
expect(
125-
newState[0].snippet,
126-
`${name} snippet on ${env} env.`
127-
).to.equal(`${comment}${snippet}`);
123+
).to.equal(replaceOperatorSnippetTokens(`${comment}${snippet}`));
128124
});
129125
});
130126
});
@@ -134,8 +130,7 @@ describe('pipeline module', function () {
134130
);
135131
const stage = {
136132
stageOperator: geoNear.name,
137-
stage: replaceAceTokens(`${geoNear.comment}${geoNear.snippet}`),
138-
snippet: `${geoNear.comment}${geoNear.snippet}`,
133+
stage: replaceOperatorSnippetTokens(`${geoNear.comment}${geoNear.snippet}`),
139134
};
140135
STAGE_OPERATORS.filter((x) => x.name !== '$geoNear').forEach(
141136
({ name, comment, snippet, env: envs }) => {
@@ -151,11 +146,7 @@ describe('pipeline module', function () {
151146
expect(
152147
newState[0].stage,
153148
`${name} stage on ${env} env.`
154-
).to.equal(`${comment}${snippet}`);
155-
expect(
156-
newState[0].snippet,
157-
`${name} snippet on ${env} env.`
158-
).to.equal(`${comment}${snippet}`);
149+
).to.equal(replaceOperatorSnippetTokens(`${comment}${snippet}`));
159150
});
160151
}
161152
);
@@ -165,7 +156,6 @@ describe('pipeline module', function () {
165156
const stage = {
166157
stageOperator: limit.name,
167158
stage: '20',
168-
snippet: `${limit.comment}${limit.snippet}`,
169159
};
170160
STAGE_OPERATORS.filter((x) => x.name !== '$limit').forEach(
171161
({ name, env: envs }) => {
@@ -182,10 +172,6 @@ describe('pipeline module', function () {
182172
newState[0].stage,
183173
`${name} stage on ${env} env.`
184174
).to.equal('20');
185-
expect(
186-
newState[0].snippet,
187-
`${name} snippet on ${env} env.`
188-
).to.equal('20');
189175
});
190176
}
191177
);

0 commit comments

Comments
 (0)