Skip to content

Commit 72d4447

Browse files
committed
COMPASS-2965: Proper state reset on disconnect
1 parent 3dc1a91 commit 72d4447

File tree

7 files changed

+60
-29
lines changed

7 files changed

+60
-29
lines changed

package-lock.json

Lines changed: 38 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@
226226
"url": "git://github.com/10gen/compass.git"
227227
},
228228
"dependencies": {
229-
"@mongodb-js/compass-aggregations": "^1.6.2",
229+
"@mongodb-js/compass-aggregations": "^1.6.3",
230230
"@mongodb-js/compass-auto-updates": "^0.0.2",
231231
"@mongodb-js/compass-auth-kerberos": "^1.0.1",
232232
"@mongodb-js/compass-auth-ldap": "^1.0.1",

src/internal-plugins/app/lib/stores/collection-store.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const CollectionStore = Reflux.createStore({
2020
*/
2121
onActivated(appRegistry) {
2222
this.appRegistry = appRegistry;
23+
appRegistry.on('data-service-disconnected', this.onDisconnected.bind(this));
2324
appRegistry.on('show-agg-pipeline-out-results', (ns) => {
2425
this.setCollection({
2526
_id: ns,
@@ -31,6 +32,11 @@ const CollectionStore = Reflux.createStore({
3132
});
3233
},
3334

35+
onDisconnected() {
36+
this.collection = {};
37+
this.activeTabIndex = 0;
38+
},
39+
3440
/**
3541
* Set the collection information.
3642
*

src/internal-plugins/app/lib/stores/field-store.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ const FieldStore = Reflux.createStore({
3636

3737
appRegistry.on('collection-changed', this.onCollectionChanged.bind(this));
3838
appRegistry.on('database-changed', this.onDatabaseChanged.bind(this));
39+
appRegistry.on('data-service-disconnected', this.onDisconnected.bind(this));
40+
},
41+
42+
onDisconnected() {
43+
this.setState(this.getInitialState());
3944
},
4045

4146
/**

src/internal-plugins/app/lib/stores/instance-store.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const InstanceStore = Reflux.createStore({
3535
onDisconnected() {
3636
const MongoDBInstance = require('../../../../app/models/mongodb-instance');
3737
app.state.instance = new MongoDBInstance();
38+
this.setState(this.getInitialState());
3839
},
3940

4041
/**

src/internal-plugins/app/lib/stores/namespace-store.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ const NamespaceStore = Reflux.createStore({
2020
this._ns = DEFAULT_NAMESPACE;
2121
},
2222

23+
onActivated(appRegistry) {
24+
appRegistry.on('data-service-disconnected', this.onDisconnected.bind(this));
25+
},
26+
27+
onDisconnected() {
28+
this.init();
29+
},
30+
2331
/**
2432
* Gets the current namespace being worked with in the application.
2533
*/

src/internal-plugins/home/lib/store/index.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,7 @@ const HomeStore = Reflux.createStore({
4040
},
4141

4242
onDisconnected() {
43-
this.setState({
44-
errorMessage: '',
45-
namespace: '',
46-
isConnected: false,
47-
isAtlas: false,
48-
authentication: 'NONE',
49-
ssl: 'NONE',
50-
sshTunnel: 'NONE',
51-
uiStatus: UI_STATES.INITIAL
52-
});
43+
this.setState(this.getInitialState());
5344
},
5445

5546
onConnected(appRegistry, err, ds) {

0 commit comments

Comments
 (0)