1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-02 17:53:41 +00:00

feat(dirt): implement review workflow for new applications

Handle dialog results and save review status through orchestrator.
Marks ALL new applications as reviewed and selected ones as critical.
UI updates automatically via reactive pipeline.

- Update onReviewNewApplications() to handle dialog results
- Call dataService.saveApplicationReviewStatus() with selections
- Add success/error toast notifications
- Add I18nService and ToastService dependencies
- Business logic properly separated from dialog

Related to PM-27284
This commit is contained in:
Claude
2025-10-28 21:21:52 +00:00
parent 5eab495710
commit de82d28793

View File

@@ -2,6 +2,7 @@ import { Component, DestroyRef, inject, OnInit } from "@angular/core";
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
import { ActivatedRoute } from "@angular/router";
import { firstValueFrom } from "rxjs";
import { finalize } from "rxjs/operators";
import {
AllActivitiesService,
@@ -11,8 +12,9 @@ import { OrganizationService } from "@bitwarden/common/admin-console/abstraction
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
import { getUserId } from "@bitwarden/common/auth/services/account.service";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { getById } from "@bitwarden/common/platform/misc";
import { DialogService } from "@bitwarden/components";
import { DialogService, ToastService } from "@bitwarden/components";
import { SharedModule } from "@bitwarden/web-vault/app/shared";
import { ApplicationsLoadingComponent } from "../shared/risk-insights-loading.component";
@@ -50,7 +52,9 @@ export class AllActivityComponent implements OnInit {
protected allActivitiesService: AllActivitiesService,
protected dataService: RiskInsightsDataService,
private dialogService: DialogService,
private i18nService: I18nService,
protected organizationService: OrganizationService,
private toastService: ToastService,
) {}
async ngOnInit(): Promise<void> {
@@ -84,13 +88,53 @@ export class AllActivityComponent implements OnInit {
/**
* Handles the review new applications button click.
* Opens a dialog showing the list of new applications that can be marked as critical.
* When user clicks Continue, saves review status and critical markings via orchestrator.
*/
onReviewNewApplications = async () => {
const dialogRef = NewApplicationsDialogComponent.open(this.dialogService, {
newApplications: this.newApplications,
});
await firstValueFrom(dialogRef.closed);
const result = await firstValueFrom(dialogRef.closed);
if (result?.saved) {
// User clicked Continue - save review status and critical flags
let isSaving = true;
firstValueFrom(
this.dataService.saveApplicationReviewStatus(result.selectedApplications).pipe(
finalize(() => {
isSaving = false;
}),
),
)
.then(() => {
// Success - data will update automatically through reactive pipeline
if (result.selectedApplications.length > 0) {
this.toastService.showToast({
variant: "success",
title: this.i18nService.t("success"),
message: this.i18nService.t(
"applicationsCriticalMarked",
result.selectedApplications.length.toString(),
),
});
} else {
this.toastService.showToast({
variant: "success",
title: this.i18nService.t("success"),
message: this.i18nService.t("applicationsReviewed"),
});
}
})
.catch((error) => {
this.toastService.showToast({
variant: "error",
title: this.i18nService.t("error"),
message: this.i18nService.t("failedToSaveApplications"),
});
});
}
};
/**