mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 01:33:33 +00:00
Adding personal item cloning capability (#371)
This commit is contained in:
@@ -189,7 +189,9 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||
if (params.cipherId) {
|
||||
const cipherView = new CipherView();
|
||||
cipherView.id = params.cipherId;
|
||||
if (params.action === 'edit') {
|
||||
if (params.action === 'clone') {
|
||||
await this.cloneCipher(cipherView);
|
||||
} else if (params.action === 'edit') {
|
||||
await this.editCipher(cipherView);
|
||||
} else {
|
||||
await this.viewCipher(cipherView);
|
||||
@@ -249,6 +251,12 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||
this.editCipher(cipher);
|
||||
}),
|
||||
}));
|
||||
menu.append(new remote.MenuItem({
|
||||
label: this.i18nService.t('clone'),
|
||||
click: () => this.functionWithChangeDetection(() => {
|
||||
this.cloneCipher(cipher);
|
||||
}),
|
||||
}));
|
||||
|
||||
switch (cipher.type) {
|
||||
case CipherType.Login:
|
||||
@@ -315,6 +323,18 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||
this.go();
|
||||
}
|
||||
|
||||
async cloneCipher(cipher: CipherView) {
|
||||
if (this.action === 'clone' && this.cipherId === cipher.id) {
|
||||
return;
|
||||
} else if (this.dirtyInput() && await this.wantsToSaveChanges()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.cipherId = cipher.id;
|
||||
this.action = 'clone';
|
||||
this.go();
|
||||
}
|
||||
|
||||
async addCipher(type: CipherType = null) {
|
||||
if (this.action === 'add') {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user