Skip to content

Commit 1d78639

Browse files
rueckstiessThomas Rueckstiess
authored andcommitted
COMPASS-340 privacy modal connect (#632)
* COMPASS-340 move tour and privacy modals to ./src/app/index.js * fix bug where mixpanel is being used (currently disabled) * fix functional tests with tour/optin on connect screen
1 parent 4e2a473 commit 1d78639

File tree

6 files changed

+46
-42
lines changed

6 files changed

+46
-42
lines changed

src/app/home/index.jade

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,3 @@
1111
a.show-connect-window Connect to another instance
1212
|.
1313
.compass-sidebar-container(data-hook='sidebar')
14-
div(data-hook='tour-container')
15-
div(data-hook='optin-container')

src/app/home/index.js

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ var View = require('ampersand-view');
22
// var format = require('util').format;
33
// var IdentifyView = require('../identify');
44
var { NamespaceStore } = require('hadron-reflux-store');
5-
var TourView = require('../tour');
6-
var NetworkOptInView = require('../network-optin');
75
var app = require('ampersand-app');
86
var metrics = require('mongodb-js-metrics')();
97
var _ = require('lodash');
@@ -84,8 +82,6 @@ var HomeView = View.extend({
8482
this.listenTo(app.instance, 'sync', this.onInstanceFetched);
8583
this.listenTo(app.connection, 'change:name', this.updateTitle);
8684
NamespaceStore.listen(this.switchMainContent.bind(this));
87-
ipc.on('window:show-compass-tour', this.showTour.bind(this, true));
88-
ipc.on('window:show-network-optin', this.showOptIn.bind(this));
8985

9086
this.once('change:rendered', this.onRendered);
9187
debug('fetching instance model...');
@@ -99,12 +95,6 @@ var HomeView = View.extend({
9995
React.createElement(SideBarComponent),
10096
this.queryByHook('sidebar')
10197
);
102-
103-
if (app.preferences.showFeatureTour) {
104-
this.showTour(false);
105-
} else {
106-
this.tourClosed();
107-
}
10898
this.switchMainContent('');
10999
},
110100
switchMainContent: function(namespace) {
@@ -134,26 +124,6 @@ var HomeView = View.extend({
134124
}
135125
this.updateTitle(namespace);
136126
},
137-
showTour: function(force) {
138-
var tourView = new TourView({force: force});
139-
if (tourView.features.length > 0) {
140-
tourView.on('close', this.tourClosed.bind(this));
141-
this.renderSubview(tourView, this.queryByHook('tour-container'));
142-
} else {
143-
this.tourClosed();
144-
}
145-
},
146-
showOptIn: function() {
147-
var networkOptInView = new NetworkOptInView();
148-
this.renderSubview(networkOptInView, this.queryByHook('optin-container'));
149-
},
150-
tourClosed: function() {
151-
app.preferences.unset('showFeatureTour');
152-
app.preferences.save();
153-
if (!app.preferences.showedNetworkOptIn) {
154-
this.showOptIn();
155-
}
156-
},
157127
onInstanceFetched: function() {
158128
// TODO: Remove this line
159129
// Instead, set the instance inside InstanceStore.refreshInstance

src/app/index.js

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ if (process.env.NODE_ENV === 'development') {
99
.catch((err) => console.log('An error occurred trying to install devtools: ', err));
1010
}
1111

12+
window.jQuery = require('jquery');
13+
1214
var Environment = require('../environment');
1315
Environment.init();
1416

@@ -45,6 +47,9 @@ var localLinks = require('local-links');
4547
var async = require('async');
4648
var ipc = require('hadron-ipc');
4749

50+
var TourView = require('./tour');
51+
var NetworkOptInView = require('./network-optin');
52+
4853
var format = require('util').format;
4954
var semver = require('semver');
5055

@@ -66,7 +71,8 @@ var AutoUpdate = require('../auto-update');
6671

6772
var addInspectElementMenu = require('debug-menu').install;
6873

69-
window.jQuery = require('jquery');
74+
require('bootstrap/js/modal');
75+
require('bootstrap/js/transition');
7076

7177
ipc.once('app:launched', function() {
7278
console.log('in app:launched');
@@ -134,6 +140,7 @@ function getConnection(model, done) {
134140
*
135141
* @see http://learn.humanjavascript.com/react-ampersand/application-pattern
136142
*/
143+
137144
var Application = View.extend({
138145
template: function() {
139146
return [
@@ -142,6 +149,8 @@ var Application = View.extend({
142149
' <div data-hook="statusbar"></div>',
143150
' <div data-hook="notifications"></div>',
144151
' <div data-hook="layout-container"></div>',
152+
' <div data-hook="tour-container"></div>',
153+
' <div data-hook="optin-container"></div>',
145154
'</div>'
146155
].join('\n');
147156
},
@@ -188,6 +197,10 @@ var Application = View.extend({
188197
'click i.help': 'onHelpClicked',
189198
'click a.help': 'onHelpClicked'
190199
},
200+
initialize: function() {
201+
ipc.on('window:show-compass-tour', this.showTour.bind(this, true));
202+
ipc.on('window:show-network-optin', this.showOptIn.bind(this));
203+
},
191204
onHelpClicked: function(evt) {
192205
evt.preventDefault();
193206
evt.stopPropagation();
@@ -258,11 +271,37 @@ var Application = View.extend({
258271
});
259272
this.autoUpdate.render();
260273

274+
if (app.preferences.showFeatureTour) {
275+
this.showTour(false);
276+
} else {
277+
this.tourClosed();
278+
}
279+
261280
if (process.env.NODE_ENV !== 'production') {
262281
debug('Installing "Inspect Element" context menu');
263282
addInspectElementMenu();
264283
}
265284
},
285+
showTour: function(force) {
286+
var tourView = new TourView({force: force});
287+
if (tourView.features.length > 0) {
288+
tourView.on('close', this.tourClosed.bind(this));
289+
this.renderSubview(tourView, this.queryByHook('tour-container'));
290+
} else {
291+
this.tourClosed();
292+
}
293+
},
294+
showOptIn: function() {
295+
var networkOptInView = new NetworkOptInView();
296+
this.renderSubview(networkOptInView, this.queryByHook('optin-container'));
297+
},
298+
tourClosed: function() {
299+
app.preferences.unset('showFeatureTour');
300+
app.preferences.save();
301+
if (!app.preferences.showedNetworkOptIn) {
302+
this.showOptIn();
303+
}
304+
},
266305
onPageChange: function(view) {
267306
metrics.track('App', 'viewed', view.screenName);
268307
this.pageSwitcher.set(view);

src/app/metrics/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ module.exports = function() {
102102
// enable/disable event tracking
103103
metrics.trackers.get('ga').enabled = enabled;
104104
metrics.trackers.get('intercom').enabled = enabled;
105-
metrics.trackers.get('mixpanel').enabled = enabled;
105+
// metrics.trackers.get('mixpanel').enabled = enabled;
106106
});
107107
app.preferences.on('change:enableFeedbackPanel', function(prefs, enabled) {
108108
// enable/disable product feedback

src/app/network-optin/index.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,10 @@ var app = require('ampersand-app');
44
var _ = require('lodash');
55
var metrics = require('mongodb-js-metrics')();
66

7-
var debug = require('debug')('mongodb-compass:feature-optin:index');
7+
var debug = require('debug')('mongodb-compass:network-optin:index');
88

99
var indexTemplate = require('./index.jade');
1010

11-
require('bootstrap/js/modal');
12-
require('bootstrap/js/transition');
13-
1411
var NetworkOptInView = View.extend({
1512
template: indexTemplate,
1613
props: {

test/compass-functional.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@ describe('Compass #spectron', function() {
4343
});
4444

4545
it('renders the connect window', function() {
46-
return client.
47-
waitForVisible('select[name=authentication]', 60000).
48-
getTitle().should.eventually.be.equal('MongoDB Compass - Connect');
46+
return client
47+
.startUsingCompass()
48+
.waitForVisible('select[name=authentication]', 60000)
49+
.getTitle().should.eventually.be.equal('MongoDB Compass - Connect');
4950
});
5051
});
5152

@@ -65,7 +66,6 @@ describe('Compass #spectron', function() {
6566
context('when selecting a collection', function() {
6667
it('renders the sample collection in the title', function() {
6768
return client
68-
.startUsingCompass()
6969
.selectCollection('compass-test.bands')
7070
.getTitle().should.eventually.be.equal(
7171
'MongoDB Compass - localhost:27018/compass-test.bands'

0 commit comments

Comments
 (0)