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 1
1
const Reflux = require ( 'reflux' ) ;
2
2
const app = require ( 'hadron-app' ) ;
3
3
const NamespaceStore = require ( 'hadron-reflux-store' ) . NamespaceStore ;
4
+ const toNS = require ( 'mongodb-ns' ) ;
4
5
const Actions = require ( '../actions' ) ;
5
6
const _ = require ( 'lodash' ) ;
6
7
@@ -50,7 +51,7 @@ const InsertDocumentStore = Reflux.createStore({
50
51
* @param {Object } state - The query state.
51
52
*/
52
53
onQueryChanged : function ( state ) {
53
- if ( state . filter ) {
54
+ if ( state . ns && toNS ( state . ns ) . collection && state . filter ) {
54
55
this . filter = state . filter ;
55
56
}
56
57
}
Original file line number Diff line number Diff line change 1
1
const Reflux = require ( 'reflux' ) ;
2
2
const app = require ( 'hadron-app' ) ;
3
3
const NamespaceStore = require ( 'hadron-reflux-store' ) . NamespaceStore ;
4
+ const toNS = require ( 'mongodb-ns' ) ;
4
5
const Actions = require ( '../actions' ) ;
5
6
const ReadPreference = require ( 'mongodb' ) . ReadPreference ;
6
7
const _ = require ( 'lodash' ) ;
@@ -40,12 +41,14 @@ const LoadMoreDocumentsStore = Reflux.createStore({
40
41
* @param {Object } state - The query state.
41
42
*/
42
43
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
+ }
49
52
} ,
50
53
51
54
/**
Original file line number Diff line number Diff line change 1
1
const Reflux = require ( 'reflux' ) ;
2
2
const app = require ( 'hadron-app' ) ;
3
3
const ReadPreference = require ( 'mongodb' ) . ReadPreference ;
4
+ const toNS = require ( 'mongodb-ns' ) ;
4
5
const Actions = require ( '../actions' ) ;
5
6
const _ = require ( 'lodash' ) ;
6
7
@@ -39,13 +40,15 @@ const ResetDocumentListStore = Reflux.createStore({
39
40
* @param {Object } state - The query state.
40
41
*/
41
42
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
+ }
49
52
} ,
50
53
51
54
/**
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ const Reflux = require('reflux');
2
2
const ExplainActions = require ( '../actions' ) ;
3
3
const StateMixin = require ( 'reflux-state-mixin' ) ;
4
4
const app = require ( 'hadron-app' ) ;
5
+ const toNS = require ( 'mongodb-ns' ) ;
5
6
const ExplainPlanModel = require ( 'mongodb-explain-plan-model' ) ;
6
7
const _ = require ( 'lodash' ) ;
7
8
@@ -51,18 +52,20 @@ const CompassExplainStore = Reflux.createStore({
51
52
} ,
52
53
53
54
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
+ }
66
69
}
67
70
} ,
68
71
Original file line number Diff line number Diff line change @@ -8,7 +8,6 @@ const app = require('hadron-app');
8
8
const assert = require ( 'assert' ) ;
9
9
const _ = require ( 'lodash' ) ;
10
10
const ms = require ( 'ms' ) ;
11
- const toNS = require ( 'mongodb-ns' ) ;
12
11
const bsonEqual = require ( '../util' ) . bsonEqual ;
13
12
const hasDistinctValue = require ( '../util' ) . hasDistinctValue ;
14
13
@@ -50,11 +49,9 @@ const QueryStore = Reflux.createStore({
50
49
}
51
50
// on namespace changes, reset the store
52
51
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 ) ;
58
55
} ) ;
59
56
} ,
60
57
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ const Reflux = require('reflux');
5
5
const StateMixin = require ( 'reflux-state-mixin' ) ;
6
6
const schemaStream = require ( 'mongodb-schema' ) . stream ;
7
7
const ReadPreference = require ( 'mongodb' ) . ReadPreference ;
8
+ const toNS = require ( 'mongodb-ns' ) ;
8
9
const _ = require ( 'lodash' ) ;
9
10
10
11
const COMPASS_ICON_PATH = require ( '../../../../icon' ) . path ;
@@ -97,12 +98,14 @@ const SchemaStore = Reflux.createStore({
97
98
} ,
98
99
99
100
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
+ }
106
109
} ,
107
110
108
111
setMaxTimeMS ( maxTimeMS ) {
You can’t perform that action at this time.
0 commit comments