1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-04 10:43:47 +00:00

refactor(dirt): remove newApplications from OrganizationReportSummary

Removes redundant newApplications field from summary type and uses
derived newApplications$ observable from orchestrator instead.

**Changes:**
- Remove newApplications from OrganizationReportSummary type definition
- Remove dummy data array from RiskInsightsReportService.getApplicationsSummary()
- Remove newApplications subscription from AllActivitiesService
- Update AllActivityComponent to subscribe directly to dataService.newApplications$

**Why:**
- Eliminates data redundancy (stored vs derived)
- newApplications$ already computes from applicationData.reviewedDate === null
- Single source of truth: applicationData is the source
- Simplifies encrypted payload (less data in summary)
- Better separation: stored data (counts) vs computed data (lists)

**Impact:**
- No functional changes - UI continues to display new applications correctly
- Cleaner architecture with computed observable pattern
This commit is contained in:
Alex
2025-10-29 13:18:43 -04:00
parent b1da2cb3d2
commit 907a784c13
4 changed files with 7 additions and 39 deletions

View File

@@ -55,7 +55,6 @@ export type OrganizationReportSummary = {
totalCriticalMemberCount: number;
totalCriticalAtRiskMemberCount: number;
totalCriticalAtRiskApplicationCount: number;
newApplications: string[];
};
/**

View File

@@ -56,23 +56,6 @@ export class RiskInsightsReportService {
const atRiskMembers = reports.flatMap((x) => x.atRiskMemberDetails);
const uniqueAtRiskMembers = getUniqueMembers(atRiskMembers);
// TODO: Replace with actual new applications detection logic (PM-26185)
const dummyNewApplications = [
"github.com",
"google.com",
"stackoverflow.com",
"gitlab.com",
"bitbucket.org",
"npmjs.com",
"docker.com",
"aws.amazon.com",
"azure.microsoft.com",
"jenkins.io",
"terraform.io",
"kubernetes.io",
"atlassian.net",
];
return {
totalMemberCount: uniqueMembers.length,
totalAtRiskMemberCount: uniqueAtRiskMembers.length,
@@ -82,7 +65,6 @@ export class RiskInsightsReportService {
totalCriticalAtRiskMemberCount: 0,
totalCriticalApplicationCount: 0,
totalCriticalAtRiskApplicationCount: 0,
newApplications: dummyNewApplications,
};
}

View File

@@ -21,7 +21,6 @@ export class AllActivitiesService {
totalCriticalApplicationCount: 0,
totalAtRiskApplicationCount: 0,
totalCriticalAtRiskApplicationCount: 0,
newApplications: [],
});
reportSummary$ = this.reportSummarySubject$.asObservable();
@@ -54,11 +53,6 @@ export class AllActivitiesService {
this.setCriticalAppsReportSummary(report.summaryData);
}
});
// New applications changes (from orchestrator's reactive pipeline)
this.dataService.newApplications$.pipe(takeUntilDestroyed()).subscribe((newApps) => {
this.setNewApplications(newApps);
});
}
setCriticalAppsReportSummary(summary: OrganizationReportSummary) {
@@ -78,7 +72,6 @@ export class AllActivitiesService {
totalAtRiskMemberCount: summary.totalAtRiskMemberCount,
totalApplicationCount: summary.totalApplicationCount,
totalAtRiskApplicationCount: summary.totalAtRiskApplicationCount,
// Note: newApplications now set separately via newApplications$ subscription
});
}
@@ -98,15 +91,4 @@ export class AllActivitiesService {
setTaskCreatedCount(count: number) {
this.taskCreatedCountSubject$.next(count);
}
/**
* Updates the newApplications list in the report summary.
* Called when the orchestrator's newApplications$ observable emits.
*/
private setNewApplications(newApps: string[]) {
this.reportSummarySubject$.next({
...this.reportSummarySubject$.getValue(),
newApplications: newApps,
});
}
}

View File

@@ -69,8 +69,13 @@ export class AllActivityComponent implements OnInit {
this.totalCriticalAppsAtRiskMemberCount = summary.totalCriticalAtRiskMemberCount;
this.totalCriticalAppsCount = summary.totalCriticalApplicationCount;
this.totalCriticalAppsAtRiskCount = summary.totalCriticalAtRiskApplicationCount;
this.newApplications = summary.newApplications;
this.newApplicationsCount = summary.newApplications.length;
});
this.dataService.newApplications$
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((newApps) => {
this.newApplications = newApps;
this.newApplicationsCount = newApps.length;
});
this.allActivitiesService.passwordChangeProgressMetricHasProgressBar$