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:
@@ -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 () => {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user