2017-08-20 03:03:13 -08:00
|
|
|
// Packages
|
2017-06-19 13:02:53 -08:00
|
|
|
const {app, dialog} = require('electron');
|
|
|
|
|
|
2017-08-20 03:03:13 -08:00
|
|
|
// Utilities
|
|
|
|
|
const {getKeymaps, getConfig} = require('../config');
|
2017-06-19 13:02:53 -08:00
|
|
|
const {icon} = require('../config/paths');
|
2017-05-25 22:59:02 -08:00
|
|
|
const viewMenu = require('./menus/view');
|
|
|
|
|
const shellMenu = require('./menus/shell');
|
|
|
|
|
const editMenu = require('./menus/edit');
|
|
|
|
|
const pluginsMenu = require('./menus/plugins');
|
|
|
|
|
const windowMenu = require('./menus/window');
|
|
|
|
|
const helpMenu = require('./menus/help');
|
|
|
|
|
const darwinMenu = require('./menus/darwin');
|
|
|
|
|
|
2017-06-19 13:02:53 -08:00
|
|
|
const appName = app.getName();
|
|
|
|
|
const appVersion = app.getVersion();
|
|
|
|
|
|
|
|
|
|
module.exports = (createWindow, updatePlugins, getLoadedPluginVersions) => {
|
2017-08-20 03:03:13 -08:00
|
|
|
const config = getConfig();
|
|
|
|
|
const {commands} = getKeymaps();
|
|
|
|
|
|
2017-08-30 09:14:28 -08:00
|
|
|
let updateChannel = 'stable';
|
|
|
|
|
|
|
|
|
|
if (config && config.updateChannel && config.updateChannel === 'canary') {
|
|
|
|
|
updateChannel = 'canary';
|
|
|
|
|
}
|
2017-08-20 03:03:13 -08:00
|
|
|
|
2017-06-19 13:02:53 -08:00
|
|
|
const showAbout = () => {
|
|
|
|
|
const loadedPlugins = getLoadedPluginVersions();
|
2017-09-10 05:35:10 -08:00
|
|
|
const pluginList =
|
|
|
|
|
loadedPlugins.length === 0 ? 'none' : loadedPlugins.map(plugin => `\n ${plugin.name} (${plugin.version})`);
|
2017-08-20 03:03:13 -08:00
|
|
|
|
2017-06-19 13:02:53 -08:00
|
|
|
dialog.showMessageBox({
|
|
|
|
|
title: `About ${appName}`,
|
2017-08-20 03:03:13 -08:00
|
|
|
message: `${appName} ${appVersion} (${updateChannel})`,
|
2017-06-19 13:02:53 -08:00
|
|
|
detail: `Plugins: ${pluginList}\n\nCreated by Guillermo Rauch\nCopyright © 2017 Zeit, Inc.`,
|
|
|
|
|
buttons: [],
|
|
|
|
|
icon
|
|
|
|
|
});
|
|
|
|
|
};
|
2017-06-02 16:03:47 -08:00
|
|
|
const menu = [
|
2017-06-19 13:02:53 -08:00
|
|
|
...(process.platform === 'darwin' ? [darwinMenu(commands, showAbout)] : []),
|
2017-06-02 16:03:47 -08:00
|
|
|
shellMenu(commands, createWindow),
|
|
|
|
|
editMenu(commands),
|
|
|
|
|
viewMenu(commands),
|
|
|
|
|
pluginsMenu(commands, updatePlugins),
|
|
|
|
|
windowMenu(commands),
|
2017-06-19 13:02:53 -08:00
|
|
|
helpMenu(commands, showAbout)
|
2017-06-02 16:03:47 -08:00
|
|
|
];
|
2017-05-25 22:59:02 -08:00
|
|
|
|
|
|
|
|
return menu;
|
|
|
|
|
};
|