64fe9dbfb2
* Clean logs on startup; install server-side testing/linting * Add eslint config, make all of app/ conform to its demands * Add Node.js testing and linting to CI * Lock project to Node.js 7.9.0, used by Electron 1.7.10 * New eslint error: trailing commas in function argumensts Node 7.9.0 doesn't like trailing commas, but Electron does * Move electron to devDependency, tell eslint it's built-in
219 lines
3.6 KiB
JavaScript
219 lines
3.6 KiB
JavaScript
function createTemplate(options, messages) {
|
|
const {
|
|
showDebugLog,
|
|
showAbout,
|
|
openReleaseNotes,
|
|
openNewBugForm,
|
|
openSupportPage,
|
|
openForums,
|
|
} = options;
|
|
|
|
const template = [{
|
|
label: messages.mainMenuFile.message,
|
|
submenu: [
|
|
{
|
|
role: 'quit',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
label: messages.mainMenuEdit.message,
|
|
submenu: [
|
|
{
|
|
role: 'undo',
|
|
},
|
|
{
|
|
role: 'redo',
|
|
},
|
|
{
|
|
type: 'separator',
|
|
},
|
|
{
|
|
role: 'cut',
|
|
},
|
|
{
|
|
role: 'copy',
|
|
},
|
|
{
|
|
role: 'paste',
|
|
},
|
|
{
|
|
role: 'pasteandmatchstyle',
|
|
},
|
|
{
|
|
role: 'delete',
|
|
},
|
|
{
|
|
role: 'selectall',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
label: messages.mainMenuView.message,
|
|
submenu: [
|
|
{
|
|
role: 'resetzoom',
|
|
},
|
|
{
|
|
role: 'zoomin',
|
|
},
|
|
{
|
|
role: 'zoomout',
|
|
},
|
|
{
|
|
type: 'separator',
|
|
},
|
|
{
|
|
role: 'togglefullscreen',
|
|
},
|
|
{
|
|
type: 'separator',
|
|
},
|
|
{
|
|
label: messages.debugLog.message,
|
|
click: showDebugLog,
|
|
},
|
|
{
|
|
type: 'separator',
|
|
},
|
|
{
|
|
role: 'toggledevtools',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
label: messages.mainMenuWindow.message,
|
|
role: 'window',
|
|
submenu: [
|
|
{
|
|
role: 'minimize',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
label: messages.mainMenuHelp.message,
|
|
role: 'help',
|
|
submenu: [
|
|
{
|
|
label: messages.goToReleaseNotes.message,
|
|
click: openReleaseNotes,
|
|
},
|
|
{
|
|
type: 'separator',
|
|
},
|
|
{
|
|
label: messages.goToForums.message,
|
|
click: openForums,
|
|
},
|
|
{
|
|
label: messages.goToSupportPage.message,
|
|
click: openSupportPage,
|
|
},
|
|
{
|
|
label: messages.fileABug.message,
|
|
click: openNewBugForm,
|
|
},
|
|
{
|
|
type: 'separator',
|
|
},
|
|
{
|
|
label: messages.aboutSignalDesktop.message,
|
|
click: showAbout,
|
|
},
|
|
],
|
|
}];
|
|
|
|
if (process.platform === 'darwin') {
|
|
return updateForMac(template, messages, options);
|
|
}
|
|
|
|
return template;
|
|
}
|
|
|
|
function updateForMac(template, messages, options) {
|
|
const {
|
|
showWindow,
|
|
showAbout,
|
|
} = options;
|
|
|
|
// Remove About item and separator from Help menu, since it's on the first menu
|
|
template[4].submenu.pop();
|
|
template[4].submenu.pop();
|
|
|
|
// Replace File menu
|
|
template.shift();
|
|
template.unshift({
|
|
submenu: [
|
|
{
|
|
label: messages.aboutSignalDesktop.message,
|
|
click: showAbout,
|
|
},
|
|
{
|
|
type: 'separator',
|
|
},
|
|
{
|
|
role: 'hide',
|
|
},
|
|
{
|
|
role: 'hideothers',
|
|
},
|
|
{
|
|
role: 'unhide',
|
|
},
|
|
{
|
|
type: 'separator',
|
|
},
|
|
{
|
|
role: 'quit',
|
|
},
|
|
],
|
|
});
|
|
|
|
// Add to Edit menu
|
|
template[1].submenu.push(
|
|
{
|
|
type: 'separator',
|
|
},
|
|
{
|
|
label: messages.speech.message,
|
|
submenu: [
|
|
{
|
|
role: 'startspeaking',
|
|
},
|
|
{
|
|
role: 'stopspeaking',
|
|
},
|
|
],
|
|
}
|
|
);
|
|
|
|
// Replace Window menu
|
|
// eslint-disable-next-line no-param-reassign
|
|
template[3].submenu = [
|
|
{
|
|
accelerator: 'CmdOrCtrl+W',
|
|
role: 'close',
|
|
},
|
|
{
|
|
accelerator: 'CmdOrCtrl+M',
|
|
role: 'minimize',
|
|
},
|
|
{
|
|
role: 'zoom',
|
|
},
|
|
{
|
|
label: messages.show.message,
|
|
click: showWindow,
|
|
},
|
|
{
|
|
type: 'separator',
|
|
},
|
|
{
|
|
role: 'front',
|
|
},
|
|
];
|
|
|
|
return template;
|
|
}
|
|
|
|
module.exports = createTemplate;
|