Skip to content

Commit e8cae50

Browse files
fix: make $out options more clear in agg pipeline builder COMPASS-6304 (#3913)
1 parent 8c43268 commit e8cae50

File tree

7 files changed

+44
-53
lines changed

7 files changed

+44
-53
lines changed

package-lock.json

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

packages/compass-aggregations/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"@mongodb-js/compass-logging": "^1.1.1",
4444
"@mongodb-js/compass-utils": "^0.1.2",
4545
"@mongodb-js/explain-plan-helper": "^1.0.1",
46-
"@mongodb-js/mongodb-constants": "^0.1.4",
46+
"@mongodb-js/mongodb-constants": "^0.1.5",
4747
"@mongodb-js/mongodb-redux-common": "^2.0.3",
4848
"bson": "^4.4.1",
4949
"compass-preferences-model": "^2.4.0",
@@ -99,7 +99,7 @@
9999
"@mongodb-js/compass-logging": "^1.1.1",
100100
"@mongodb-js/compass-utils": "^0.1.2",
101101
"@mongodb-js/explain-plan-helper": "^1.0.1",
102-
"@mongodb-js/mongodb-constants": "^0.1.4",
102+
"@mongodb-js/mongodb-constants": "^0.1.5",
103103
"@mongodb-js/mongodb-redux-common": "^2.0.3",
104104
"bson": "^4.4.1",
105105
"compass-preferences-model": "^2.4.0",

packages/compass-aggregations/src/components/stage-editor-toolbar/stage-operator-select.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ function EnvAwareStageOperatorSelect({
152152
serverVersion,
153153
env,
154154
isTimeSeries,
155-
isReadonly,
156155
preferencesReadOnly,
157156
sourceName
158157
});

packages/compass-aggregations/src/utils/stage.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ export function isAtlasOnly(operatorEnv) {
3737
return operatorEnv?.every(env => env === ATLAS);
3838
}
3939

40-
function disallowOutputStagesOnCompassReadonly(operator, isEditable) {
40+
function disallowOutputStagesOnCompassReadonly(operator, preferencesReadOnly) {
4141
if (operator?.outputStage) {
42-
return isEditable;
42+
return !preferencesReadOnly;
4343
}
4444

4545
return true;
@@ -56,7 +56,7 @@ function disallowOutputStagesOnCompassReadonly(operator, isEditable) {
5656
*
5757
* @returns {Array} Stage operators supported by the current version of the server.
5858
*/
59-
export const filterStageOperators = ({ serverVersion, env, isTimeSeries, sourceName, isReadonly, preferencesReadOnly }) => {
59+
export const filterStageOperators = ({ serverVersion, env, isTimeSeries, sourceName, preferencesReadOnly }) => {
6060
const namespaceType =
6161
isTimeSeries ? TIME_SERIES :
6262

@@ -65,9 +65,8 @@ export const filterStageOperators = ({ serverVersion, env, isTimeSeries, sourceN
6565
sourceName ? VIEW :
6666
COLLECTION;
6767

68-
const isEditable = !isReadonly && !preferencesReadOnly;
6968
return STAGE_OPERATORS
70-
.filter((op) => disallowOutputStagesOnCompassReadonly(op, isEditable))
69+
.filter((op) => disallowOutputStagesOnCompassReadonly(op, preferencesReadOnly))
7170
.filter((op) => supportsVersion(op, serverVersion))
7271
.filter((op) => supportsNamespace(op, namespaceType))
7372

packages/compass-aggregations/src/utils/stage.spec.js

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ describe('utils', function() {
66
const defaultFilter = {
77
env: 'on-prem',
88
isTimeSeries: false,
9-
isReadonly: false,
109
preferencesReadOnly: false,
1110
sourceName: null,
1211
serverVersion: '4.2.0'
@@ -79,7 +78,7 @@ describe('utils', function() {
7978
});
8079

8180
it('does not return full-text search stages for views', function() {
82-
const searchStages = filterStageOperators({ ...filter, isReadonly: true, sourceName: 'simple.sample' })
81+
const searchStages = filterStageOperators({ ...filter, sourceName: 'simple.sample' })
8382
.filter((o) => (['$search', '$searchMeta', '$documents'].includes(o.name)));
8483

8584
expect(searchStages.length).to.be.equal(0);
@@ -119,30 +118,24 @@ describe('utils', function() {
119118
});
120119

121120
context('when is not a read-only distribution of Compass', function() {
122-
it('returns output stages if isReadonly is false', function() {
123-
const searchStages = filterStageOperators({ ...defaultFilter, env: 'adl', serverVersion: '6.0.0', isReadonly: false })
124-
.filter((o) => (['$out', '$merge'].includes(o.name)));
125-
126-
expect(searchStages.length).to.be.equal(2);
127-
});
128-
129-
it('returns output stages if isReadonly is undefined', function() {
130-
const searchStages = filterStageOperators({ ...defaultFilter, env: 'adl', serverVersion: '6.0.0' })
121+
it('returns output stages', function() {
122+
const searchStages = filterStageOperators({ ...defaultFilter, env: 'adl', serverVersion: '6.0.0', preferencesReadOnly: false })
131123
.filter((o) => (['$out', '$merge'].includes(o.name)));
132124

133125
expect(searchStages.length).to.be.equal(2);
134126
});
135127
});
136128

137129
context('when is a read-only distribution of Compass', function() {
138-
it('filters out output stages if isEditable is true', function() {
130+
it('filters out output stages', function() {
139131
const searchStages = filterStageOperators({ ...defaultFilter, env: 'adl', serverVersion: '6.0.0', preferencesReadOnly: true })
140132
.filter((o) => (['$out', '$merge'].includes(o.name)));
141133

142134
expect(searchStages.length).to.be.equal(0);
143135
});
144136
});
145137
});
138+
146139
context('findAtlasOperator', function() {
147140
it('returns atlas only stage operator', function() {
148141
expect(

packages/compass-editor/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
},
6666
"dependencies": {
6767
"@mongodb-js/compass-components": "^1.4.0",
68-
"@mongodb-js/mongodb-constants": "^0.1.4",
68+
"@mongodb-js/mongodb-constants": "^0.1.5",
6969
"ace-builds": "^1.11.2",
7070
"react": "^16.14.0",
7171
"react-ace": "^9.5.0",

packages/compass-query-bar/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"@mongodb-js/compass-components": "^1.4.0",
6161
"@mongodb-js/compass-editor": "^0.3.0",
6262
"@mongodb-js/compass-logging": "^1.1.1",
63-
"@mongodb-js/mongodb-constants": "^0.1.4",
63+
"@mongodb-js/mongodb-constants": "^0.1.5",
6464
"compass-preferences-model": "^2.4.0",
6565
"react": "^16.14.0"
6666
},
@@ -98,7 +98,7 @@
9898
"@mongodb-js/compass-components": "^1.4.0",
9999
"@mongodb-js/compass-editor": "^0.3.0",
100100
"@mongodb-js/compass-logging": "^1.1.1",
101-
"@mongodb-js/mongodb-constants": "^0.1.4",
101+
"@mongodb-js/mongodb-constants": "^0.1.5",
102102
"compass-preferences-model": "^2.4.0",
103103
"react": "^16.14.0"
104104
}

0 commit comments

Comments
 (0)