Signal-Desktop/app/menu.js

278 lines
5.1 KiB
JavaScript
Raw Normal View History

function createTemplate(options, messages) {
const {
openForums,
openNewBugForm,
openReleaseNotes,
openSupportPage,
New design for import/install, 'light' import (#2053) - A new design for the import flow. It features: - Icons at the top of every screen - Gray background, blue buttons, thinner text - Simpler copy - A new design for the install flow. It features: - Immediate entry into the QR code screen - Animated dots to show that we're loading the QR code from the server - Fewer screens: 1) QR 2) device name 3) sync-in-progress - When not set up, the app opens directly into the install screen, which has been streamlined. The `--import` command-line argument will cause the app to open directly into the import flow. - Support for two different flavors of builds - the normal build will open into the standard registration flow, and the import flavor will be exactly the same except during setup it will open directly into the import flow. - A new design for the (dev-only) standalone registration view - When these install sequences are active, the OS File menu has entries to allow you to switch the method of setup you'd like to use. These go away as soon as the first step is taken in any of these flows. - The device name (chosen on initial setup) is now shown in the settings panel - At the end of a light import, we hand off to the normal device link screen, starting at the QR code. On a full import, we remove the sensitive encryption information in the export to prevent conflicts on multiple imports. - `Whisper.Backup.exportToDirectory()` takes an options object so you can tell it to do a light export. - `Whisper.Backup.importFromDirectory()` takes an options object so you can force it to load only the light components found on disk. It also returns an object so you can tell whether a given import was a full import or light import. - On start of import, we build a list of all the ids present in the messages, conversations, and groups stores in IndexedDB. This can take some time if a lot of data is in the database already, but it makes the subsequent deduplicated import very fast. - Disappearing messages are now excluded when exporting - Remove some TODOs in the tests
2018-02-22 18:40:32 +00:00
setupAsNewDevice,
setupAsStandalone,
setupWithImport,
showAbout,
showDebugLog,
} = options;
2017-04-05 18:29:43 +00:00
const template = [{
label: messages.mainMenuFile.message,
submenu: [
{
role: 'quit',
},
],
},
2017-04-05 18:29:43 +00:00
{
label: messages.mainMenuEdit.message,
2017-04-05 18:29:43 +00:00
submenu: [
{
role: 'undo',
2017-04-05 18:29:43 +00:00
},
{
role: 'redo',
2017-04-05 18:29:43 +00:00
},
{
type: 'separator',
2017-04-05 18:29:43 +00:00
},
{
role: 'cut',
2017-04-05 18:29:43 +00:00
},
{
role: 'copy',
2017-04-05 18:29:43 +00:00
},
{
role: 'paste',
2017-04-05 18:29:43 +00:00
},
{
role: 'pasteandmatchstyle',
2017-04-05 18:29:43 +00:00
},
{
role: 'delete',
2017-04-05 18:29:43 +00:00
},
{
role: 'selectall',
},
],
2017-04-05 18:29:43 +00:00
},
{
label: messages.mainMenuView.message,
2017-04-05 18:29:43 +00:00
submenu: [
{
role: 'resetzoom',
},
{
role: 'zoomin',
},
2017-04-05 18:29:43 +00:00
{
role: 'zoomout',
2017-04-05 18:29:43 +00:00
},
{
type: 'separator',
2017-04-05 18:29:43 +00:00
},
{
role: 'togglefullscreen',
2017-04-05 18:29:43 +00:00
},
{
type: 'separator',
2017-04-05 18:29:43 +00:00
},
{
label: messages.debugLog.message,
click: showDebugLog,
2017-04-05 18:29:43 +00:00
},
{
type: 'separator',
2017-04-05 18:29:43 +00:00
},
{
role: 'toggledevtools',
2017-04-05 18:29:43 +00:00
},
],
},
{
label: messages.mainMenuWindow.message,
role: 'window',
submenu: [
2017-04-05 18:29:43 +00:00
{
role: 'minimize',
2017-04-05 18:29:43 +00:00
},
],
2017-04-05 18:29:43 +00:00
},
{
label: messages.mainMenuHelp.message,
role: 'help',
2017-04-05 18:29:43 +00:00
submenu: [
{
label: messages.goToReleaseNotes.message,
click: openReleaseNotes,
2017-04-05 18:29:43 +00:00
},
{
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,
},
],
}];
New design for import/install, 'light' import (#2053) - A new design for the import flow. It features: - Icons at the top of every screen - Gray background, blue buttons, thinner text - Simpler copy - A new design for the install flow. It features: - Immediate entry into the QR code screen - Animated dots to show that we're loading the QR code from the server - Fewer screens: 1) QR 2) device name 3) sync-in-progress - When not set up, the app opens directly into the install screen, which has been streamlined. The `--import` command-line argument will cause the app to open directly into the import flow. - Support for two different flavors of builds - the normal build will open into the standard registration flow, and the import flavor will be exactly the same except during setup it will open directly into the import flow. - A new design for the (dev-only) standalone registration view - When these install sequences are active, the OS File menu has entries to allow you to switch the method of setup you'd like to use. These go away as soon as the first step is taken in any of these flows. - The device name (chosen on initial setup) is now shown in the settings panel - At the end of a light import, we hand off to the normal device link screen, starting at the QR code. On a full import, we remove the sensitive encryption information in the export to prevent conflicts on multiple imports. - `Whisper.Backup.exportToDirectory()` takes an options object so you can tell it to do a light export. - `Whisper.Backup.importFromDirectory()` takes an options object so you can force it to load only the light components found on disk. It also returns an object so you can tell whether a given import was a full import or light import. - On start of import, we build a list of all the ids present in the messages, conversations, and groups stores in IndexedDB. This can take some time if a lot of data is in the database already, but it makes the subsequent deduplicated import very fast. - Disappearing messages are now excluded when exporting - Remove some TODOs in the tests
2018-02-22 18:40:32 +00:00
if (options.includeSetup) {
const fileMenu = template[0];
// These are in reverse order, since we're prepending them one at a time
if (options.development) {
fileMenu.submenu.unshift({
label: messages.menuSetupAsStandalone.message,
click: setupAsStandalone,
});
}
fileMenu.submenu.unshift({
label: messages.menuSetupAsNewDevice.message,
click: setupAsNewDevice,
});
fileMenu.submenu.unshift({
label: messages.menuSetupWithImport.message,
click: setupWithImport,
});
}
if (process.platform === 'darwin') {
return updateForMac(template, messages, options);
2017-04-05 18:29:43 +00:00
}
return template;
}
function updateForMac(template, messages, options) {
const {
New design for import/install, 'light' import (#2053) - A new design for the import flow. It features: - Icons at the top of every screen - Gray background, blue buttons, thinner text - Simpler copy - A new design for the install flow. It features: - Immediate entry into the QR code screen - Animated dots to show that we're loading the QR code from the server - Fewer screens: 1) QR 2) device name 3) sync-in-progress - When not set up, the app opens directly into the install screen, which has been streamlined. The `--import` command-line argument will cause the app to open directly into the import flow. - Support for two different flavors of builds - the normal build will open into the standard registration flow, and the import flavor will be exactly the same except during setup it will open directly into the import flow. - A new design for the (dev-only) standalone registration view - When these install sequences are active, the OS File menu has entries to allow you to switch the method of setup you'd like to use. These go away as soon as the first step is taken in any of these flows. - The device name (chosen on initial setup) is now shown in the settings panel - At the end of a light import, we hand off to the normal device link screen, starting at the QR code. On a full import, we remove the sensitive encryption information in the export to prevent conflicts on multiple imports. - `Whisper.Backup.exportToDirectory()` takes an options object so you can tell it to do a light export. - `Whisper.Backup.importFromDirectory()` takes an options object so you can force it to load only the light components found on disk. It also returns an object so you can tell whether a given import was a full import or light import. - On start of import, we build a list of all the ids present in the messages, conversations, and groups stores in IndexedDB. This can take some time if a lot of data is in the database already, but it makes the subsequent deduplicated import very fast. - Disappearing messages are now excluded when exporting - Remove some TODOs in the tests
2018-02-22 18:40:32 +00:00
setupAsNewDevice,
setupAsStandalone,
setupWithImport,
showAbout,
showWindow,
} = options;
// Remove About item and separator from Help menu, since it's on the first menu
template[4].submenu.pop();
template[4].submenu.pop();
New design for import/install, 'light' import (#2053) - A new design for the import flow. It features: - Icons at the top of every screen - Gray background, blue buttons, thinner text - Simpler copy - A new design for the install flow. It features: - Immediate entry into the QR code screen - Animated dots to show that we're loading the QR code from the server - Fewer screens: 1) QR 2) device name 3) sync-in-progress - When not set up, the app opens directly into the install screen, which has been streamlined. The `--import` command-line argument will cause the app to open directly into the import flow. - Support for two different flavors of builds - the normal build will open into the standard registration flow, and the import flavor will be exactly the same except during setup it will open directly into the import flow. - A new design for the (dev-only) standalone registration view - When these install sequences are active, the OS File menu has entries to allow you to switch the method of setup you'd like to use. These go away as soon as the first step is taken in any of these flows. - The device name (chosen on initial setup) is now shown in the settings panel - At the end of a light import, we hand off to the normal device link screen, starting at the QR code. On a full import, we remove the sensitive encryption information in the export to prevent conflicts on multiple imports. - `Whisper.Backup.exportToDirectory()` takes an options object so you can tell it to do a light export. - `Whisper.Backup.importFromDirectory()` takes an options object so you can force it to load only the light components found on disk. It also returns an object so you can tell whether a given import was a full import or light import. - On start of import, we build a list of all the ids present in the messages, conversations, and groups stores in IndexedDB. This can take some time if a lot of data is in the database already, but it makes the subsequent deduplicated import very fast. - Disappearing messages are now excluded when exporting - Remove some TODOs in the tests
2018-02-22 18:40:32 +00:00
// Remove File menu
template.shift();
New design for import/install, 'light' import (#2053) - A new design for the import flow. It features: - Icons at the top of every screen - Gray background, blue buttons, thinner text - Simpler copy - A new design for the install flow. It features: - Immediate entry into the QR code screen - Animated dots to show that we're loading the QR code from the server - Fewer screens: 1) QR 2) device name 3) sync-in-progress - When not set up, the app opens directly into the install screen, which has been streamlined. The `--import` command-line argument will cause the app to open directly into the import flow. - Support for two different flavors of builds - the normal build will open into the standard registration flow, and the import flavor will be exactly the same except during setup it will open directly into the import flow. - A new design for the (dev-only) standalone registration view - When these install sequences are active, the OS File menu has entries to allow you to switch the method of setup you'd like to use. These go away as soon as the first step is taken in any of these flows. - The device name (chosen on initial setup) is now shown in the settings panel - At the end of a light import, we hand off to the normal device link screen, starting at the QR code. On a full import, we remove the sensitive encryption information in the export to prevent conflicts on multiple imports. - `Whisper.Backup.exportToDirectory()` takes an options object so you can tell it to do a light export. - `Whisper.Backup.importFromDirectory()` takes an options object so you can force it to load only the light components found on disk. It also returns an object so you can tell whether a given import was a full import or light import. - On start of import, we build a list of all the ids present in the messages, conversations, and groups stores in IndexedDB. This can take some time if a lot of data is in the database already, but it makes the subsequent deduplicated import very fast. - Disappearing messages are now excluded when exporting - Remove some TODOs in the tests
2018-02-22 18:40:32 +00:00
if (options.includeSetup) {
// Add a File menu just for these setup options. Because we're using unshift(), we add
// the file menu first, though it ends up to the right of the Signal Desktop menu.
const fileMenu = {
label: messages.mainMenuFile.message,
submenu: [
{
label: messages.menuSetupWithImport.message,
click: setupWithImport,
},
{
label: messages.menuSetupAsNewDevice.message,
click: setupAsNewDevice,
},
],
};
if (options.development) {
fileMenu.submenu.push({
label: messages.menuSetupAsStandalone.message,
click: setupAsStandalone,
});
}
template.unshift(fileMenu);
}
// Add the OSX-specific Signal Desktop menu at the far left
2017-04-05 18:29:43 +00:00
template.unshift({
submenu: [
{
label: messages.aboutSignalDesktop.message,
click: showAbout,
2017-04-05 18:29:43 +00:00
},
{
type: 'separator',
2017-04-05 18:29:43 +00:00
},
{
role: 'hide',
2017-04-05 18:29:43 +00:00
},
{
role: 'hideothers',
2017-04-05 18:29:43 +00:00
},
{
role: 'unhide',
2017-04-05 18:29:43 +00:00
},
{
type: 'separator',
2017-04-05 18:29:43 +00:00
},
{
role: 'quit',
},
],
});
// Add to Edit menu
New design for import/install, 'light' import (#2053) - A new design for the import flow. It features: - Icons at the top of every screen - Gray background, blue buttons, thinner text - Simpler copy - A new design for the install flow. It features: - Immediate entry into the QR code screen - Animated dots to show that we're loading the QR code from the server - Fewer screens: 1) QR 2) device name 3) sync-in-progress - When not set up, the app opens directly into the install screen, which has been streamlined. The `--import` command-line argument will cause the app to open directly into the import flow. - Support for two different flavors of builds - the normal build will open into the standard registration flow, and the import flavor will be exactly the same except during setup it will open directly into the import flow. - A new design for the (dev-only) standalone registration view - When these install sequences are active, the OS File menu has entries to allow you to switch the method of setup you'd like to use. These go away as soon as the first step is taken in any of these flows. - The device name (chosen on initial setup) is now shown in the settings panel - At the end of a light import, we hand off to the normal device link screen, starting at the QR code. On a full import, we remove the sensitive encryption information in the export to prevent conflicts on multiple imports. - `Whisper.Backup.exportToDirectory()` takes an options object so you can tell it to do a light export. - `Whisper.Backup.importFromDirectory()` takes an options object so you can force it to load only the light components found on disk. It also returns an object so you can tell whether a given import was a full import or light import. - On start of import, we build a list of all the ids present in the messages, conversations, and groups stores in IndexedDB. This can take some time if a lot of data is in the database already, but it makes the subsequent deduplicated import very fast. - Disappearing messages are now excluded when exporting - Remove some TODOs in the tests
2018-02-22 18:40:32 +00:00
const editIndex = options.includeSetup ? 2 : 1;
template[editIndex].submenu.push(
2017-04-05 18:29:43 +00:00
{
type: 'separator',
2017-04-05 18:29:43 +00:00
},
{
label: messages.speech.message,
2017-04-05 18:29:43 +00:00
submenu: [
{
role: 'startspeaking',
2017-04-05 18:29:43 +00:00
},
{
role: 'stopspeaking',
},
],
2017-04-05 18:29:43 +00:00
}
);
// Replace Window menu
const windowIndex = options.includeSetup ? 4 : 3;
// eslint-disable-next-line no-param-reassign
template[windowIndex].submenu = [
2017-04-05 18:29:43 +00:00
{
accelerator: 'CmdOrCtrl+W',
role: 'close',
2017-04-05 18:29:43 +00:00
},
{
accelerator: 'CmdOrCtrl+M',
role: 'minimize',
2017-04-05 18:29:43 +00:00
},
{
role: 'zoom',
2017-04-05 18:29:43 +00:00
},
{
label: messages.show.message,
click: showWindow,
},
2017-04-05 18:29:43 +00:00
{
type: 'separator',
2017-04-05 18:29:43 +00:00
},
{
role: 'front',
},
];
return template;
2017-04-05 18:29:43 +00:00
}
module.exports = createTemplate;