2018-02-08 21:58:47 +01:00
|
|
|
import {
|
|
|
|
app,
|
|
|
|
BrowserWindow,
|
2018-02-12 22:07:14 +01:00
|
|
|
clipboard,
|
2018-02-09 19:21:23 +01:00
|
|
|
dialog,
|
2018-02-10 21:30:42 +01:00
|
|
|
ipcMain,
|
2018-02-08 21:58:47 +01:00
|
|
|
Menu,
|
2018-02-13 21:00:38 +01:00
|
|
|
MenuItem,
|
2018-02-08 21:58:47 +01:00
|
|
|
MenuItemConstructorOptions,
|
2018-02-09 18:36:37 +01:00
|
|
|
shell,
|
2018-02-08 21:58:47 +01:00
|
|
|
} from 'electron';
|
|
|
|
|
2018-02-14 05:38:18 +01:00
|
|
|
import { Main } from '../main';
|
2018-02-09 06:21:00 +01:00
|
|
|
|
2018-02-08 19:10:13 +01:00
|
|
|
export class MenuMain {
|
2018-02-14 06:26:32 +01:00
|
|
|
menu: Menu;
|
|
|
|
updateMenuItem: MenuItem;
|
|
|
|
addNewLogin: MenuItem;
|
|
|
|
addNewItem: MenuItem;
|
|
|
|
addNewFolder: MenuItem;
|
|
|
|
syncVault: MenuItem;
|
|
|
|
settings: MenuItem;
|
|
|
|
lockNow: MenuItem;
|
|
|
|
logOut: MenuItem;
|
|
|
|
twoStepLogin: MenuItem;
|
|
|
|
changeEmail: MenuItem;
|
|
|
|
changeMasterPass: MenuItem;
|
|
|
|
premiumMembership: MenuItem;
|
|
|
|
passwordGenerator: MenuItem;
|
|
|
|
searchVault: MenuItem;
|
|
|
|
unlockedRequiredMenuItems: MenuItem[] = [];
|
|
|
|
|
2018-02-14 05:38:18 +01:00
|
|
|
constructor(private main: Main) { }
|
2018-02-08 19:10:13 +01:00
|
|
|
|
|
|
|
init() {
|
2018-02-14 05:06:45 +01:00
|
|
|
this.initContextMenu();
|
|
|
|
this.initApplicationMenu();
|
2018-02-14 06:26:32 +01:00
|
|
|
|
|
|
|
this.updateMenuItem = this.menu.getMenuItemById('checkForUpdates');
|
|
|
|
this.addNewLogin = this.menu.getMenuItemById('addNewLogin');
|
|
|
|
this.addNewItem = this.menu.getMenuItemById('addNewItem');
|
|
|
|
this.addNewFolder = this.menu.getMenuItemById('addNewFolder');
|
|
|
|
this.syncVault = this.menu.getMenuItemById('syncVault');
|
|
|
|
this.settings = this.menu.getMenuItemById('settings');
|
|
|
|
this.lockNow = this.menu.getMenuItemById('lockNow');
|
|
|
|
this.logOut = this.menu.getMenuItemById('logOut');
|
|
|
|
this.twoStepLogin = this.menu.getMenuItemById('twoStepLogin');
|
|
|
|
this.changeEmail = this.menu.getMenuItemById('changeEmail');
|
|
|
|
this.changeMasterPass = this.menu.getMenuItemById('changeMasterPass');
|
|
|
|
this.premiumMembership = this.menu.getMenuItemById('premiumMembership');
|
|
|
|
this.passwordGenerator = this.menu.getMenuItemById('passwordGenerator');
|
|
|
|
this.searchVault = this.menu.getMenuItemById('searchVault');
|
|
|
|
|
|
|
|
this.unlockedRequiredMenuItems = [
|
|
|
|
this.addNewLogin, this.addNewItem, this.addNewFolder,
|
|
|
|
this.syncVault, this.settings, this.lockNow, this.twoStepLogin, this.changeEmail,
|
|
|
|
this.changeMasterPass, this.premiumMembership, this.passwordGenerator, this.searchVault];
|
|
|
|
this.updateApplicationMenuState(false, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
updateApplicationMenuState(isAuthenticated: boolean, isLocked: boolean) {
|
|
|
|
this.unlockedRequiredMenuItems.forEach((mi: MenuItem) => {
|
|
|
|
mi.enabled = isAuthenticated && !isLocked;
|
|
|
|
});
|
|
|
|
|
|
|
|
this.logOut.enabled = isAuthenticated;
|
2018-02-14 05:06:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private initContextMenu() {
|
2018-02-16 15:59:03 +01:00
|
|
|
if (this.main.windowMain.win == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-02-14 05:06:45 +01:00
|
|
|
const selectionMenu = Menu.buildFromTemplate([
|
|
|
|
{ role: 'copy' },
|
|
|
|
{ type: 'separator' },
|
|
|
|
{ role: 'selectall' },
|
|
|
|
]);
|
|
|
|
|
|
|
|
const inputMenu = Menu.buildFromTemplate([
|
|
|
|
{ role: 'undo' },
|
|
|
|
{ role: 'redo' },
|
|
|
|
{ type: 'separator' },
|
|
|
|
{ role: 'cut', enabled: false },
|
|
|
|
{ role: 'copy', enabled: false },
|
|
|
|
{ role: 'paste' },
|
|
|
|
{ type: 'separator' },
|
|
|
|
{ role: 'selectall' },
|
|
|
|
]);
|
|
|
|
|
|
|
|
const inputSelectionMenu = Menu.buildFromTemplate([
|
|
|
|
{ role: 'cut' },
|
|
|
|
{ role: 'copy' },
|
|
|
|
{ role: 'paste' },
|
|
|
|
{ type: 'separator' },
|
|
|
|
{ role: 'selectall' },
|
|
|
|
]);
|
|
|
|
|
2018-02-14 05:38:18 +01:00
|
|
|
this.main.windowMain.win.webContents.on('context-menu', (e, props) => {
|
2018-02-14 05:06:45 +01:00
|
|
|
const selected = props.selectionText && props.selectionText.trim() !== '';
|
|
|
|
if (props.isEditable && selected) {
|
2018-02-14 05:38:18 +01:00
|
|
|
inputSelectionMenu.popup(this.main.windowMain.win);
|
2018-02-14 05:06:45 +01:00
|
|
|
} else if (props.isEditable) {
|
2018-02-14 05:38:18 +01:00
|
|
|
inputMenu.popup(this.main.windowMain.win);
|
2018-02-14 05:06:45 +01:00
|
|
|
} else if (selected) {
|
2018-02-14 05:38:18 +01:00
|
|
|
selectionMenu.popup(this.main.windowMain.win);
|
2018-02-14 05:06:45 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
private initApplicationMenu() {
|
2018-02-08 19:10:13 +01:00
|
|
|
const template: MenuItemConstructorOptions[] = [
|
2018-02-08 21:58:47 +01:00
|
|
|
{
|
2018-02-14 05:38:18 +01:00
|
|
|
label: this.main.i18nService.t('file'),
|
2018-02-08 21:58:47 +01:00
|
|
|
submenu: [
|
|
|
|
{
|
2018-02-14 05:38:18 +01:00
|
|
|
label: this.main.i18nService.t('addNewLogin'),
|
|
|
|
click: () => this.main.messagingService.send('newLogin'),
|
2018-02-10 21:30:42 +01:00
|
|
|
accelerator: 'CmdOrCtrl+N',
|
2018-02-14 06:26:32 +01:00
|
|
|
id: 'addNewLogin',
|
2018-02-09 06:21:00 +01:00
|
|
|
},
|
|
|
|
{
|
2018-02-14 05:38:18 +01:00
|
|
|
label: this.main.i18nService.t('addNewItem'),
|
2018-02-14 06:26:32 +01:00
|
|
|
id: 'addNewItem',
|
2018-02-08 21:58:47 +01:00
|
|
|
submenu: [
|
|
|
|
{
|
2018-02-14 05:38:18 +01:00
|
|
|
label: this.main.i18nService.t('typeLogin'),
|
|
|
|
click: () => this.main.messagingService.send('newLogin'),
|
2018-02-10 21:30:42 +01:00
|
|
|
accelerator: 'Alt+L',
|
2018-02-08 21:58:47 +01:00
|
|
|
},
|
|
|
|
{
|
2018-02-14 05:38:18 +01:00
|
|
|
label: this.main.i18nService.t('typeCard'),
|
|
|
|
click: () => this.main.messagingService.send('newCard'),
|
2018-02-10 21:30:42 +01:00
|
|
|
accelerator: 'Alt+C',
|
2018-02-08 21:58:47 +01:00
|
|
|
},
|
|
|
|
{
|
2018-02-14 05:38:18 +01:00
|
|
|
label: this.main.i18nService.t('typeIdentity'),
|
|
|
|
click: () => this.main.messagingService.send('newIdentity'),
|
2018-02-10 21:30:42 +01:00
|
|
|
accelerator: 'Alt+I',
|
2018-02-08 21:58:47 +01:00
|
|
|
},
|
|
|
|
{
|
2018-02-14 05:38:18 +01:00
|
|
|
label: this.main.i18nService.t('typeSecureNote'),
|
|
|
|
click: () => this.main.messagingService.send('newSecureNote'),
|
2018-02-10 21:30:42 +01:00
|
|
|
accelerator: 'Alt+S',
|
|
|
|
},
|
|
|
|
],
|
2018-02-08 21:58:47 +01:00
|
|
|
},
|
|
|
|
{
|
2018-02-14 05:38:18 +01:00
|
|
|
label: this.main.i18nService.t('addNewFolder'),
|
2018-02-14 06:26:32 +01:00
|
|
|
id: 'addNewFolder',
|
2018-02-14 05:38:18 +01:00
|
|
|
click: () => this.main.messagingService.send('newFolder'),
|
2018-02-08 21:58:47 +01:00
|
|
|
},
|
2018-02-09 06:21:00 +01:00
|
|
|
{ type: 'separator' },
|
2018-02-09 19:21:23 +01:00
|
|
|
{
|
2018-02-14 05:38:18 +01:00
|
|
|
label: this.main.i18nService.t('syncVault'),
|
2018-02-14 06:26:32 +01:00
|
|
|
id: 'syncVault',
|
2018-02-14 05:38:18 +01:00
|
|
|
click: () => this.main.messagingService.send('syncVault'),
|
2018-02-09 19:21:23 +01:00
|
|
|
},
|
2018-02-10 21:30:42 +01:00
|
|
|
],
|
2018-02-08 21:58:47 +01:00
|
|
|
},
|
2018-02-08 19:10:13 +01:00
|
|
|
{
|
2018-02-14 05:38:18 +01:00
|
|
|
label: this.main.i18nService.t('edit'),
|
2018-02-08 19:10:13 +01:00
|
|
|
submenu: [
|
|
|
|
{ role: 'undo' },
|
|
|
|
{ role: 'redo' },
|
|
|
|
{ type: 'separator' },
|
|
|
|
{ role: 'cut' },
|
|
|
|
{ role: 'copy' },
|
|
|
|
{ role: 'paste' },
|
2018-02-14 05:11:32 +01:00
|
|
|
{ type: 'separator' },
|
|
|
|
{ role: 'selectall' },
|
2018-02-10 21:30:42 +01:00
|
|
|
],
|
2018-02-08 19:10:13 +01:00
|
|
|
},
|
|
|
|
{
|
2018-02-14 05:38:18 +01:00
|
|
|
label: this.main.i18nService.t('view'),
|
2018-02-08 19:10:13 +01:00
|
|
|
submenu: [
|
2018-02-09 06:21:00 +01:00
|
|
|
{
|
2018-02-14 05:38:18 +01:00
|
|
|
label: this.main.i18nService.t('passwordGenerator'),
|
2018-02-14 06:26:32 +01:00
|
|
|
id: 'passwordGenerator',
|
2018-02-14 05:38:18 +01:00
|
|
|
click: () => this.main.messagingService.send('openPasswordGenerator'),
|
2018-02-10 21:30:42 +01:00
|
|
|
accelerator: 'CmdOrCtrl+G',
|
2018-02-09 18:12:41 +01:00
|
|
|
},
|
2018-02-09 06:21:00 +01:00
|
|
|
{
|
2018-02-14 05:38:18 +01:00
|
|
|
label: this.main.i18nService.t('searchVault'),
|
2018-02-14 06:26:32 +01:00
|
|
|
id: 'searchVault',
|
2018-02-14 05:38:18 +01:00
|
|
|
click: () => this.main.messagingService.send('focusSearch'),
|
2018-02-10 21:30:42 +01:00
|
|
|
accelerator: 'CmdOrCtrl+F',
|
2018-02-09 06:21:00 +01:00
|
|
|
},
|
2018-02-08 19:10:13 +01:00
|
|
|
{ type: 'separator' },
|
2018-02-09 18:12:41 +01:00
|
|
|
{ role: 'zoomin', accelerator: 'CmdOrCtrl+=' },
|
|
|
|
{ role: 'zoomout', accelerator: 'CmdOrCtrl+-' },
|
2018-02-09 18:36:37 +01:00
|
|
|
{ role: 'resetzoom', accelerator: 'CmdOrCtrl+0' },
|
2018-02-09 18:12:41 +01:00
|
|
|
{ type: 'separator' },
|
|
|
|
{ role: 'togglefullscreen' },
|
|
|
|
{ type: 'separator' },
|
|
|
|
{ role: 'reload', accelerator: 'Alt+Shift+R' },
|
|
|
|
{ role: 'forcereload' },
|
|
|
|
{ role: 'toggledevtools' },
|
2018-02-10 21:30:42 +01:00
|
|
|
],
|
2018-02-08 19:10:13 +01:00
|
|
|
},
|
2018-02-08 21:58:47 +01:00
|
|
|
{
|
2018-02-14 05:38:18 +01:00
|
|
|
label: this.main.i18nService.t('account'),
|
2018-02-08 21:58:47 +01:00
|
|
|
submenu: [
|
2018-02-09 19:21:23 +01:00
|
|
|
{
|
2018-02-14 05:38:18 +01:00
|
|
|
label: this.main.i18nService.t('premiumMembership'),
|
|
|
|
click: () => this.main.messagingService.send('premiumMembership'),
|
2018-02-14 06:26:32 +01:00
|
|
|
id: 'premiumMembership',
|
2018-02-09 19:21:23 +01:00
|
|
|
},
|
|
|
|
{
|
2018-02-14 05:38:18 +01:00
|
|
|
label: this.main.i18nService.t('changeMasterPass'),
|
2018-02-14 06:26:32 +01:00
|
|
|
id: 'changeMasterPass',
|
2018-02-10 21:30:42 +01:00
|
|
|
click: () => {
|
2018-02-14 05:38:18 +01:00
|
|
|
const result = dialog.showMessageBox(this.main.windowMain.win, {
|
|
|
|
title: this.main.i18nService.t('changeMasterPass'),
|
|
|
|
message: this.main.i18nService.t('changeMasterPasswordConfirmation'),
|
|
|
|
buttons: [this.main.i18nService.t('yes'), this.main.i18nService.t('no')],
|
2018-02-09 19:21:23 +01:00
|
|
|
cancelId: 1,
|
|
|
|
defaultId: 0,
|
|
|
|
noLink: true,
|
|
|
|
});
|
|
|
|
if (result === 0) {
|
|
|
|
shell.openExternal('https://vault.bitwarden.com');
|
|
|
|
}
|
2018-02-10 21:30:42 +01:00
|
|
|
},
|
2018-02-09 19:21:23 +01:00
|
|
|
},
|
|
|
|
{
|
2018-02-14 05:38:18 +01:00
|
|
|
label: this.main.i18nService.t('changeEmail'),
|
2018-02-14 06:26:32 +01:00
|
|
|
id: 'changeEmail',
|
2018-02-10 21:30:42 +01:00
|
|
|
click: () => {
|
2018-02-14 05:38:18 +01:00
|
|
|
const result = dialog.showMessageBox(this.main.windowMain.win, {
|
|
|
|
title: this.main.i18nService.t('changeEmail'),
|
|
|
|
message: this.main.i18nService.t('changeEmailConfirmation'),
|
|
|
|
buttons: [this.main.i18nService.t('yes'), this.main.i18nService.t('no')],
|
2018-02-09 19:21:23 +01:00
|
|
|
cancelId: 1,
|
|
|
|
defaultId: 0,
|
|
|
|
noLink: true,
|
|
|
|
});
|
|
|
|
if (result === 0) {
|
|
|
|
shell.openExternal('https://vault.bitwarden.com');
|
|
|
|
}
|
2018-02-10 21:30:42 +01:00
|
|
|
},
|
2018-02-09 19:21:23 +01:00
|
|
|
},
|
2018-02-10 22:06:39 +01:00
|
|
|
{
|
2018-02-14 05:38:18 +01:00
|
|
|
label: this.main.i18nService.t('twoStepLogin'),
|
2018-02-14 06:26:32 +01:00
|
|
|
id: 'twoStepLogin',
|
2018-02-10 22:06:39 +01:00
|
|
|
click: () => {
|
2018-02-14 05:38:18 +01:00
|
|
|
const result = dialog.showMessageBox(this.main.windowMain.win, {
|
|
|
|
title: this.main.i18nService.t('twoStepLogin'),
|
|
|
|
message: this.main.i18nService.t('twoStepLoginConfirmation'),
|
|
|
|
buttons: [this.main.i18nService.t('yes'), this.main.i18nService.t('no')],
|
2018-02-10 22:06:39 +01:00
|
|
|
cancelId: 1,
|
|
|
|
defaultId: 0,
|
|
|
|
noLink: true,
|
|
|
|
});
|
|
|
|
if (result === 0) {
|
|
|
|
shell.openExternal('https://vault.bitwarden.com');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
2018-02-09 19:21:23 +01:00
|
|
|
{ type: 'separator' },
|
2018-02-08 21:58:47 +01:00
|
|
|
{
|
2018-02-14 05:38:18 +01:00
|
|
|
label: this.main.i18nService.t('logOut'),
|
2018-02-14 06:26:32 +01:00
|
|
|
id: 'logOut',
|
2018-02-10 21:30:42 +01:00
|
|
|
click: () => {
|
2018-02-14 05:38:18 +01:00
|
|
|
const result = dialog.showMessageBox(this.main.windowMain.win, {
|
|
|
|
title: this.main.i18nService.t('logOut'),
|
|
|
|
message: this.main.i18nService.t('logOutConfirmation'),
|
|
|
|
buttons: [this.main.i18nService.t('logOut'), this.main.i18nService.t('cancel')],
|
2018-02-09 19:21:23 +01:00
|
|
|
cancelId: 1,
|
|
|
|
defaultId: 0,
|
|
|
|
noLink: true,
|
|
|
|
});
|
|
|
|
if (result === 0) {
|
2018-02-14 05:38:18 +01:00
|
|
|
this.main.messagingService.send('logout');
|
2018-02-09 19:21:23 +01:00
|
|
|
}
|
2018-02-10 21:30:42 +01:00
|
|
|
},
|
2018-02-08 21:58:47 +01:00
|
|
|
},
|
2018-02-10 21:30:42 +01:00
|
|
|
],
|
2018-02-08 21:58:47 +01:00
|
|
|
},
|
2018-02-08 19:10:13 +01:00
|
|
|
{
|
|
|
|
role: 'window',
|
|
|
|
submenu: [
|
|
|
|
{ role: 'minimize' },
|
2018-02-10 21:30:42 +01:00
|
|
|
{ role: 'close' },
|
|
|
|
],
|
2018-02-08 19:10:13 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
role: 'help',
|
|
|
|
submenu: [
|
|
|
|
{
|
2018-02-14 05:38:18 +01:00
|
|
|
label: this.main.i18nService.t('emailUs'),
|
2018-02-10 22:06:39 +01:00
|
|
|
click: () => shell.openExternal('mailTo:hello@bitwarden.com'),
|
2018-02-09 18:36:37 +01:00
|
|
|
},
|
|
|
|
{
|
2018-02-14 05:38:18 +01:00
|
|
|
label: this.main.i18nService.t('visitOurWebsite'),
|
2018-02-10 22:06:39 +01:00
|
|
|
click: () => shell.openExternal('https://bitwarden.com/contact'),
|
2018-02-09 18:36:37 +01:00
|
|
|
},
|
|
|
|
{
|
2018-02-14 05:38:18 +01:00
|
|
|
label: this.main.i18nService.t('fileBugReport'),
|
2018-02-10 22:06:39 +01:00
|
|
|
click: () => shell.openExternal('https://github.com/bitwarden/desktop'),
|
2018-02-09 18:36:37 +01:00
|
|
|
},
|
|
|
|
{ type: 'separator' },
|
|
|
|
{
|
2018-02-14 05:38:18 +01:00
|
|
|
label: this.main.i18nService.t('followUs'),
|
2018-02-09 19:21:23 +01:00
|
|
|
submenu: [
|
|
|
|
{
|
2018-02-14 05:38:18 +01:00
|
|
|
label: this.main.i18nService.t('blog'),
|
2018-02-10 22:06:39 +01:00
|
|
|
click: () => shell.openExternal('https://blog.bitwarden.com'),
|
2018-02-09 19:21:23 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Twitter',
|
2018-02-10 22:06:39 +01:00
|
|
|
click: () => shell.openExternal('https://twitter.com/bitwarden_app'),
|
2018-02-09 19:21:23 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Facebook',
|
2018-02-10 22:06:39 +01:00
|
|
|
click: () => shell.openExternal('https://www.facebook.com/bitwarden/'),
|
2018-02-09 19:21:23 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Google+',
|
2018-02-10 22:06:39 +01:00
|
|
|
click: () => shell.openExternal('https://plus.google.com/114869903467947368993'),
|
2018-02-09 19:21:23 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'GitHub',
|
2018-02-10 22:06:39 +01:00
|
|
|
click: () => shell.openExternal('https://github.com/bitwarden'),
|
2018-02-10 21:30:42 +01:00
|
|
|
},
|
|
|
|
],
|
2018-02-09 18:36:37 +01:00
|
|
|
},
|
2018-02-09 19:21:23 +01:00
|
|
|
{ type: 'separator' },
|
2018-02-09 18:36:37 +01:00
|
|
|
{
|
2018-02-14 05:38:18 +01:00
|
|
|
label: this.main.i18nService.t('goToWebVault'),
|
2018-02-10 22:06:39 +01:00
|
|
|
click: () => shell.openExternal('https://vault.bitwarden.com'),
|
2018-02-09 18:36:37 +01:00
|
|
|
},
|
|
|
|
{
|
2018-02-14 05:38:18 +01:00
|
|
|
label: this.main.i18nService.t('getMobileApp'),
|
2018-02-09 19:21:23 +01:00
|
|
|
submenu: [
|
|
|
|
{
|
|
|
|
label: 'iOS',
|
2018-02-10 21:30:42 +01:00
|
|
|
click: () => {
|
2018-02-09 19:21:23 +01:00
|
|
|
shell.openExternal('https://itunes.apple.com/app/' +
|
|
|
|
'bitwarden-free-password-manager/id1137397744?mt=8');
|
2018-02-10 21:30:42 +01:00
|
|
|
},
|
2018-02-09 19:21:23 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Android',
|
2018-02-10 21:30:42 +01:00
|
|
|
click: () => {
|
2018-02-09 19:21:23 +01:00
|
|
|
shell.openExternal('https://play.google.com/store/apps/' +
|
|
|
|
'details?id=com.x8bit.bitwarden');
|
2018-02-10 21:30:42 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
2018-02-09 18:36:37 +01:00
|
|
|
},
|
|
|
|
{
|
2018-02-14 05:38:18 +01:00
|
|
|
label: this.main.i18nService.t('getBrowserExtension'),
|
2018-02-09 19:21:23 +01:00
|
|
|
submenu: [
|
|
|
|
{
|
|
|
|
label: 'Chrome',
|
2018-02-10 21:30:42 +01:00
|
|
|
click: () => {
|
2018-02-09 19:21:23 +01:00
|
|
|
shell.openExternal('https://chrome.google.com/webstore/detail/' +
|
|
|
|
+'bitwarden-free-password-m/nngceckbapebfimnlniiiahkandclblb');
|
2018-02-10 21:30:42 +01:00
|
|
|
},
|
2018-02-09 19:21:23 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Firefox',
|
2018-02-10 21:30:42 +01:00
|
|
|
click: () => {
|
2018-02-09 19:21:23 +01:00
|
|
|
shell.openExternal('https://addons.mozilla.org/firefox/addon/' +
|
|
|
|
'bitwarden-password-manager/');
|
2018-02-10 21:30:42 +01:00
|
|
|
},
|
2018-02-09 19:21:23 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Opera',
|
2018-02-10 21:30:42 +01:00
|
|
|
click: () => {
|
2018-02-09 19:21:23 +01:00
|
|
|
shell.openExternal('https://addons.opera.com/extensions/details/' +
|
|
|
|
'bitwarden-free-password-manager/');
|
2018-02-10 21:30:42 +01:00
|
|
|
},
|
2018-02-09 19:21:23 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Edge',
|
2018-02-10 21:30:42 +01:00
|
|
|
click: () => {
|
2018-02-09 19:21:23 +01:00
|
|
|
shell.openExternal('https://www.microsoft.com/store/p/' +
|
|
|
|
'bitwarden-free-password-manager/9p6kxl0svnnl');
|
2018-02-10 21:30:42 +01:00
|
|
|
},
|
2018-02-09 19:21:23 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Safari',
|
2018-02-10 21:30:42 +01:00
|
|
|
click: () => {
|
2018-02-09 19:21:23 +01:00
|
|
|
shell.openExternal('https://safari-extensions.apple.com/details/' +
|
|
|
|
'?id=com.bitwarden.safari-LTZ2PFU5D6');
|
2018-02-10 21:30:42 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2018-02-08 19:10:13 +01:00
|
|
|
];
|
|
|
|
|
2018-02-10 23:07:46 +01:00
|
|
|
const firstMenuOptions: MenuItemConstructorOptions[] = [
|
|
|
|
{ type: 'separator' },
|
|
|
|
{
|
2018-02-14 05:38:18 +01:00
|
|
|
label: this.main.i18nService.t('settings'),
|
2018-02-14 06:26:32 +01:00
|
|
|
id: 'settings',
|
2018-02-14 05:38:18 +01:00
|
|
|
click: () => this.main.messagingService.send('openSettings'),
|
2018-02-10 23:07:46 +01:00
|
|
|
},
|
|
|
|
{
|
2018-02-14 05:38:18 +01:00
|
|
|
label: this.main.i18nService.t('lockNow'),
|
2018-02-14 06:26:32 +01:00
|
|
|
id: 'lockNow',
|
2018-02-14 05:38:18 +01:00
|
|
|
click: () => this.main.messagingService.send('lockVault'),
|
2018-02-10 23:07:46 +01:00
|
|
|
accelerator: 'CmdOrCtrl+L',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2018-02-14 04:33:01 +01:00
|
|
|
const updateMenuItem = {
|
2018-02-14 05:38:18 +01:00
|
|
|
label: this.main.i18nService.t('checkForUpdates'),
|
|
|
|
click: () => this.main.updaterMain.checkForUpdate(true),
|
2018-02-14 04:33:01 +01:00
|
|
|
id: 'checkForUpdates',
|
|
|
|
};
|
|
|
|
|
2018-02-08 19:10:13 +01:00
|
|
|
if (process.platform === 'darwin') {
|
2018-02-10 23:07:46 +01:00
|
|
|
const firstMenuPart: MenuItemConstructorOptions[] = [
|
2018-02-08 21:58:47 +01:00
|
|
|
{ role: 'about' },
|
2018-02-14 04:33:01 +01:00
|
|
|
updateMenuItem,
|
2018-02-10 23:07:46 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
template.unshift({
|
|
|
|
label: 'Bitwarden',
|
|
|
|
submenu: firstMenuPart.concat(firstMenuOptions, [
|
|
|
|
{ type: 'separator' },
|
|
|
|
{ role: 'services', submenu: [] },
|
|
|
|
{ type: 'separator' },
|
|
|
|
{ role: 'hide' },
|
|
|
|
{ role: 'hideothers' },
|
|
|
|
{ role: 'unhide' },
|
|
|
|
{ type: 'separator' },
|
|
|
|
{ role: 'quit' },
|
|
|
|
]),
|
|
|
|
});
|
2018-02-08 19:10:13 +01:00
|
|
|
|
|
|
|
// Window menu
|
2018-02-10 23:07:46 +01:00
|
|
|
template[template.length - 2].submenu = [
|
2018-02-08 19:10:13 +01:00
|
|
|
{ role: 'close' },
|
|
|
|
{ role: 'minimize' },
|
|
|
|
{ role: 'zoom' },
|
|
|
|
{ type: 'separator' },
|
2018-02-10 21:30:42 +01:00
|
|
|
{ role: 'front' },
|
|
|
|
];
|
2018-02-10 23:07:46 +01:00
|
|
|
} else {
|
2018-02-12 22:07:14 +01:00
|
|
|
// File menu
|
2018-02-10 23:07:46 +01:00
|
|
|
template[0].submenu = (template[0].submenu as MenuItemConstructorOptions[]).concat(
|
|
|
|
firstMenuOptions);
|
2018-02-12 22:07:14 +01:00
|
|
|
|
|
|
|
// About menu
|
|
|
|
template[template.length - 1].submenu =
|
|
|
|
(template[template.length - 1].submenu as MenuItemConstructorOptions[]).concat([
|
|
|
|
{ type: 'separator' },
|
2018-02-14 04:33:01 +01:00
|
|
|
updateMenuItem,
|
2018-02-12 22:07:14 +01:00
|
|
|
{
|
2018-02-14 05:38:18 +01:00
|
|
|
label: this.main.i18nService.t('about'),
|
2018-02-12 22:07:14 +01:00
|
|
|
click: () => {
|
2018-02-14 05:38:18 +01:00
|
|
|
const aboutInformation = this.main.i18nService.t('version', app.getVersion()) +
|
2018-02-12 22:12:18 +01:00
|
|
|
'\nShell ' + process.versions.electron +
|
|
|
|
'\nRenderer ' + process.versions.chrome +
|
|
|
|
'\nNode ' + process.versions.node +
|
2018-02-12 22:07:14 +01:00
|
|
|
'\nArchitecture ' + process.arch;
|
2018-02-14 05:38:18 +01:00
|
|
|
const result = dialog.showMessageBox(this.main.windowMain.win, {
|
2018-02-12 22:07:14 +01:00
|
|
|
title: 'Bitwarden',
|
|
|
|
message: 'Bitwarden',
|
|
|
|
detail: aboutInformation,
|
|
|
|
type: 'info',
|
|
|
|
noLink: true,
|
2018-02-14 05:38:18 +01:00
|
|
|
buttons: [this.main.i18nService.t('ok'), this.main.i18nService.t('copy')],
|
2018-02-12 22:07:14 +01:00
|
|
|
});
|
|
|
|
if (result === 1) {
|
|
|
|
clipboard.writeText(aboutInformation);
|
|
|
|
}
|
|
|
|
},
|
2018-02-12 22:12:18 +01:00
|
|
|
},
|
2018-02-12 22:07:14 +01:00
|
|
|
]);
|
2018-02-08 21:58:47 +01:00
|
|
|
}
|
2018-02-08 19:10:13 +01:00
|
|
|
|
2018-02-14 06:26:32 +01:00
|
|
|
this.menu = Menu.buildFromTemplate(template);
|
|
|
|
Menu.setApplicationMenu(this.menu);
|
2018-02-08 19:10:13 +01:00
|
|
|
}
|
|
|
|
}
|