Skip to content

Commit b8997c8

Browse files
committed
Remove feature flag shortcuts from query bar (#1303)
1 parent 5071438 commit b8997c8

File tree

3 files changed

+1
-74
lines changed

3 files changed

+1
-74
lines changed

src/app/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
https://app.getsentry.com
3333
https://*.google-analytics.com;
3434
child-src
35+
blob:
3536
https://share.intercom.io
3637
https://www.youtube.com
3738
https://player.vimeo.com

src/internal-plugins/query/lib/store/query-store.js

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ const debug = require('debug')('mongodb-compass:stores:query');
1515
// constants
1616
const USER_TYPING_DEBOUNCE_MS = 100;
1717

18-
const FEATURE_FLAG_REGEX = /^(enable|disable) (\w+)\s*$/;
1918
const RESET_STATE = 'reset';
2019
const APPLY_STATE = 'apply';
2120

@@ -40,17 +39,6 @@ const QueryStore = Reflux.createStore({
4039
mixins: [StateMixin.store],
4140
listenables: QueryAction,
4241

43-
init: function() {
44-
// store valid feature flags to recognise in the filter box
45-
if (_.get(app.preferences, 'serialize')) {
46-
this.validFeatureFlags = _.keys(
47-
_.pick(app.preferences.serialize(), _.isBoolean)
48-
);
49-
} else {
50-
this.validFeatureFlags = [];
51-
}
52-
},
53-
5442
onActivated(appRegistry) {
5543
this.QueryHistoryActions = appRegistry.getAction('QueryHistory.Actions');
5644
this.QueryHistoryActions.runQuery.listen(this.autoPopulateQuery.bind(this));
@@ -123,9 +111,6 @@ const QueryStore = Reflux.createStore({
123111
// query history view.
124112
autoPopulated: false,
125113

126-
// was a feature flag recognised in the input
127-
featureFlag: false,
128-
129114
// is the query bar component expanded or collapsed?
130115
expanded: false,
131116

@@ -215,10 +200,8 @@ const QueryStore = Reflux.createStore({
215200
setQueryString(label, input, userTyping) {
216201
assert(_.includes(QUERY_PROPERTIES, label));
217202
const validatedInput = this._validateInput(label, input);
218-
const isFeatureFlag = Boolean(this._validateFeatureFlag(input));
219203

220204
const state = {
221-
featureFlag: isFeatureFlag,
222205
userTyping: Boolean(userTyping)
223206
};
224207
state[`${label}String`] = input;
@@ -305,7 +288,6 @@ const QueryStore = Reflux.createStore({
305288
if (_.has(query, 'sample')) {
306289
this.toggleSample(query.sample);
307290
}
308-
state.featureFlag = false;
309291
state.autoPopulated = autoPopulated;
310292
state.valid = valid;
311293
this.setState(state);
@@ -359,37 +341,6 @@ const QueryStore = Reflux.createStore({
359341
);
360342
},
361343

362-
/**
363-
* validates if the input is a feature flag directive.
364-
*
365-
* @param {String} input The input to validate.
366-
*
367-
* @return {Boolean|MatchGroup} the regex match or false if invalid.
368-
*/
369-
_validateFeatureFlag(input) {
370-
const match = input.match(FEATURE_FLAG_REGEX);
371-
if (match && _.contains(this.validFeatureFlags, match[2])) {
372-
return match;
373-
}
374-
return false;
375-
},
376-
377-
/**
378-
* check if the filter input is really a feature flag directive, for example
379-
* `enable serverStats`. If so, set the feature flag accordingly.
380-
*
381-
* @return {Boolean} if it was a feature flag or not.
382-
*/
383-
_checkFeatureFlagDirective() {
384-
const match = this._validateFeatureFlag(this.state.filterString);
385-
if (match) {
386-
app.preferences.save(match[2], match[1] === 'enable');
387-
debug('feature flag %s %sd', match[2], match[1]);
388-
return true;
389-
}
390-
return false;
391-
},
392-
393344
/**
394345
* Sets the value for the given field on the filter.
395346
*
@@ -627,14 +578,6 @@ const QueryStore = Reflux.createStore({
627578
* apply the current (valid) query, and store it in `lastExecutedQuery`.
628579
*/
629580
apply() {
630-
// if it's a feature flag directive, then we can just reset the query
631-
// to whatever was last executed.
632-
if (this._checkFeatureFlagDirective()) {
633-
this.setQuery(this.state.lastExecutedQuery);
634-
return;
635-
}
636-
// otherwise, if the query validates ok, modify lastExecutedQuery (which
637-
// triggers the QueryChangedStore) and set the "apply" state.
638581
if (this._validateQuery()) {
639582
const registry = app.appRegistry;
640583
if (registry) {

test/unit/query-store.test.js

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -91,23 +91,6 @@ describe('QueryStore', () => {
9191
});
9292
});
9393

94-
describe('_validateFeatureFlag', () => {
95-
it('accepts a valid feature flag', () => {
96-
QueryStore.validFeatureFlags = [
97-
'rocketLauncher',
98-
'laserWeapon',
99-
'turboBoost'
100-
];
101-
const res = QueryStore._validateFeatureFlag('enable rocketLauncher');
102-
expect(res[1]).to.be.equal('enable');
103-
expect(res[2]).to.be.equal('rocketLauncher');
104-
});
105-
it('rejects an invalid query sort', () => {
106-
const res = QueryStore._validateFeatureFlag('{foo: 1}');
107-
expect(res).to.be.false;
108-
});
109-
});
110-
11194
describe('setQuery', () => {
11295
context('when setting a single query property', () => {
11396
it('sets a new `filter`', done => {

0 commit comments

Comments
 (0)