@@ -15,7 +15,6 @@ const debug = require('debug')('mongodb-compass:stores:query');
1515// constants
1616const USER_TYPING_DEBOUNCE_MS = 100 ;
1717
18- const FEATURE_FLAG_REGEX = / ^ ( e n a b l e | d i s a b l e ) ( \w + ) \s * $ / ;
1918const RESET_STATE = 'reset' ;
2019const 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 ) {
0 commit comments