From db4f9a89620157476f398e973085ed20a17ccf4f Mon Sep 17 00:00:00 2001 From: jaasen-livefront Date: Thu, 12 Dec 2024 16:50:03 -0800 Subject: [PATCH] fix types --- .../all-applications.component.ts | 14 ++++----- .../risk-insights.component.ts | 29 ++++++++++--------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/bitwarden_license/bit-web/src/app/tools/access-intelligence/all-applications.component.ts b/bitwarden_license/bit-web/src/app/tools/access-intelligence/all-applications.component.ts index 435c17a1b07..119b2073061 100644 --- a/bitwarden_license/bit-web/src/app/tools/access-intelligence/all-applications.component.ts +++ b/bitwarden_license/bit-web/src/app/tools/access-intelligence/all-applications.component.ts @@ -2,7 +2,7 @@ import { Component, DestroyRef, OnDestroy, OnInit, inject } from "@angular/core" import { takeUntilDestroyed } from "@angular/core/rxjs-interop"; import { FormControl } from "@angular/forms"; import { ActivatedRoute } from "@angular/router"; -import { debounceTime, map, Observable, Subscription } from "rxjs"; +import { debounceTime, map, Observable, of, Subscription } from "rxjs"; import { RiskInsightsDataService, @@ -52,14 +52,14 @@ export class AllApplicationsComponent implements OnInit, OnDestroy { protected selectedIds: Set = new Set(); protected searchControl = new FormControl("", { nonNullable: true }); protected loading = true; - protected organization: Organization; + protected organization = {} as Organization; noItemsIcon = Icons.Security; protected markingAsCritical = false; - protected applicationSummary: ApplicationHealthReportSummary; - private subscription: Subscription; + protected applicationSummary = {} as ApplicationHealthReportSummary; + private subscription = new Subscription(); destroyRef = inject(DestroyRef); - isLoading$: Observable; + isLoading$: Observable = of(false); isCriticalAppsFeatureEnabled = false; async ngOnInit() { @@ -110,7 +110,7 @@ export class AllApplicationsComponent implements OnInit, OnDestroy { // TODO: implement this.toastService.showToast({ variant: "warning", - title: null, + title: "", message: "Not yet implemented", }); }; @@ -123,7 +123,7 @@ export class AllApplicationsComponent implements OnInit, OnDestroy { this.selectedIds.clear(); this.toastService.showToast({ variant: "success", - title: null, + title: "", message: this.i18nService.t("appsMarkedAsCritical"), }); resolve(true); diff --git a/bitwarden_license/bit-web/src/app/tools/access-intelligence/risk-insights.component.ts b/bitwarden_license/bit-web/src/app/tools/access-intelligence/risk-insights.component.ts index eb24fc9902b..f0c1fcbccb1 100644 --- a/bitwarden_license/bit-web/src/app/tools/access-intelligence/risk-insights.component.ts +++ b/bitwarden_license/bit-web/src/app/tools/access-intelligence/risk-insights.component.ts @@ -2,7 +2,7 @@ import { CommonModule } from "@angular/common"; import { Component, DestroyRef, OnInit, inject } from "@angular/core"; import { takeUntilDestroyed } from "@angular/core/rxjs-interop"; import { ActivatedRoute, Router } from "@angular/router"; -import { Observable } from "rxjs"; +import { Observable, EMPTY } from "rxjs"; import { map, switchMap } from "rxjs/operators"; import { JslibModule } from "@bitwarden/angular/jslib.module"; @@ -47,25 +47,25 @@ export enum RiskInsightsTabType { NotifiedMembersTableComponent, TabsModule, ], - providers: [RiskInsightsReportService, RiskInsightsDataService, MemberCipherDetailsApiService], + providers: [RiskInsightsReportService, MemberCipherDetailsApiService], }) export class RiskInsightsComponent implements OnInit { tabIndex: RiskInsightsTabType = RiskInsightsTabType.AllApps; - dataLastUpdated = new Date(); + dataLastUpdated: Date = new Date(); - isCriticalAppsFeatureEnabled = false; + isCriticalAppsFeatureEnabled: boolean = false; - appsCount = 0; - criticalAppsCount = 0; - notifiedMembersCount = 0; + appsCount: number = 0; + criticalAppsCount: number = 0; + notifiedMembersCount: number = 0; - private organizationId: string; + private organizationId: string | null = null; private destroyRef = inject(DestroyRef); - isLoading$: Observable; - isRefreshing$: Observable; - dataLastUpdated$: Observable; - refetching = false; + isLoading$: Observable = new Observable(); + isRefreshing$: Observable = new Observable(); + dataLastUpdated$: Observable = new Observable(); + refetching: boolean = false; constructor( private route: ActivatedRoute, @@ -87,7 +87,7 @@ export class RiskInsightsComponent implements OnInit { .pipe( takeUntilDestroyed(this.destroyRef), map((params) => params.get("organizationId")), - switchMap((orgId) => { + switchMap((orgId: string | null) => { if (orgId) { this.organizationId = orgId; this.dataService.fetchApplicationsReport(orgId); @@ -95,6 +95,8 @@ export class RiskInsightsComponent implements OnInit { this.isRefreshing$ = this.dataService.isRefreshing$; this.dataLastUpdated$ = this.dataService.dataLastUpdated$; return this.dataService.applications$; + } else { + return EMPTY; // Ensures switchMap always returns an Observable } }), ) @@ -102,6 +104,7 @@ export class RiskInsightsComponent implements OnInit { next: (applications: ApplicationHealthReportDetail[] | null) => { if (applications) { this.appsCount = applications.length; + // Optionally, you can calculate other counts here or in child components } }, });