From f7037dd1f5f7a0c2a33fca37de3b7d4d0a641843 Mon Sep 17 00:00:00 2001 From: Elias Papavasileiou Date: Tue, 11 Feb 2020 05:37:25 +0200 Subject: [PATCH] Add copy username and copy password shortcuts (#379) --- src/app/vault/vault.component.ts | 12 ++++++++++++ src/main/menu.main.ts | 19 ++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/app/vault/vault.component.ts b/src/app/vault/vault.component.ts index 50775f3b58..e6e5914472 100644 --- a/src/app/vault/vault.component.ts +++ b/src/app/vault/vault.component.ts @@ -151,6 +151,18 @@ export class VaultComponent implements OnInit, OnDestroy { case 'modalClosed': this.showingModal = false; break; + case 'copyUsername': + const selectedCipherU = this.cipherId != null ? this.ciphersComponent.ciphers.find(cipher => cipher.id == this.cipherId) : null; + if (selectedCipherU != null && selectedCipherU.login != null && selectedCipherU.login.username != null) { + this.copyValue(selectedCipherU.login.username, 'username'); + } + break; + case 'copyPassword': + const selectedCipherP = this.cipherId != null ? this.ciphersComponent.ciphers.find(cipher => cipher.id == this.cipherId) : null; + if (selectedCipherP != null && selectedCipherP.login != null && selectedCipherP.login.password != null) { + this.copyValue(selectedCipherP.login.password, 'password'); + } + break; default: detectChanges = false; break; diff --git a/src/main/menu.main.ts b/src/main/menu.main.ts index 283635f58e..160cf44ced 100644 --- a/src/main/menu.main.ts +++ b/src/main/menu.main.ts @@ -36,6 +36,8 @@ export class MenuMain extends BaseMenu { passwordGenerator: MenuItem; passwordHistory: MenuItem; searchVault: MenuItem; + copyUsername: MenuItem; + copyPassword: MenuItem; unlockedRequiredMenuItems: MenuItem[] = []; constructor(private main: Main) { @@ -63,12 +65,14 @@ export class MenuMain extends BaseMenu { this.passwordGenerator = this.menu.getMenuItemById('passwordGenerator'); this.passwordHistory = this.menu.getMenuItemById('passwordHistory'); this.searchVault = this.menu.getMenuItemById('searchVault'); + this.copyUsername = this.menu.getMenuItemById('copyUsername'); + this.copyPassword = this.menu.getMenuItemById('copyPassword'); this.unlockedRequiredMenuItems = [ this.addNewLogin, this.addNewItem, this.addNewFolder, this.syncVault, this.exportVault, this.settings, this.lockNow, this.twoStepLogin, this.fingerprintPhrase, this.changeMasterPass, this.premiumMembership, this.passwordGenerator, this.passwordHistory, - this.searchVault]; + this.searchVault, this.copyUsername, this.copyPassword]; this.updateApplicationMenuState(false, true); } @@ -355,6 +359,19 @@ export class MenuMain extends BaseMenu { click: () => this.main.messagingService.send('openPasswordHistory'), }, { type: 'separator' }, + { + label: this.main.i18nService.t('copyUsername'), + id: 'copyUsername', + click: () => this.main.messagingService.send('copyUsername'), + accelerator: 'CmdOrCtrl+U', + }, + { + label: this.main.i18nService.t('copyPassword'), + id: 'copyPassword', + click: () => this.main.messagingService.send('copyPassword'), + accelerator: 'CmdOrCtrl+P', + }, + { type: 'separator' }, ] as MenuItemConstructorOptions[]).concat(this.viewSubMenuItemOptions), }, {