From 34cdcf231b684cd64c4332e7f6f698b2d44efdcb Mon Sep 17 00:00:00 2001 From: Jeffrey Holland <124393578+jholland-livefront@users.noreply.github.com> Date: Wed, 30 Jul 2025 18:05:08 +0200 Subject: [PATCH] Fix action text and close vault modal (#15634) * Fix action text and close vault modal * Fix broken tests --- .../fido2-create.component.spec.ts | 6 +- .../credentials/fido2-create.component.ts | 58 ++++++++++--------- .../credentials/fido2-vault.component.ts | 2 +- apps/desktop/src/locales/en/messages.json | 6 +- 4 files changed, 39 insertions(+), 33 deletions(-) diff --git a/apps/desktop/src/autofill/modal/credentials/fido2-create.component.spec.ts b/apps/desktop/src/autofill/modal/credentials/fido2-create.component.spec.ts index 54a637ec974..778215895ee 100644 --- a/apps/desktop/src/autofill/modal/credentials/fido2-create.component.spec.ts +++ b/apps/desktop/src/autofill/modal/credentials/fido2-create.component.spec.ts @@ -137,7 +137,8 @@ describe("Fido2CreateComponent", () => { title: { key: "unableToSavePasskey" }, content: { key: "closeThisBitwardenWindow" }, type: "danger", - acceptButtonText: { key: "closeBitwarden" }, + acceptButtonText: { key: "closeThisWindow" }, + acceptAction: expect.any(Function), cancelButtonText: null, }); }); @@ -217,7 +218,8 @@ describe("Fido2CreateComponent", () => { title: { key: "unableToSavePasskey" }, content: { key: "closeThisBitwardenWindow" }, type: "danger", - acceptButtonText: { key: "closeBitwarden" }, + acceptButtonText: { key: "closeThisWindow" }, + acceptAction: expect.any(Function), cancelButtonText: null, }); }); diff --git a/apps/desktop/src/autofill/modal/credentials/fido2-create.component.ts b/apps/desktop/src/autofill/modal/credentials/fido2-create.component.ts index d85a90e20ea..f3342d6bc24 100644 --- a/apps/desktop/src/autofill/modal/credentials/fido2-create.component.ts +++ b/apps/desktop/src/autofill/modal/credentials/fido2-create.component.ts @@ -35,28 +35,6 @@ import { import { BitwardenShield } from "./bitwarden-shield.icon"; import { Fido2PasskeyExistsIcon } from "./fido2-passkey-exists-icon"; -const DIALOG_MESSAGES = { - unexpectedErrorShort: { - title: { key: "unexpectedErrorShort" }, - content: { key: "closeThisBitwardenWindow" }, - type: "danger", - acceptButtonText: { key: "closeBitwarden" }, - cancelButtonText: null as null, - }, - unableToSavePasskey: { - title: { key: "unableToSavePasskey" }, - content: { key: "closeThisBitwardenWindow" }, - type: "danger", - acceptButtonText: { key: "closeBitwarden" }, - cancelButtonText: null as null, - }, - overwritePasskey: { - title: { key: "overwritePasskey" }, - content: { key: "alreadyContainsPasskey" }, - type: "warning", - }, -} as const satisfies Record; - @Component({ standalone: true, imports: [ @@ -81,6 +59,32 @@ export class Fido2CreateComponent implements OnInit, OnDestroy { readonly Icons = { BitwardenShield }; protected fido2PasskeyExistsIcon = Fido2PasskeyExistsIcon; + private get DIALOG_MESSAGES() { + return { + unexpectedErrorShort: { + title: { key: "unexpectedErrorShort" }, + content: { key: "closeThisBitwardenWindow" }, + type: "danger", + acceptButtonText: { key: "closeThisWindow" }, + cancelButtonText: null as null, + acceptAction: async () => this.dialogService.closeAll(), + }, + unableToSavePasskey: { + title: { key: "unableToSavePasskey" }, + content: { key: "closeThisBitwardenWindow" }, + type: "danger", + acceptButtonText: { key: "closeThisWindow" }, + cancelButtonText: null as null, + acceptAction: async () => this.dialogService.closeAll(), + }, + overwritePasskey: { + title: { key: "overwritePasskey" }, + content: { key: "alreadyContainsPasskey" }, + type: "warning", + }, + } as const satisfies Record; + } + constructor( private readonly desktopSettingsService: DesktopSettingsService, private readonly fido2UserInterfaceService: DesktopFido2UserInterfaceService, @@ -98,7 +102,7 @@ export class Fido2CreateComponent implements OnInit, OnDestroy { const rpid = await this.session?.getRpId(); if (!this.session) { - await this.showErrorDialog(DIALOG_MESSAGES.unableToSavePasskey); + await this.showErrorDialog(this.DIALOG_MESSAGES.unableToSavePasskey); return; } @@ -119,7 +123,7 @@ export class Fido2CreateComponent implements OnInit, OnDestroy { this.session.notifyConfirmCreateCredential(isConfirmed, cipher); } catch { - await this.showErrorDialog(DIALOG_MESSAGES.unableToSavePasskey); + await this.showErrorDialog(this.DIALOG_MESSAGES.unableToSavePasskey); return; } @@ -134,7 +138,7 @@ export class Fido2CreateComponent implements OnInit, OnDestroy { this.session.notifyConfirmCreateCredential(true); } catch { - await this.showErrorDialog(DIALOG_MESSAGES.unableToSavePasskey); + await this.showErrorDialog(this.DIALOG_MESSAGES.unableToSavePasskey); } await this.closeModal(); @@ -179,7 +183,7 @@ export class Fido2CreateComponent implements OnInit, OnDestroy { !cipher.deletedDate, ); } catch { - await this.showErrorDialog(DIALOG_MESSAGES.unexpectedErrorShort); + await this.showErrorDialog(this.DIALOG_MESSAGES.unexpectedErrorShort); return []; } }), @@ -189,7 +193,7 @@ export class Fido2CreateComponent implements OnInit, OnDestroy { private async validateCipherAccess(cipher: CipherView): Promise { if (cipher.login.hasFido2Credentials) { const overwriteConfirmed = await this.dialogService.openSimpleDialog( - DIALOG_MESSAGES.overwritePasskey, + this.DIALOG_MESSAGES.overwritePasskey, ); if (!overwriteConfirmed) { diff --git a/apps/desktop/src/autofill/modal/credentials/fido2-vault.component.ts b/apps/desktop/src/autofill/modal/credentials/fido2-vault.component.ts index e3062b0c7d9..a91ee15b021 100644 --- a/apps/desktop/src/autofill/modal/credentials/fido2-vault.component.ts +++ b/apps/desktop/src/autofill/modal/credentials/fido2-vault.component.ts @@ -85,7 +85,7 @@ export class Fido2VaultComponent implements OnInit, OnDestroy { title: { key: "unexpectedErrorShort" }, content: { key: "closeThisBitwardenWindow" }, type: "danger", - acceptButtonText: { key: "closeBitwarden" }, + acceptButtonText: { key: "closeThisWindow" }, cancelButtonText: null, }); await this.closeModal(); diff --git a/apps/desktop/src/locales/en/messages.json b/apps/desktop/src/locales/en/messages.json index 7a92fc61dcc..1dc559b88ad 100644 --- a/apps/desktop/src/locales/en/messages.json +++ b/apps/desktop/src/locales/en/messages.json @@ -3211,7 +3211,7 @@ "orgTrustWarning1": { "message": "This organization has an Enterprise policy that will enroll you in account recovery. Enrollment will allow organization administrators to change your password. Only proceed if you recognize this organization and the fingerprint phrase displayed below matches the organization's fingerprint." }, - "trustUser":{ + "trustUser": { "message": "Trust user" }, "inputRequired": { @@ -3781,8 +3781,8 @@ "applicationDoesNotSupportDuplicates": { "message": "This application does not support duplicates." }, - "closeBitwarden": { - "message": "Close Bitwarden" + "closeThisWindow": { + "message": "Close this window" }, "allowScreenshots": { "message": "Allow screen capture"