From cf15d257837035f1622b59487155b72b809a454a Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 29 Oct 2025 15:54:05 -0400 Subject: [PATCH] fix(dirt): improve dialog type safety and error logging Addresses critical PR review issues in NewApplicationsDialogComponent: **Type Safety:** - Replace unsafe type casting `(this as any).dialogRef` with proper DialogRef injection - Inject DialogRef using Angular's inject() function - Ensures type safety and prevents runtime errors from missing dialogRef **Error Handling:** - Add LogService to dialog component - Log errors with "[NewApplicationsDialog]" for debugging - Maintain user-facing error toast while adding server-side logging **Impact:** - Eliminates TypeScript safety bypasses - Improves production debugging capabilities - Follows Angular dependency injection best practices --- .../activity/new-applications-dialog.component.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bitwarden_license/bit-web/src/app/dirt/access-intelligence/activity/new-applications-dialog.component.ts b/bitwarden_license/bit-web/src/app/dirt/access-intelligence/activity/new-applications-dialog.component.ts index 0553d2558a3..c9df3283fae 100644 --- a/bitwarden_license/bit-web/src/app/dirt/access-intelligence/activity/new-applications-dialog.component.ts +++ b/bitwarden_license/bit-web/src/app/dirt/access-intelligence/activity/new-applications-dialog.component.ts @@ -4,9 +4,11 @@ import { firstValueFrom } from "rxjs"; import { RiskInsightsDataService } from "@bitwarden/bit-common/dirt/reports/risk-insights"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; +import { LogService } from "@bitwarden/common/platform/abstractions/log.service"; import { ButtonModule, DialogModule, + DialogRef, DialogService, ToastService, TypographyModule, @@ -27,9 +29,11 @@ export class NewApplicationsDialogComponent { protected newApplications: string[] = []; protected selectedApplications: Set = new Set(); + private dialogRef = inject(DialogRef); private dataService = inject(RiskInsightsDataService); private toastService = inject(ToastService); private i18nService = inject(I18nService); + private logService = inject(LogService); /** * Opens the new applications dialog @@ -96,8 +100,9 @@ export class NewApplicationsDialogComponent { }); // Close dialog with success indicator - (this as any).dialogRef?.close(true); + this.dialogRef.close(true); } catch { + this.logService.error("[NewApplicationsDialog] Failed to save review status"); this.toastService.showToast({ variant: "error", title: this.i18nService.t("errorSavingReviewStatus"),