@@ -20,6 +20,10 @@ require('./setup-hadron-caches');
20
20
/**
21
21
* The main entrypoint for the application!
22
22
*/
23
+ const pkg = require ( '../../package.json' ) ;
24
+ const COMMUNITY = 'mongodb-compass-community' ;
25
+ const DISTRIBUTION = pkg . config . hadron . distributions [ process . env . HADRON_DISTRIBUTION ] ;
26
+
23
27
var electron = require ( 'electron' ) ;
24
28
var APP_VERSION = electron . remote . app . getVersion ( ) ;
25
29
@@ -84,6 +88,7 @@ var Application = View.extend({
84
88
' <div data-hook="tour-container"></div>' ,
85
89
' <div data-hook="optin-container"></div>' ,
86
90
' <div data-hook="security"></div>' ,
91
+ ' <div data-hook="license"></div>' ,
87
92
'</div>'
88
93
] . join ( '\n' ) ;
89
94
} ,
@@ -210,10 +215,34 @@ var Application = View.extend({
210
215
} ) ;
211
216
this . autoUpdate . render ( ) ;
212
217
213
- if ( app . preferences . showFeatureTour ) {
214
- this . showTour ( false ) ;
218
+ const handleTour = ( ) => {
219
+ if ( app . preferences . showFeatureTour ) {
220
+ this . showTour ( false ) ;
221
+ } else {
222
+ this . tourClosed ( ) ;
223
+ }
224
+ } ;
225
+
226
+ /**
227
+ * If we're in Compass community and the license has not been agreed, we need
228
+ * to show it first and force the user to agree or disagree.
229
+ */
230
+ if ( DISTRIBUTION . name === COMMUNITY && ! app . preferences . agreedToLicense ) {
231
+ const licenseComponent = app . appRegistry . getRole ( 'Application.License' ) [ 0 ] . component ;
232
+ const licenseStore = app . appRegistry . getStore ( 'License.Store' ) ;
233
+ const licenseActions = app . appRegistry . getAction ( 'License.Actions' ) ;
234
+
235
+ ReactDOM . render ( React . createElement ( licenseComponent ) , this . queryByHook ( 'license' ) ) ;
236
+
237
+ licenseStore . listen ( ( state ) => {
238
+ if ( state . isAgreed ) {
239
+ handleTour ( ) ;
240
+ }
241
+ } ) ;
242
+
243
+ licenseActions . show ( ) ;
215
244
} else {
216
- this . tourClosed ( ) ;
245
+ handleTour ( ) ;
217
246
}
218
247
219
248
if ( process . env . NODE_ENV !== 'production' ) {
0 commit comments