1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-15 15:53:27 +00:00

[PM-19579] - add sshKey option to desktop (#14402)

* add sshKey option to desktop

* fix add new sshKey

* revert removal of catch

* revert removal of catch
This commit is contained in:
Jordan Aasen
2025-05-01 13:03:11 -07:00
committed by GitHub
parent 4292744ca8
commit 23e7f120fd
5 changed files with 31 additions and 22 deletions

View File

@@ -103,6 +103,12 @@ export class FileMenu extends FirstMenu implements IMenubarMenu {
click: () => this.sendMessage("newSecureNote"), click: () => this.sendMessage("newSecureNote"),
accelerator: "CmdOrCtrl+Shift+S", accelerator: "CmdOrCtrl+Shift+S",
}, },
{
id: "typeSshKey",
label: this.localize("typeSshKey"),
click: () => this.sendMessage("newSshKey"),
accelerator: "CmdOrCtrl+Shift+K",
},
]; ];
} }

View File

@@ -88,5 +88,9 @@
<i class="bwi bwi-sticky-note tw-mr-1" aria-hidden="true"></i> <i class="bwi bwi-sticky-note tw-mr-1" aria-hidden="true"></i>
{{ "typeSecureNote" | i18n }} {{ "typeSecureNote" | i18n }}
</button> </button>
<button type="button" bitMenuItem (click)="addCipher(CipherType.SshKey)">
<i class="bwi bwi-key tw-mr-1" aria-hidden="true"></i>
{{ "typeSshKey" | i18n }}
</button>
</bit-menu> </bit-menu>
</ng-template> </ng-template>

View File

@@ -6,7 +6,6 @@
(onCipherClicked)="viewCipher($event)" (onCipherClicked)="viewCipher($event)"
(onCipherRightClicked)="viewCipherMenu($event)" (onCipherRightClicked)="viewCipherMenu($event)"
(onAddCipher)="addCipher($event)" (onAddCipher)="addCipher($event)"
(onAddCipherOptions)="addCipherOptions()"
> >
</app-vault-items-v2> </app-vault-items-v2>
<div class="details" *ngIf="!!action"> <div class="details" *ngIf="!!action">

View File

@@ -208,6 +208,9 @@ export class VaultV2Component implements OnInit, OnDestroy {
case "newSecureNote": case "newSecureNote":
await this.addCipher(CipherType.SecureNote).catch(() => {}); await this.addCipher(CipherType.SecureNote).catch(() => {});
break; break;
case "newSshKey":
await this.addCipher(CipherType.SshKey).catch(() => {});
break;
case "focusSearch": case "focusSearch":
(document.querySelector("#search") as HTMLInputElement)?.select(); (document.querySelector("#search") as HTMLInputElement)?.select();
detectChanges = false; detectChanges = false;
@@ -531,28 +534,14 @@ export class VaultV2Component implements OnInit, OnDestroy {
this.action = "add"; this.action = "add";
this.prefillCipherFromFilter(); this.prefillCipherFromFilter();
await this.go().catch(() => {}); await this.go().catch(() => {});
}
addCipherOptions() { if (type === CipherType.SshKey) {
const menu: RendererMenuItem[] = [ this.toastService.showToast({
{ variant: "success",
label: this.i18nService.t("typeLogin"), title: "",
click: () => this.addCipherWithChangeDetection(CipherType.Login), message: this.i18nService.t("sshKeyGenerated"),
}, });
{ }
label: this.i18nService.t("typeCard"),
click: () => this.addCipherWithChangeDetection(CipherType.Card),
},
{
label: this.i18nService.t("typeIdentity"),
click: () => this.addCipherWithChangeDetection(CipherType.Identity),
},
{
label: this.i18nService.t("typeSecureNote"),
click: () => this.addCipherWithChangeDetection(CipherType.SecureNote),
},
];
invokeMenu(menu);
} }
async savedCipher(cipher: CipherView) { async savedCipher(cipher: CipherView) {

View File

@@ -151,6 +151,9 @@ export class VaultComponent implements OnInit, OnDestroy {
case "newSecureNote": case "newSecureNote":
await this.addCipher(CipherType.SecureNote); await this.addCipher(CipherType.SecureNote);
break; break;
case "newSshKey":
await this.addCipher(CipherType.SshKey);
break;
case "focusSearch": case "focusSearch":
(document.querySelector("#search") as HTMLInputElement).select(); (document.querySelector("#search") as HTMLInputElement).select();
detectChanges = false; detectChanges = false;
@@ -470,6 +473,14 @@ export class VaultComponent implements OnInit, OnDestroy {
this.cipherId = null; this.cipherId = null;
this.prefillNewCipherFromFilter(); this.prefillNewCipherFromFilter();
this.go(); this.go();
if (type === CipherType.SshKey) {
this.toastService.showToast({
variant: "success",
title: "",
message: this.i18nService.t("sshKeyGenerated"),
});
}
} }
addCipherOptions() { addCipherOptions() {