Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const Reflux = require('reflux');
const app = require('hadron-app');
const NamespaceStore = require('hadron-reflux-store').NamespaceStore;
const toNS = require('mongodb-ns');
const Actions = require('../actions');
const _ = require('lodash');

Expand Down Expand Up @@ -50,7 +51,7 @@ const InsertDocumentStore = Reflux.createStore({
* @param {Object} state - The query state.
*/
onQueryChanged: function(state) {
if (state.filter) {
if (state.ns && toNS(state.ns).collection && state.filter) {
this.filter = state.filter;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const Reflux = require('reflux');
const app = require('hadron-app');
const NamespaceStore = require('hadron-reflux-store').NamespaceStore;
const toNS = require('mongodb-ns');
const Actions = require('../actions');
const ReadPreference = require('mongodb').ReadPreference;
const _ = require('lodash');
Expand Down Expand Up @@ -40,12 +41,14 @@ const LoadMoreDocumentsStore = Reflux.createStore({
* @param {Object} state - The query state.
*/
onQueryChanged: function(state) {
this.filter = state.filter || {};
this.sort = _.pairs(state.sort);
this.limit = state.limit;
this.skip = state.skip;
this.project = state.project;
this.counter = 0;
if (state.ns && toNS(state.ns).collection) {
this.filter = state.filter || {};
this.sort = _.pairs(state.sort);
this.limit = state.limit;
this.skip = state.skip;
this.project = state.project;
this.counter = 0;
}
},

/**
Expand Down
17 changes: 10 additions & 7 deletions src/internal-packages/crud/lib/store/reset-document-list-store.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const Reflux = require('reflux');
const app = require('hadron-app');
const ReadPreference = require('mongodb').ReadPreference;
const toNS = require('mongodb-ns');
const Actions = require('../actions');
const _ = require('lodash');

Expand Down Expand Up @@ -39,13 +40,15 @@ const ResetDocumentListStore = Reflux.createStore({
* @param {Object} state - The query state.
*/
onQueryChanged: function(state) {
this.filter = state.filter || {};
this.sort = _.pairs(state.sort);
this.limit = state.limit;
this.skip = state.skip;
this.project = state.project;
this.ns = state.ns;
this.reset();
if (state.ns && toNS(state.ns).collection) {
this.filter = state.filter || {};
this.sort = _.pairs(state.sort);
this.limit = state.limit;
this.skip = state.skip;
this.project = state.project;
this.ns = state.ns;
this.reset();
}
},

/**
Expand Down
27 changes: 15 additions & 12 deletions src/internal-packages/explain/lib/stores/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const Reflux = require('reflux');
const ExplainActions = require('../actions');
const StateMixin = require('reflux-state-mixin');
const app = require('hadron-app');
const toNS = require('mongodb-ns');
const ExplainPlanModel = require('mongodb-explain-plan-model');
const _ = require('lodash');

Expand Down Expand Up @@ -51,18 +52,20 @@ const CompassExplainStore = Reflux.createStore({
},

onQueryChanged(state) {
this.filter = state.filter;
this.project = state.project;
this.sort = state.sort;
this.skip = state.skip;
this.limit = state.limit;
this.ns = state.ns;

if (state.queryState === 'reset') {
this._resetQuery();
this._reset();
} else {
this.fetchExplainPlan();
if (state.ns && toNS(state.ns).collection) {
this.filter = state.filter;
this.project = state.project;
this.sort = state.sort;
this.skip = state.skip;
this.limit = state.limit;
this.ns = state.ns;

if (state.queryState === 'reset') {
this._resetQuery();
this._reset();
} else {
this.fetchExplainPlan();
}
}
},

Expand Down
9 changes: 3 additions & 6 deletions src/internal-packages/query/lib/store/query-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const app = require('hadron-app');
const assert = require('assert');
const _ = require('lodash');
const ms = require('ms');
const toNS = require('mongodb-ns');
const bsonEqual = require('../util').bsonEqual;
const hasDistinctValue = require('../util').hasDistinctValue;

Expand Down Expand Up @@ -50,11 +49,9 @@ const QueryStore = Reflux.createStore({
}
// on namespace changes, reset the store
NamespaceStore.listen((ns) => {
if (ns && toNS(ns).collection) {
const newState = this.getInitialState();
newState.ns = ns;
this.setState(newState);
}
const newState = this.getInitialState();
newState.ns = ns;
this.setState(newState);
});
},

Expand Down
15 changes: 9 additions & 6 deletions src/internal-packages/schema/lib/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const Reflux = require('reflux');
const StateMixin = require('reflux-state-mixin');
const schemaStream = require('mongodb-schema').stream;
const ReadPreference = require('mongodb').ReadPreference;
const toNS = require('mongodb-ns');
const _ = require('lodash');

const COMPASS_ICON_PATH = require('../../../../icon').path;
Expand Down Expand Up @@ -97,12 +98,14 @@ const SchemaStore = Reflux.createStore({
},

onQueryChanged: function(state) {
this._reset();
this.query.filter = state.filter;
this.query.limit = state.limit;
this.query.project = state.project;
this.ns = state.ns;
SchemaAction.startSampling();
if (state.ns && toNS(state.ns).collection) {
this._reset();
this.query.filter = state.filter;
this.query.limit = state.limit;
this.query.project = state.project;
this.ns = state.ns;
SchemaAction.startSampling();
}
},

setMaxTimeMS(maxTimeMS) {
Expand Down