Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
https://app.getsentry.com
https://*.google-analytics.com;
child-src
blob:
https://share.intercom.io
https://www.youtube.com
https://player.vimeo.com
Expand Down
1 change: 1 addition & 0 deletions src/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ app.extend({
Action.pluginActivationCompleted.listen(() => {
global.hadronApp.appRegistry.onActivated();
global.hadronApp.appRegistry.emit('application-initialized', APP_VERSION);
global.hadronApp.appRegistry.emit('preferences-loaded', state.preferences);
// signal to main process that app is ready
ipc.call('window:renderer-ready');
// as soon as dom is ready, render and set up the rest
Expand Down
57 changes: 0 additions & 57 deletions src/internal-plugins/query/lib/store/query-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const debug = require('debug')('mongodb-compass:stores:query');
// constants
const USER_TYPING_DEBOUNCE_MS = 100;

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

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

init: function() {
// store valid feature flags to recognise in the filter box
if (_.get(app.preferences, 'serialize')) {
this.validFeatureFlags = _.keys(
_.pick(app.preferences.serialize(), _.isBoolean)
);
} else {
this.validFeatureFlags = [];
}
},

onActivated(appRegistry) {
this.QueryHistoryActions = appRegistry.getAction('QueryHistory.Actions');
this.QueryHistoryActions.runQuery.listen(this.autoPopulateQuery.bind(this));
Expand Down Expand Up @@ -123,9 +111,6 @@ const QueryStore = Reflux.createStore({
// query history view.
autoPopulated: false,

// was a feature flag recognised in the input
featureFlag: false,

// is the query bar component expanded or collapsed?
expanded: false,

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

const state = {
featureFlag: isFeatureFlag,
userTyping: Boolean(userTyping)
};
state[`${label}String`] = input;
Expand Down Expand Up @@ -305,7 +288,6 @@ const QueryStore = Reflux.createStore({
if (_.has(query, 'sample')) {
this.toggleSample(query.sample);
}
state.featureFlag = false;
state.autoPopulated = autoPopulated;
state.valid = valid;
this.setState(state);
Expand Down Expand Up @@ -359,37 +341,6 @@ const QueryStore = Reflux.createStore({
);
},

/**
* validates if the input is a feature flag directive.
*
* @param {String} input The input to validate.
*
* @return {Boolean|MatchGroup} the regex match or false if invalid.
*/
_validateFeatureFlag(input) {
const match = input.match(FEATURE_FLAG_REGEX);
if (match && _.contains(this.validFeatureFlags, match[2])) {
return match;
}
return false;
},

/**
* check if the filter input is really a feature flag directive, for example
* `enable serverStats`. If so, set the feature flag accordingly.
*
* @return {Boolean} if it was a feature flag or not.
*/
_checkFeatureFlagDirective() {
const match = this._validateFeatureFlag(this.state.filterString);
if (match) {
app.preferences.save(match[2], match[1] === 'enable');
debug('feature flag %s %sd', match[2], match[1]);
return true;
}
return false;
},

/**
* Sets the value for the given field on the filter.
*
Expand Down Expand Up @@ -627,14 +578,6 @@ const QueryStore = Reflux.createStore({
* apply the current (valid) query, and store it in `lastExecutedQuery`.
*/
apply() {
// if it's a feature flag directive, then we can just reset the query
// to whatever was last executed.
if (this._checkFeatureFlagDirective()) {
this.setQuery(this.state.lastExecutedQuery);
return;
}
// otherwise, if the query validates ok, modify lastExecutedQuery (which
// triggers the QueryChangedStore) and set the "apply" state.
if (this._validateQuery()) {
const registry = app.appRegistry;
if (registry) {
Expand Down
17 changes: 0 additions & 17 deletions test/unit/query-store.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,23 +91,6 @@ describe('QueryStore', () => {
});
});

describe('_validateFeatureFlag', () => {
it('accepts a valid feature flag', () => {
QueryStore.validFeatureFlags = [
'rocketLauncher',
'laserWeapon',
'turboBoost'
];
const res = QueryStore._validateFeatureFlag('enable rocketLauncher');
expect(res[1]).to.be.equal('enable');
expect(res[2]).to.be.equal('rocketLauncher');
});
it('rejects an invalid query sort', () => {
const res = QueryStore._validateFeatureFlag('{foo: 1}');
expect(res).to.be.false;
});
});

describe('setQuery', () => {
context('when setting a single query property', () => {
it('sets a new `filter`', done => {
Expand Down