Add copy username and copy password shortcuts (#379)

This commit is contained in:
Elias Papavasileiou 2020-02-11 05:37:25 +02:00 committed by GitHub
parent d10e562e40
commit f7037dd1f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 1 deletions

View File

@ -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;

View File

@ -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),
},
{