File tree Expand file tree Collapse file tree 6 files changed +48
-38
lines changed
Expand file tree Collapse file tree 6 files changed +48
-38
lines changed Original file line number Diff line number Diff line change 11const Reflux = require ( 'reflux' ) ;
22const app = require ( 'hadron-app' ) ;
33const NamespaceStore = require ( 'hadron-reflux-store' ) . NamespaceStore ;
4+ const toNS = require ( 'mongodb-ns' ) ;
45const Actions = require ( '../actions' ) ;
56const _ = require ( 'lodash' ) ;
67
@@ -50,7 +51,7 @@ const InsertDocumentStore = Reflux.createStore({
5051 * @param {Object } state - The query state.
5152 */
5253 onQueryChanged : function ( state ) {
53- if ( state . filter ) {
54+ if ( state . ns && toNS ( state . ns ) . collection && state . filter ) {
5455 this . filter = state . filter ;
5556 }
5657 }
Original file line number Diff line number Diff line change 11const Reflux = require ( 'reflux' ) ;
22const app = require ( 'hadron-app' ) ;
33const NamespaceStore = require ( 'hadron-reflux-store' ) . NamespaceStore ;
4+ const toNS = require ( 'mongodb-ns' ) ;
45const Actions = require ( '../actions' ) ;
56const ReadPreference = require ( 'mongodb' ) . ReadPreference ;
67const _ = require ( 'lodash' ) ;
@@ -40,12 +41,14 @@ const LoadMoreDocumentsStore = Reflux.createStore({
4041 * @param {Object } state - The query state.
4142 */
4243 onQueryChanged : function ( state ) {
43- this . filter = state . filter || { } ;
44- this . sort = _ . pairs ( state . sort ) ;
45- this . limit = state . limit ;
46- this . skip = state . skip ;
47- this . project = state . project ;
48- this . counter = 0 ;
44+ if ( state . ns && toNS ( state . ns ) . collection ) {
45+ this . filter = state . filter || { } ;
46+ this . sort = _ . pairs ( state . sort ) ;
47+ this . limit = state . limit ;
48+ this . skip = state . skip ;
49+ this . project = state . project ;
50+ this . counter = 0 ;
51+ }
4952 } ,
5053
5154 /**
Original file line number Diff line number Diff line change 11const Reflux = require ( 'reflux' ) ;
22const app = require ( 'hadron-app' ) ;
33const ReadPreference = require ( 'mongodb' ) . ReadPreference ;
4+ const toNS = require ( 'mongodb-ns' ) ;
45const Actions = require ( '../actions' ) ;
56const _ = require ( 'lodash' ) ;
67
@@ -39,13 +40,15 @@ const ResetDocumentListStore = Reflux.createStore({
3940 * @param {Object } state - The query state.
4041 */
4142 onQueryChanged : function ( state ) {
42- this . filter = state . filter || { } ;
43- this . sort = _ . pairs ( state . sort ) ;
44- this . limit = state . limit ;
45- this . skip = state . skip ;
46- this . project = state . project ;
47- this . ns = state . ns ;
48- this . reset ( ) ;
43+ if ( state . ns && toNS ( state . ns ) . collection ) {
44+ this . filter = state . filter || { } ;
45+ this . sort = _ . pairs ( state . sort ) ;
46+ this . limit = state . limit ;
47+ this . skip = state . skip ;
48+ this . project = state . project ;
49+ this . ns = state . ns ;
50+ this . reset ( ) ;
51+ }
4952 } ,
5053
5154 /**
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ const Reflux = require('reflux');
22const ExplainActions = require ( '../actions' ) ;
33const StateMixin = require ( 'reflux-state-mixin' ) ;
44const app = require ( 'hadron-app' ) ;
5+ const toNS = require ( 'mongodb-ns' ) ;
56const ExplainPlanModel = require ( 'mongodb-explain-plan-model' ) ;
67const _ = require ( 'lodash' ) ;
78
@@ -51,18 +52,20 @@ const CompassExplainStore = Reflux.createStore({
5152 } ,
5253
5354 onQueryChanged ( state ) {
54- this . filter = state . filter ;
55- this . project = state . project ;
56- this . sort = state . sort ;
57- this . skip = state . skip ;
58- this . limit = state . limit ;
59- this . ns = state . ns ;
60-
61- if ( state . queryState === 'reset' ) {
62- this . _resetQuery ( ) ;
63- this . _reset ( ) ;
64- } else {
65- this . fetchExplainPlan ( ) ;
55+ if ( state . ns && toNS ( state . ns ) . collection ) {
56+ this . filter = state . filter ;
57+ this . project = state . project ;
58+ this . sort = state . sort ;
59+ this . skip = state . skip ;
60+ this . limit = state . limit ;
61+ this . ns = state . ns ;
62+
63+ if ( state . queryState === 'reset' ) {
64+ this . _resetQuery ( ) ;
65+ this . _reset ( ) ;
66+ } else {
67+ this . fetchExplainPlan ( ) ;
68+ }
6669 }
6770 } ,
6871
Original file line number Diff line number Diff line change @@ -8,7 +8,6 @@ const app = require('hadron-app');
88const assert = require ( 'assert' ) ;
99const _ = require ( 'lodash' ) ;
1010const ms = require ( 'ms' ) ;
11- const toNS = require ( 'mongodb-ns' ) ;
1211const bsonEqual = require ( '../util' ) . bsonEqual ;
1312const hasDistinctValue = require ( '../util' ) . hasDistinctValue ;
1413
@@ -50,11 +49,9 @@ const QueryStore = Reflux.createStore({
5049 }
5150 // on namespace changes, reset the store
5251 NamespaceStore . listen ( ( ns ) => {
53- if ( ns && toNS ( ns ) . collection ) {
54- const newState = this . getInitialState ( ) ;
55- newState . ns = ns ;
56- this . setState ( newState ) ;
57- }
52+ const newState = this . getInitialState ( ) ;
53+ newState . ns = ns ;
54+ this . setState ( newState ) ;
5855 } ) ;
5956 } ,
6057
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ const Reflux = require('reflux');
55const StateMixin = require ( 'reflux-state-mixin' ) ;
66const schemaStream = require ( 'mongodb-schema' ) . stream ;
77const ReadPreference = require ( 'mongodb' ) . ReadPreference ;
8+ const toNS = require ( 'mongodb-ns' ) ;
89const _ = require ( 'lodash' ) ;
910
1011const COMPASS_ICON_PATH = require ( '../../../../icon' ) . path ;
@@ -97,12 +98,14 @@ const SchemaStore = Reflux.createStore({
9798 } ,
9899
99100 onQueryChanged : function ( state ) {
100- this . _reset ( ) ;
101- this . query . filter = state . filter ;
102- this . query . limit = state . limit ;
103- this . query . project = state . project ;
104- this . ns = state . ns ;
105- SchemaAction . startSampling ( ) ;
101+ if ( state . ns && toNS ( state . ns ) . collection ) {
102+ this . _reset ( ) ;
103+ this . query . filter = state . filter ;
104+ this . query . limit = state . limit ;
105+ this . query . project = state . project ;
106+ this . ns = state . ns ;
107+ SchemaAction . startSampling ( ) ;
108+ }
106109 } ,
107110
108111 setMaxTimeMS ( maxTimeMS ) {
You can’t perform that action at this time.
0 commit comments