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
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"node_modules/@mongodb-js/compass-connect",
"node_modules/@mongodb-js/compass-crud",
"node_modules/@mongodb-js/compass-deployment-awareness",
"node_modules/@mongodb-js/compass-license",
"node_modules/@mongodb-js/compass-query-history",
"node_modules/@mongodb-js/compass-security",
"node_modules/@mongodb-js/compass-status"
Expand Down Expand Up @@ -145,6 +146,7 @@
"@mongodb-js/compass-crud": "^0.7.1",
"@mongodb-js/compass-deployment-awareness": "^5.0.0",
"@mongodb-js/compass-document-validation": "^5.0.0",
"@mongodb-js/compass-license": "^0.0.1",
"@mongodb-js/compass-query-history": "^2.0.1",
"@mongodb-js/compass-security": "^0.0.2",
"@mongodb-js/compass-serverstats": "^10.0.0",
Expand Down
35 changes: 32 additions & 3 deletions src/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ require('./setup-hadron-caches');
/**
* The main entrypoint for the application!
*/
const pkg = require('../../package.json');
const COMMUNITY = 'mongodb-compass-community';
const DISTRIBUTION = pkg.config.hadron.distributions[process.env.HADRON_DISTRIBUTION];

var electron = require('electron');
var APP_VERSION = electron.remote.app.getVersion();

Expand Down Expand Up @@ -84,6 +88,7 @@ var Application = View.extend({
' <div data-hook="tour-container"></div>',
' <div data-hook="optin-container"></div>',
' <div data-hook="security"></div>',
' <div data-hook="license"></div>',
'</div>'
].join('\n');
},
Expand Down Expand Up @@ -210,10 +215,34 @@ var Application = View.extend({
});
this.autoUpdate.render();

if (app.preferences.showFeatureTour) {
this.showTour(false);
const handleTour = () => {
if (app.preferences.showFeatureTour) {
this.showTour(false);
} else {
this.tourClosed();
}
};

/**
* If we're in Compass community and the license has not been agreed, we need
* to show it first and force the user to agree or disagree.
*/
if (DISTRIBUTION.name === COMMUNITY && !app.preferences.agreedToLicense) {
const licenseComponent = app.appRegistry.getRole('Application.License')[0].component;
const licenseStore = app.appRegistry.getStore('License.Store');
const licenseActions = app.appRegistry.getAction('License.Actions');

ReactDOM.render(React.createElement(licenseComponent), this.queryByHook('license'));

licenseStore.listen((state) => {
if (state.isAgreed) {
handleTour();
}
});

licenseActions.show();
} else {
this.tourClosed();
handleTour();
}

if (process.env.NODE_ENV !== 'production') {
Expand Down
9 changes: 9 additions & 0 deletions src/app/models/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ const preferencesProps = {
required: true,
default: ''
},
/**
* Whether the user agreed to community license terms.
* @type {Boolean}
*/
agreedToLicense: {
type: 'boolean',
required: true,
default: false
},

/**
* Feature Flags
Expand Down
14 changes: 7 additions & 7 deletions src/main/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ Application.prototype.setupLifecycleListeners = function() {
debug('All windows closed. Quitting app.');
app.quit();
});

ipc.respondTo({
'license:disagree': function() {
debug('Did not agree to license, quitting app.');
app.quit();
}
});
};

Application.prototype.setupApplicationMenu = function() {
Expand Down Expand Up @@ -130,13 +137,6 @@ Application.prototype.setupUserDirectory = function() {
}
};

Application.prototype.setupLifecycleListeners = function() {
app.on('window-all-closed', function() {
debug('All windows closed. Quitting app.');
app.quit();
});
};

Application._instance = null;

Application.main = function() {
Expand Down
2 changes: 1 addition & 1 deletion src/setup-hadron-distribution.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const pkg = require('../package.json');

/**
* @note: HADRON_DISTRIBUTION is set via command line args in dev, for example:
* npm start compass-enterprise
* npm start compass-community
*/
if (!process.env.HADRON_DISTRIBUTION) {
process.env.HADRON_DISTRIBUTION = pkg.distribution || pkg.config.hadron.distributions.default;
Expand Down