[Account Switching] Fix menus (#1232)
* Fix enabled/disabling menu items with locked state * Fix the empty about menu (title) Moved the items to the help menu
This commit is contained in:
parent
b6117d6801
commit
7818ffc2fb
|
@ -10,12 +10,8 @@ import { IMenubarMenu } from "./menubar";
|
||||||
export class AboutMenu implements IMenubarMenu {
|
export class AboutMenu implements IMenubarMenu {
|
||||||
readonly id: string = "about";
|
readonly id: string = "about";
|
||||||
|
|
||||||
get visible(): boolean {
|
|
||||||
return !isMac();
|
|
||||||
}
|
|
||||||
|
|
||||||
get label(): string {
|
get label(): string {
|
||||||
return this.localize("about");
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
get items(): MenuItemConstructorOptions[] {
|
get items(): MenuItemConstructorOptions[] {
|
||||||
|
|
|
@ -27,20 +27,20 @@ export class AccountMenu implements IMenubarMenu {
|
||||||
private readonly _messagingService: MessagingService;
|
private readonly _messagingService: MessagingService;
|
||||||
private readonly _webVaultUrl: string;
|
private readonly _webVaultUrl: string;
|
||||||
private readonly _window: BrowserWindow;
|
private readonly _window: BrowserWindow;
|
||||||
private readonly _isAuthenticated: boolean;
|
private readonly _isLocked: boolean;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
i18nService: I18nService,
|
i18nService: I18nService,
|
||||||
messagingService: MessagingService,
|
messagingService: MessagingService,
|
||||||
webVaultUrl: string,
|
webVaultUrl: string,
|
||||||
window: BrowserWindow,
|
window: BrowserWindow,
|
||||||
isAuthenticated: boolean
|
isLocked: boolean
|
||||||
) {
|
) {
|
||||||
this._i18nService = i18nService;
|
this._i18nService = i18nService;
|
||||||
this._messagingService = messagingService;
|
this._messagingService = messagingService;
|
||||||
this._webVaultUrl = webVaultUrl;
|
this._webVaultUrl = webVaultUrl;
|
||||||
this._window = window;
|
this._window = window;
|
||||||
this._isAuthenticated = isAuthenticated;
|
this._isLocked = isLocked;
|
||||||
}
|
}
|
||||||
|
|
||||||
private get premiumMembership(): MenuItemConstructorOptions {
|
private get premiumMembership(): MenuItemConstructorOptions {
|
||||||
|
@ -49,7 +49,7 @@ export class AccountMenu implements IMenubarMenu {
|
||||||
click: () => this.sendMessage("openPremium"),
|
click: () => this.sendMessage("openPremium"),
|
||||||
id: "premiumMembership",
|
id: "premiumMembership",
|
||||||
visible: !isWindowsStore() && !isMacAppStore(),
|
visible: !isWindowsStore() && !isMacAppStore(),
|
||||||
enabled: this._isAuthenticated,
|
enabled: !this._isLocked,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ export class AccountMenu implements IMenubarMenu {
|
||||||
shell.openExternal(this._webVaultUrl);
|
shell.openExternal(this._webVaultUrl);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
enabled: this._isAuthenticated,
|
enabled: !this._isLocked,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ export class AccountMenu implements IMenubarMenu {
|
||||||
shell.openExternal(this._webVaultUrl);
|
shell.openExternal(this._webVaultUrl);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
enabled: this._isAuthenticated,
|
enabled: !this._isLocked,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ export class AccountMenu implements IMenubarMenu {
|
||||||
label: this.localize("fingerprintPhrase"),
|
label: this.localize("fingerprintPhrase"),
|
||||||
id: "fingerprintPhrase",
|
id: "fingerprintPhrase",
|
||||||
click: () => this.sendMessage("showFingerprintPhrase"),
|
click: () => this.sendMessage("showFingerprintPhrase"),
|
||||||
enabled: this._isAuthenticated,
|
enabled: !this._isLocked,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,16 +31,12 @@ export class EditMenu implements IMenubarMenu {
|
||||||
|
|
||||||
private readonly _i18nService: I18nService;
|
private readonly _i18nService: I18nService;
|
||||||
private readonly _messagingService: MessagingService;
|
private readonly _messagingService: MessagingService;
|
||||||
private readonly _isAuthenticated: boolean;
|
private readonly _isLocked: boolean;
|
||||||
|
|
||||||
constructor(
|
constructor(i18nService: I18nService, messagingService: MessagingService, isLocked: boolean) {
|
||||||
i18nService: I18nService,
|
|
||||||
messagingService: MessagingService,
|
|
||||||
isAuthenticated: boolean
|
|
||||||
) {
|
|
||||||
this._i18nService = i18nService;
|
this._i18nService = i18nService;
|
||||||
this._messagingService = messagingService;
|
this._messagingService = messagingService;
|
||||||
this._isAuthenticated = isAuthenticated;
|
this._isLocked = isLocked;
|
||||||
}
|
}
|
||||||
|
|
||||||
private get undo(): MenuItemConstructorOptions {
|
private get undo(): MenuItemConstructorOptions {
|
||||||
|
@ -101,7 +97,7 @@ export class EditMenu implements IMenubarMenu {
|
||||||
id: "copyUsername",
|
id: "copyUsername",
|
||||||
click: () => this.sendMessage("copyUsername"),
|
click: () => this.sendMessage("copyUsername"),
|
||||||
accelerator: "CmdOrCtrl+U",
|
accelerator: "CmdOrCtrl+U",
|
||||||
enabled: this._isAuthenticated,
|
enabled: !this._isLocked,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +107,7 @@ export class EditMenu implements IMenubarMenu {
|
||||||
id: "copyPassword",
|
id: "copyPassword",
|
||||||
click: () => this.sendMessage("copyPassword"),
|
click: () => this.sendMessage("copyPassword"),
|
||||||
accelerator: "CmdOrCtrl+P",
|
accelerator: "CmdOrCtrl+P",
|
||||||
enabled: this._isAuthenticated,
|
enabled: !this._isLocked,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,6 +117,7 @@ export class EditMenu implements IMenubarMenu {
|
||||||
id: "copyTotp",
|
id: "copyTotp",
|
||||||
click: () => this.sendMessage("copyTotp"),
|
click: () => this.sendMessage("copyTotp"),
|
||||||
accelerator: "CmdOrCtrl+T",
|
accelerator: "CmdOrCtrl+T",
|
||||||
|
enabled: !this._isLocked,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,16 +28,12 @@ export class FileMenu implements IMenubarMenu {
|
||||||
|
|
||||||
private readonly _i18nService: I18nService;
|
private readonly _i18nService: I18nService;
|
||||||
private readonly _messagingService: MessagingService;
|
private readonly _messagingService: MessagingService;
|
||||||
private readonly _isAuthenticated: boolean;
|
private readonly _isLocked: boolean;
|
||||||
|
|
||||||
constructor(
|
constructor(i18nService: I18nService, messagingService: MessagingService, isLocked: boolean) {
|
||||||
i18nService: I18nService,
|
|
||||||
messagingService: MessagingService,
|
|
||||||
isAuthenticated: boolean
|
|
||||||
) {
|
|
||||||
this._i18nService = i18nService;
|
this._i18nService = i18nService;
|
||||||
this._messagingService = messagingService;
|
this._messagingService = messagingService;
|
||||||
this._isAuthenticated = isAuthenticated;
|
this._isLocked = isLocked;
|
||||||
}
|
}
|
||||||
|
|
||||||
private get addNewLogin(): MenuItemConstructorOptions {
|
private get addNewLogin(): MenuItemConstructorOptions {
|
||||||
|
@ -46,6 +42,7 @@ export class FileMenu implements IMenubarMenu {
|
||||||
click: () => this.sendMessage("newLogin"),
|
click: () => this.sendMessage("newLogin"),
|
||||||
accelerator: "CmdOrCtrl+N",
|
accelerator: "CmdOrCtrl+N",
|
||||||
id: "addNewLogin",
|
id: "addNewLogin",
|
||||||
|
enabled: !this._isLocked,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +51,7 @@ export class FileMenu implements IMenubarMenu {
|
||||||
label: this.localize("addNewItem"),
|
label: this.localize("addNewItem"),
|
||||||
id: "addNewItem",
|
id: "addNewItem",
|
||||||
submenu: this.addNewItemSubmenu,
|
submenu: this.addNewItemSubmenu,
|
||||||
enabled: this._isAuthenticated,
|
enabled: !this._isLocked,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,6 +89,7 @@ export class FileMenu implements IMenubarMenu {
|
||||||
id: "addNewFolder",
|
id: "addNewFolder",
|
||||||
label: this.localize("addNewFolder"),
|
label: this.localize("addNewFolder"),
|
||||||
click: () => this.sendMessage("newFolder"),
|
click: () => this.sendMessage("newFolder"),
|
||||||
|
enabled: !this._isLocked,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,6 +102,7 @@ export class FileMenu implements IMenubarMenu {
|
||||||
id: "syncVault",
|
id: "syncVault",
|
||||||
label: this.localize("syncVault"),
|
label: this.localize("syncVault"),
|
||||||
click: () => this.sendMessage("syncVault"),
|
click: () => this.sendMessage("syncVault"),
|
||||||
|
enabled: !this._isLocked,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,6 +111,7 @@ export class FileMenu implements IMenubarMenu {
|
||||||
id: "exportVault",
|
id: "exportVault",
|
||||||
label: this.localize("exportVault"),
|
label: this.localize("exportVault"),
|
||||||
click: () => this.sendMessage("exportVault"),
|
click: () => this.sendMessage("exportVault"),
|
||||||
|
enabled: !this._isLocked,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import { shell } from "electron";
|
||||||
import { isMacAppStore, isWindowsStore } from "jslib-electron/utils";
|
import { isMacAppStore, isWindowsStore } from "jslib-electron/utils";
|
||||||
|
|
||||||
import { MenuItemConstructorOptions } from "electron";
|
import { MenuItemConstructorOptions } from "electron";
|
||||||
|
import { AboutMenu } from "./menu.about";
|
||||||
|
|
||||||
export class HelpMenu implements IMenubarMenu {
|
export class HelpMenu implements IMenubarMenu {
|
||||||
readonly id: string = "help";
|
readonly id: string = "help";
|
||||||
|
@ -15,7 +16,7 @@ export class HelpMenu implements IMenubarMenu {
|
||||||
}
|
}
|
||||||
|
|
||||||
get items(): MenuItemConstructorOptions[] {
|
get items(): MenuItemConstructorOptions[] {
|
||||||
return [
|
const items = [
|
||||||
this.emailUs,
|
this.emailUs,
|
||||||
this.visitOurWebsite,
|
this.visitOurWebsite,
|
||||||
this.fileBugReport,
|
this.fileBugReport,
|
||||||
|
@ -28,14 +29,21 @@ export class HelpMenu implements IMenubarMenu {
|
||||||
this.getMobileApp,
|
this.getMobileApp,
|
||||||
this.getBrowserExtension,
|
this.getBrowserExtension,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if (this._aboutMenu != null) {
|
||||||
|
items.push(...this._aboutMenu.items);
|
||||||
|
}
|
||||||
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly _i18nService: I18nService;
|
private readonly _i18nService: I18nService;
|
||||||
private readonly _webVaultUrl: string;
|
private readonly _webVaultUrl: string;
|
||||||
|
private readonly _aboutMenu: AboutMenu;
|
||||||
|
|
||||||
constructor(i18nService: I18nService, webVaultUrl: string) {
|
constructor(i18nService: I18nService, webVaultUrl: string, aboutMenu: AboutMenu) {
|
||||||
this._i18nService = i18nService;
|
this._i18nService = i18nService;
|
||||||
this._webVaultUrl = webVaultUrl;
|
this._webVaultUrl = webVaultUrl;
|
||||||
|
this._aboutMenu = aboutMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
private get emailUs(): MenuItemConstructorOptions {
|
private get emailUs(): MenuItemConstructorOptions {
|
||||||
|
|
|
@ -32,16 +32,12 @@ export class ViewMenu implements IMenubarMenu {
|
||||||
|
|
||||||
private readonly _i18nService: I18nService;
|
private readonly _i18nService: I18nService;
|
||||||
private readonly _messagingService: MessagingService;
|
private readonly _messagingService: MessagingService;
|
||||||
private readonly _isAuthenticated: boolean;
|
private readonly _isLocked: boolean;
|
||||||
|
|
||||||
constructor(
|
constructor(i18nService: I18nService, messagingService: MessagingService, isLocked: boolean) {
|
||||||
i18nService: I18nService,
|
|
||||||
messagingService: MessagingService,
|
|
||||||
isAuthenticated: boolean
|
|
||||||
) {
|
|
||||||
this._i18nService = i18nService;
|
this._i18nService = i18nService;
|
||||||
this._messagingService = messagingService;
|
this._messagingService = messagingService;
|
||||||
this._isAuthenticated = isAuthenticated;
|
this._isLocked = isLocked;
|
||||||
}
|
}
|
||||||
|
|
||||||
private get searchVault(): MenuItemConstructorOptions {
|
private get searchVault(): MenuItemConstructorOptions {
|
||||||
|
@ -50,7 +46,7 @@ export class ViewMenu implements IMenubarMenu {
|
||||||
label: this.localize("searchVault"),
|
label: this.localize("searchVault"),
|
||||||
click: () => this.sendMessage("focusSearch"),
|
click: () => this.sendMessage("focusSearch"),
|
||||||
accelerator: "CmdOrCtrl+F",
|
accelerator: "CmdOrCtrl+F",
|
||||||
enabled: this._isAuthenticated,
|
enabled: !this._isLocked,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +60,7 @@ export class ViewMenu implements IMenubarMenu {
|
||||||
label: this.localize("passwordGenerator"),
|
label: this.localize("passwordGenerator"),
|
||||||
click: () => this.sendMessage("openPasswordGenerator"),
|
click: () => this.sendMessage("openPasswordGenerator"),
|
||||||
accelerator: "CmdOrCtrl+G",
|
accelerator: "CmdOrCtrl+G",
|
||||||
enabled: this._isAuthenticated,
|
enabled: !this._isLocked,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +69,7 @@ export class ViewMenu implements IMenubarMenu {
|
||||||
id: "passwordHistory",
|
id: "passwordHistory",
|
||||||
label: this.localize("passwordHistory"),
|
label: this.localize("passwordHistory"),
|
||||||
click: () => this.sendMessage("openPasswordHistory"),
|
click: () => this.sendMessage("openPasswordHistory"),
|
||||||
enabled: this._isAuthenticated,
|
enabled: !this._isLocked,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,8 +74,11 @@ export class Menubar {
|
||||||
new ViewMenu(i18nService, messagingService, isLocked),
|
new ViewMenu(i18nService, messagingService, isLocked),
|
||||||
new AccountMenu(i18nService, messagingService, webVaultUrl, windowMain.win, isLocked),
|
new AccountMenu(i18nService, messagingService, webVaultUrl, windowMain.win, isLocked),
|
||||||
new WindowMenu(i18nService, messagingService, windowMain),
|
new WindowMenu(i18nService, messagingService, windowMain),
|
||||||
new AboutMenu(i18nService, appVersion, windowMain.win, updaterMain),
|
new HelpMenu(
|
||||||
new HelpMenu(i18nService, webVaultUrl),
|
i18nService,
|
||||||
|
webVaultUrl,
|
||||||
|
new AboutMenu(i18nService, appVersion, windowMain.win, updaterMain)
|
||||||
|
),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue