Skip to content

Commit 0a0e1ba

Browse files
author
Satya Sinha
authored
with fix (#804)
1 parent f7b4eed commit 0a0e1ba

File tree

6 files changed

+48
-38
lines changed

6 files changed

+48
-38
lines changed

src/internal-packages/crud/lib/store/insert-document-store.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const Reflux = require('reflux');
22
const app = require('hadron-app');
33
const NamespaceStore = require('hadron-reflux-store').NamespaceStore;
4+
const toNS = require('mongodb-ns');
45
const Actions = require('../actions');
56
const _ = 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
}

src/internal-packages/crud/lib/store/load-more-documents-store.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const Reflux = require('reflux');
22
const app = require('hadron-app');
33
const NamespaceStore = require('hadron-reflux-store').NamespaceStore;
4+
const toNS = require('mongodb-ns');
45
const Actions = require('../actions');
56
const ReadPreference = require('mongodb').ReadPreference;
67
const _ = 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
/**

src/internal-packages/crud/lib/store/reset-document-list-store.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const Reflux = require('reflux');
22
const app = require('hadron-app');
33
const ReadPreference = require('mongodb').ReadPreference;
4+
const toNS = require('mongodb-ns');
45
const Actions = require('../actions');
56
const _ = 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
/**

src/internal-packages/explain/lib/stores/index.js

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const Reflux = require('reflux');
22
const ExplainActions = require('../actions');
33
const StateMixin = require('reflux-state-mixin');
44
const app = require('hadron-app');
5+
const toNS = require('mongodb-ns');
56
const ExplainPlanModel = require('mongodb-explain-plan-model');
67
const _ = 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

src/internal-packages/query/lib/store/query-store.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const app = require('hadron-app');
88
const assert = require('assert');
99
const _ = require('lodash');
1010
const ms = require('ms');
11-
const toNS = require('mongodb-ns');
1211
const bsonEqual = require('../util').bsonEqual;
1312
const 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

src/internal-packages/schema/lib/store/index.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const Reflux = require('reflux');
55
const StateMixin = require('reflux-state-mixin');
66
const schemaStream = require('mongodb-schema').stream;
77
const ReadPreference = require('mongodb').ReadPreference;
8+
const toNS = require('mongodb-ns');
89
const _ = require('lodash');
910

1011
const 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) {

0 commit comments

Comments
 (0)