1
0
mirror of https://github.com/bitwarden/desktop.git synced 2024-11-28 12:35:40 +01:00

adjustments to copy username/pass shortcuts

This commit is contained in:
Kyle Spearrin 2020-02-10 23:00:39 -05:00
parent f7037dd1f5
commit c5c7f8a623
3 changed files with 29 additions and 20 deletions

2
jslib

@ -1 +1 @@
Subproject commit bb459ce4b45d0ddcfc2ec0cfe3e925125550d862
Subproject commit fd260dfbae1717cdc019353f091501ac1dabe45f

View File

@ -32,6 +32,7 @@ import { GroupingsComponent } from './groupings.component';
import { PasswordGeneratorComponent } from './password-generator.component';
import { PasswordHistoryComponent } from './password-history.component';
import { ShareComponent } from './share.component';
import { ViewComponent } from './view.component';
import { CipherType } from 'jslib/enums/cipherType';
import { EventType } from 'jslib/enums/eventType';
@ -53,6 +54,7 @@ const BroadcasterSubscriptionId = 'VaultComponent';
templateUrl: 'vault.component.html',
})
export class VaultComponent implements OnInit, OnDestroy {
@ViewChild(ViewComponent) viewComponent: ViewComponent;
@ViewChild(AddEditComponent) addEditComponent: AddEditComponent;
@ViewChild(CiphersComponent) ciphersComponent: CiphersComponent;
@ViewChild(GroupingsComponent) groupingsComponent: GroupingsComponent;
@ -152,15 +154,19 @@ export class VaultComponent implements OnInit, OnDestroy {
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');
const uComponent = this.addEditComponent == null ? this.viewComponent : this.addEditComponent;
const uCipher = uComponent != null ? uComponent.cipher : null;
if (this.cipherId != null && uCipher != null && uCipher.id === this.cipherId &&
uCipher.login != null && uCipher.login.username != null) {
this.copyValue(uCipher.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');
const pComponent = this.addEditComponent == null ? this.viewComponent : this.addEditComponent;
const pCipher = pComponent != null ? pComponent.cipher : null;
if (this.cipherId != null && pCipher != null && pCipher.id === this.cipherId &&
pCipher.login != null && pCipher.login.password != null) {
this.copyValue(pCipher.login.password, 'password');
}
break;
default:

View File

@ -152,6 +152,22 @@ export class MenuMain extends BaseMenu {
},
];
this.editMenuItemOptions.submenu = (this.editMenuItemOptions.submenu as MenuItemConstructorOptions[]).concat([
{ 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',
},
]);
if (!isWindowsStore()) {
accountSubmenu.unshift({
label: this.main.i18nService.t('premiumMembership'),
@ -359,19 +375,6 @@ 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),
},
{