Skip to content

Commit 52e5c8d

Browse files
committed
touchup last commit
1 parent a8cf1d9 commit 52e5c8d

File tree

3 files changed

+51
-23
lines changed

3 files changed

+51
-23
lines changed

src/electron/menu.js

Lines changed: 48 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// based off of https://github.com/atom/atom/blob/master/src/browser/application-menu.coffee
2+
// use js2.coffee to convert it to JS
3+
14
var app = require('app');
25
var BrowserWindow = require('browser-window');
36
var Menu = require('menu');
@@ -180,51 +183,76 @@ function windowSubMenu() {
180183
}
181184

182185
// menus
183-
function darwinMenu(showShareSubMenu) {
186+
function darwinMenu(showConnectSubMenu, showShareSubMenu) {
184187
var m = [
185-
darwinCompassSubMenu(),
186-
connectSubMenu(),
187-
editSubMenu(),
188-
viewSubMenu(),
189-
windowSubMenu()
188+
darwinCompassSubMenu()
190189
];
190+
191+
if (showConnectSubMenu) {
192+
m.push(connectSubMenu());
193+
}
194+
195+
m.push(editSubMenu());
196+
m.push(viewSubMenu());
197+
191198
if (showShareSubMenu) {
192-
m.splice(4, 0, shareSubMenu());
199+
m.push(shareSubMenu());
193200
}
201+
202+
m.push(windowSubMenu());
203+
194204
return m;
195205
}
196206

197-
function nonDarwinMenu(showShareSubMenu) {
207+
function nonDarwinMenu(showConnectSubMenu, showShareSubMenu) {
198208
var m = [
199-
nonDarwinCompassSubMenu(),
200-
connectSubMenu(),
201-
viewSubMenu()
209+
nonDarwinCompassSubMenu()
202210
];
211+
212+
if (showConnectSubMenu) {
213+
m.push(connectSubMenu());
214+
}
215+
216+
m.push(viewSubMenu());
217+
203218
if (showShareSubMenu) {
204219
m.push(shareSubMenu());
205220
}
221+
206222
return m;
207223
}
208224

209225
// menu singleton
210226
var menu = (function() {
211227
return {
212-
init: function() {
228+
load: function(showConnectSubMenu, showShareSubMenu) {
229+
if (typeof showConnectSubMenu === 'undefined') {
230+
showConnectSubMenu = true;
231+
}
232+
233+
if (typeof showShareSubMenu === 'undefined') {
234+
showShareSubMenu = true;
235+
}
236+
213237
var m;
214238
if (process.platform === 'darwin') {
215-
m = darwinMenu();
239+
m = darwinMenu(showConnectSubMenu, showShareSubMenu);
216240
} else {
217-
m = nonDarwinMenu();
241+
m = nonDarwinMenu(showConnectSubMenu, showShareSubMenu);
218242
}
219243
m = Menu.buildFromTemplate(m);
220244
Menu.setApplicationMenu(m);
221-
},
222-
hideShareSubMenu: function() {
223-
224-
},
225-
showShareSubMenu: function() {
226-
227245
}
246+
// hideShareSubMenu: function() {
247+
// this.load(false);
248+
// },
249+
// hideConnectSubMenu: function() {
250+
// },
251+
// showConnectSubMenu: function() {
252+
// },
253+
// showShareSubMenu: function() {
254+
// this.load(true);
255+
// }
228256
};
229257
}());
230258

src/electron/window-manager.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ module.exports.create = function(opts) {
6363
'direct-write': true
6464
}
6565
});
66-
menu.init();
67-
GLOBAL.menu = menu;
66+
menu.load();
67+
// GLOBAL.menu = menu;
6868

6969
// makes the application a single instance application
7070
// see "app.makeSingleInstance" in https://github.com/atom/electron/blob/master/docs/api/app.md

src/home/collection.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ var MongoDBCollectionView = View.extend({
7575
schemaIsSynced: function() {
7676
// only listen to share menu events if we have a sync'ed schema
7777
// @todo enable share menu item here
78-
GLOBAL.menu.showShareMenu();
78+
// GLOBAL.menu.showShareMenu();
7979
this.listenTo(app, 'menu-share-schema-json', this.onShareSchema.bind(this));
8080
},
8181
schemaIsRequested: function() {

0 commit comments

Comments
 (0)