From d4cf7217e353361ade58885cb23f77b4b5cf4733 Mon Sep 17 00:00:00 2001 From: Tom <144813356+ttalty@users.noreply.github.com> Date: Thu, 18 Sep 2025 16:18:41 -0400 Subject: [PATCH] [PM-25838] Adding new properties to the summary and renaming the type (#16477) * Adding new properties to the summary and renaming the type * properties were missing from not saving * fixing type issues and missed renaming --- .../risk-insights/models/report-models.ts | 11 ++++++--- .../services/risk-insights-report.service.ts | 24 +++++++++++++++---- .../all-applications.component.ts | 9 +++++-- .../critical-applications.component.ts | 4 ++-- 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/bitwarden_license/bit-common/src/dirt/reports/risk-insights/models/report-models.ts b/bitwarden_license/bit-common/src/dirt/reports/risk-insights/models/report-models.ts index 631170be4f9..5d0a14ca016 100644 --- a/bitwarden_license/bit-common/src/dirt/reports/risk-insights/models/report-models.ts +++ b/bitwarden_license/bit-common/src/dirt/reports/risk-insights/models/report-models.ts @@ -90,11 +90,16 @@ export type CipherApplicationView = { * total at risk members, application, and at risk application * counts. Aggregated from all calculated applications */ -export type ApplicationHealthReportSummary = { +export type OrganizationReportSummary = { totalMemberCount: number; + totalCriticalMemberCount: number; totalAtRiskMemberCount: number; + totalCriticalAtRiskMemberCount: number; totalApplicationCount: number; + totalCriticalApplicationCount: number; totalAtRiskApplicationCount: number; + totalCriticalAtRiskApplicationCount: number; + newApplications: string[]; }; export type CriticalSummaryDetails = { @@ -138,7 +143,7 @@ export type PasswordHealthReportApplicationId = Opaque([]); riskInsightsReport$ = this.riskInsightsReportSubject.asObservable(); - private riskInsightsSummarySubject = new BehaviorSubject({ + private riskInsightsSummarySubject = new BehaviorSubject({ totalMemberCount: 0, totalAtRiskMemberCount: 0, totalApplicationCount: 0, totalAtRiskApplicationCount: 0, + totalCriticalMemberCount: 0, + totalCriticalAtRiskMemberCount: 0, + totalCriticalApplicationCount: 0, + totalCriticalAtRiskApplicationCount: 0, + newApplications: [], }); riskInsightsSummary$ = this.riskInsightsSummarySubject.asObservable(); @@ -190,20 +195,24 @@ export class RiskInsightsReportService { * @param reports The previously calculated application health report data * @returns A summary object containing report totals */ - generateApplicationsSummary( - reports: ApplicationHealthReportDetail[], - ): ApplicationHealthReportSummary { + generateApplicationsSummary(reports: ApplicationHealthReportDetail[]): OrganizationReportSummary { const totalMembers = reports.flatMap((x) => x.memberDetails); const uniqueMembers = getUniqueMembers(totalMembers); const atRiskMembers = reports.flatMap((x) => x.atRiskMemberDetails); const uniqueAtRiskMembers = getUniqueMembers(atRiskMembers); + // TODO: totalCriticalMemberCount, totalCriticalAtRiskMemberCount, totalCriticalApplicationCount, totalCriticalAtRiskApplicationCount, and newApplications will be handled with future logic implementation return { totalMemberCount: uniqueMembers.length, + totalCriticalMemberCount: 0, totalAtRiskMemberCount: uniqueAtRiskMembers.length, + totalCriticalAtRiskMemberCount: 0, totalApplicationCount: reports.length, + totalCriticalApplicationCount: 0, totalAtRiskApplicationCount: reports.filter((app) => app.atRiskPasswordCount > 0).length, + totalCriticalAtRiskApplicationCount: 0, + newApplications: [], }; } @@ -237,6 +246,11 @@ export class RiskInsightsReportService { totalAtRiskMemberCount: 0, totalApplicationCount: 0, totalAtRiskApplicationCount: 0, + totalCriticalMemberCount: 0, + totalCriticalAtRiskMemberCount: 0, + totalCriticalApplicationCount: 0, + totalCriticalAtRiskApplicationCount: 0, + newApplications: [], }, }); } 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 50f2d6de687..239236ee065 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 @@ -16,7 +16,7 @@ import { } from "@bitwarden/bit-common/dirt/reports/risk-insights/models/password-health"; import { ApplicationHealthReportDetail, - ApplicationHealthReportSummary, + OrganizationReportSummary, } from "@bitwarden/bit-common/dirt/reports/risk-insights/models/report-models"; import { RiskInsightsEncryptionService } from "@bitwarden/bit-common/dirt/reports/risk-insights/services/risk-insights-encryption.service"; import { @@ -69,11 +69,16 @@ export class AllApplicationsComponent implements OnInit { protected organization = new Organization(); noItemsIcon = Security; protected markingAsCritical = false; - protected applicationSummary: ApplicationHealthReportSummary = { + protected applicationSummary: OrganizationReportSummary = { totalMemberCount: 0, totalAtRiskMemberCount: 0, totalApplicationCount: 0, totalAtRiskApplicationCount: 0, + totalCriticalMemberCount: 0, + totalCriticalAtRiskMemberCount: 0, + totalCriticalApplicationCount: 0, + totalCriticalAtRiskApplicationCount: 0, + newApplications: [], }; destroyRef = inject(DestroyRef); diff --git a/bitwarden_license/bit-web/src/app/dirt/access-intelligence/critical-applications.component.ts b/bitwarden_license/bit-web/src/app/dirt/access-intelligence/critical-applications.component.ts index eb5d9bd4499..c8bc3e81680 100644 --- a/bitwarden_license/bit-web/src/app/dirt/access-intelligence/critical-applications.component.ts +++ b/bitwarden_license/bit-web/src/app/dirt/access-intelligence/critical-applications.component.ts @@ -16,7 +16,7 @@ import { LEGACY_ApplicationHealthReportDetailWithCriticalFlag, LEGACY_ApplicationHealthReportDetailWithCriticalFlagAndCipher, } from "@bitwarden/bit-common/dirt/reports/risk-insights/models/password-health"; -import { ApplicationHealthReportSummary } from "@bitwarden/bit-common/dirt/reports/risk-insights/models/report-models"; +import { OrganizationReportSummary } from "@bitwarden/bit-common/dirt/reports/risk-insights/models/report-models"; import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { getUserId } from "@bitwarden/common/auth/services/account.service"; import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; @@ -57,7 +57,7 @@ export class CriticalApplicationsComponent implements OnInit { private destroyRef = inject(DestroyRef); protected loading = false; protected organizationId: OrganizationId; - protected applicationSummary = {} as ApplicationHealthReportSummary; + protected applicationSummary = {} as OrganizationReportSummary; noItemsIcon = Security; enableRequestPasswordChange = false;