diff --git a/src/app/index.html b/src/app/index.html index 458d61fd428..168031572fb 100644 --- a/src/app/index.html +++ b/src/app/index.html @@ -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 diff --git a/src/app/index.js b/src/app/index.js index d06ef3bf0a8..70dc23e84cd 100644 --- a/src/app/index.js +++ b/src/app/index.js @@ -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 diff --git a/src/internal-plugins/query/lib/store/query-store.js b/src/internal-plugins/query/lib/store/query-store.js index 55efb57b4e6..4da99141ec2 100644 --- a/src/internal-plugins/query/lib/store/query-store.js +++ b/src/internal-plugins/query/lib/store/query-store.js @@ -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'; @@ -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)); @@ -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, @@ -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; @@ -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); @@ -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. * @@ -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) { diff --git a/test/unit/query-store.test.js b/test/unit/query-store.test.js index ec4a7a61bde..7d1b493a84d 100644 --- a/test/unit/query-store.test.js +++ b/test/unit/query-store.test.js @@ -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 => {