5 changed files with 146 additions and 32 deletions
@ -0,0 +1,19 @@
@@ -0,0 +1,19 @@
|
||||
{ |
||||
"version": "0.2.0", |
||||
"configurations": [ |
||||
{ |
||||
"name": "Debug Main Process", |
||||
"type": "node", |
||||
"request": "launch", |
||||
"cwd": "${workspaceRoot}/build", |
||||
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron", |
||||
"windows": { |
||||
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd" |
||||
}, |
||||
"args": [ |
||||
"." |
||||
] |
||||
} |
||||
] |
||||
} |
||||
|
||||
@ -1 +1 @@
@@ -1 +1 @@
|
||||
Subproject commit 6e6dc422ac13047427d21d44463a5de2a3db7ebb |
||||
Subproject commit 42bf9b2edbafcda5d180df6d2746f19881a63315 |
||||
@ -0,0 +1,112 @@
@@ -0,0 +1,112 @@
|
||||
import { |
||||
app, |
||||
BrowserWindow, |
||||
clipboard, |
||||
dialog, |
||||
ipcMain, |
||||
Menu, |
||||
MenuItem, |
||||
MenuItemConstructorOptions, |
||||
shell, |
||||
} from 'electron'; |
||||
|
||||
import { Main } from '../main'; |
||||
|
||||
import { BaseMenu } from 'jslib/electron/baseMenu'; |
||||
|
||||
import { ConstantsService } from 'jslib/services/constants.service'; |
||||
|
||||
export class MenuMain extends BaseMenu { |
||||
menu: Menu; |
||||
logOut: MenuItem; |
||||
|
||||
constructor(private main: Main) { |
||||
super(main.i18nService, main.windowMain, 'Bitwarden Directory Connector', |
||||
() => { /* TODO: Log Out Message */ }); |
||||
} |
||||
|
||||
init() { |
||||
this.initProperties(); |
||||
this.initContextMenu(); |
||||
this.initApplicationMenu(); |
||||
|
||||
this.logOut = this.menu.getMenuItemById('logOut'); |
||||
this.updateApplicationMenuState(false, true); |
||||
} |
||||
|
||||
updateApplicationMenuState(isAuthenticated: boolean, isLocked: boolean) { |
||||
this.logOut.enabled = isAuthenticated; |
||||
} |
||||
|
||||
private initApplicationMenu() { |
||||
const accountSubmenu: MenuItemConstructorOptions[] = [ |
||||
this.logOutMenuItemOptions, |
||||
]; |
||||
|
||||
const template: MenuItemConstructorOptions[] = [ |
||||
{ |
||||
label: this.i18nService.t('file'), |
||||
submenu: [ this.logOutMenuItemOptions ], |
||||
}, |
||||
this.editMenuItemOptions, |
||||
{ |
||||
label: this.main.i18nService.t('view'), |
||||
submenu: this.viewSubMenuItemOptions, |
||||
}, |
||||
this.windowMenuItemOptions, |
||||
]; |
||||
|
||||
const firstMenuOptions: MenuItemConstructorOptions[] = [ |
||||
{ type: 'separator' }, |
||||
{ |
||||
label: this.i18nService.t('settings'), |
||||
id: 'settings', |
||||
click: () => { /* Something */ }, |
||||
}, |
||||
]; |
||||
|
||||
const updateMenuItem = { |
||||
label: this.i18nService.t('checkForUpdates'), |
||||
click: () => { /* Something */ }, |
||||
id: 'checkForUpdates', |
||||
}; |
||||
|
||||
if (process.platform === 'darwin') { |
||||
const firstMenuPart: MenuItemConstructorOptions[] = [ |
||||
{ |
||||
label: this.i18nService.t('aboutBitwarden'), |
||||
role: 'about', |
||||
}, |
||||
updateMenuItem, |
||||
]; |
||||
|
||||
template.unshift({ |
||||
label: this.appName, |
||||
submenu: firstMenuPart.concat(firstMenuOptions, [ |
||||
{ type: 'separator' }, |
||||
], this.macAppMenuItemOptions), |
||||
}); |
||||
|
||||
// Window menu
|
||||
template[template.length - 1].submenu = this.macWindowSubmenuOptions; |
||||
} else { |
||||
// File menu
|
||||
template[0].submenu = (template[0].submenu as MenuItemConstructorOptions[]).concat( |
||||
firstMenuOptions); |
||||
|
||||
// About menu
|
||||
const aboutMenuAdditions: MenuItemConstructorOptions[] = [ |
||||
{ type: 'separator' }, |
||||
updateMenuItem, |
||||
]; |
||||
|
||||
aboutMenuAdditions.push(this.aboutMenuItemOptions); |
||||
|
||||
template[template.length - 1].submenu = |
||||
(template[template.length - 1].submenu as MenuItemConstructorOptions[]).concat(aboutMenuAdditions); |
||||
} |
||||
|
||||
this.menu = Menu.buildFromTemplate(template); |
||||
Menu.setApplicationMenu(this.menu); |
||||
} |
||||
} |
||||
Loading…
Reference in new issue