From c947041f74bd8385a3e10482584f4d6f072b45c1 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 9 Sep 2025 17:02:59 -0400 Subject: [PATCH] refactor: report prompt dialog --- .../all-applications.component.ts | 13 +++++++++++-- .../first-report-prompt-dialog.component.ts | 14 ++------------ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/bitwarden_license/bit-web/src/app/dirt/access-intelligence/all-applications.component.ts b/bitwarden_license/bit-web/src/app/dirt/access-intelligence/all-applications.component.ts index b3a20dcdb1b..0a90153fc60 100644 --- a/bitwarden_license/bit-web/src/app/dirt/access-intelligence/all-applications.component.ts +++ b/bitwarden_license/bit-web/src/app/dirt/access-intelligence/all-applications.component.ts @@ -2,7 +2,7 @@ import { Component, DestroyRef, inject, OnInit } from "@angular/core"; import { takeUntilDestroyed } from "@angular/core/rxjs-interop"; import { FormControl } from "@angular/forms"; import { ActivatedRoute } from "@angular/router"; -import { catchError, debounceTime, exhaustMap, finalize, of, tap } from "rxjs"; +import { catchError, debounceTime, exhaustMap, finalize, firstValueFrom, of, tap } from "rxjs"; import { CriticalAppsService, @@ -119,7 +119,16 @@ export class AllApplicationsComponent implements OnInit { this.hasShownFirstReportPrompt = true; // Open the dialog using the dialog service - FirstReportPromptDialogComponent.open(this.dialogService); + const dialogRef = FirstReportPromptDialogComponent.open(this.dialogService); + + const result = await firstValueFrom(dialogRef.closed); + + // Dialog is now closed, check what the user chose + if (result === true) { + // User clicked "Run Report" - trigger the report generation + this.dataService.triggerReport(); + } + // If result is false/undefined, user dismissed dialog without running report } goToCreateNewLoginItem = async () => { diff --git a/bitwarden_license/bit-web/src/app/dirt/access-intelligence/first-report-prompt-dialog.component.ts b/bitwarden_license/bit-web/src/app/dirt/access-intelligence/first-report-prompt-dialog.component.ts index 5790fa03a68..c5ff3651659 100644 --- a/bitwarden_license/bit-web/src/app/dirt/access-intelligence/first-report-prompt-dialog.component.ts +++ b/bitwarden_license/bit-web/src/app/dirt/access-intelligence/first-report-prompt-dialog.component.ts @@ -1,6 +1,5 @@ import { Component, inject } from "@angular/core"; -import { RiskInsightsDataService } from "@bitwarden/bit-common/dirt/reports/risk-insights"; import { ButtonModule, DialogModule, @@ -16,22 +15,13 @@ import { I18nPipe } from "@bitwarden/ui-common"; }) export class FirstReportPromptDialogComponent { private dialogRef = inject(DialogRef); - private dataService = inject(RiskInsightsDataService); static open(dialogService: DialogService) { return dialogService.open(FirstReportPromptDialogComponent); } - async runReport(): Promise { - // Close the dialog first + runReport(): void { + // Simply close the dialog with 'true' to indicate user wants to run report this.dialogRef.close(true); - - // Add a small delay to ensure dialog closes before triggering the report - await new Promise((resolve) => setTimeout(resolve, 100)); - - // Trigger the report generation - if (this.dataService) { - this.dataService.triggerReport(); - } } }