1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-10 05:30:01 +00:00

refactor: report prompt dialog

This commit is contained in:
Alex
2025-09-09 17:02:59 -04:00
parent 55f5dbd911
commit c947041f74
2 changed files with 13 additions and 14 deletions

View File

@@ -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 () => {

View File

@@ -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<boolean>(FirstReportPromptDialogComponent);
}
async runReport(): Promise<void> {
// 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();
}
}
}