1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 08:13:42 +00:00

[PM-24146] Remove stateProvider.activeUserId from ProviderService (#16258)

* Refactor provider service calls to include userId parameter

- Updated multiple components and services to pass userId when fetching provider data.
- Adjusted the ProviderService interface to require userId for get, get$, and getAll methods.
- Ensured consistent handling of userId across various components, enhancing data retrieval based on active user context.

* Remove deprecated type safety comments and use the getById utility for fetching providers.

* Update ProviderService methods to return undefined for non-existent providers

- Modified the return types of get$ and get methods in ProviderService to allow for undefined values, enhancing type safety.
- Adjusted the providers$ method to return only defined Provider arrays, ensuring consistent handling of provider data.

* Enhance provider permissions guard tests to include userId parameter

- Updated test cases in provider-permissions.guard.spec.ts to pass userId when calling ProviderService methods.
- Mocked AccountService to provide active account details for improved test coverage.
- Ensured consistent handling of userId across all relevant test scenarios.

* remove promise based api's from provider service, continue refactor

* cleanup observable logic

* cleanup

---------

Co-authored-by: Brandon <btreston@bitwarden.com>
This commit is contained in:
Rui Tomé
2025-09-22 16:06:28 +01:00
committed by GitHub
parent dbec02cf8d
commit b455cb5986
24 changed files with 342 additions and 281 deletions

View File

@@ -11,6 +11,8 @@ import { BusinessUnitPortalLogo, Icon, ProviderPortalLogo } from "@bitwarden/ass
import { ProviderService } from "@bitwarden/common/admin-console/abstractions/provider.service";
import { ProviderStatusType, ProviderType } from "@bitwarden/common/admin-console/enums";
import { Provider } from "@bitwarden/common/admin-console/models/domain/provider";
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
import { getUserId } from "@bitwarden/common/auth/services/account.service";
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
import { IconModule } from "@bitwarden/components";
@@ -56,6 +58,7 @@ export class ProvidersLayoutComponent implements OnInit, OnDestroy {
private providerService: ProviderService,
private configService: ConfigService,
private providerWarningsService: ProviderWarningsService,
private accountService: AccountService,
) {}
ngOnInit() {
@@ -65,8 +68,11 @@ export class ProvidersLayoutComponent implements OnInit, OnDestroy {
map((params) => params.providerId),
);
this.provider$ = providerId$.pipe(
switchMap((providerId) => this.providerService.get$(providerId)),
this.provider$ = combineLatest([
providerId$,
this.accountService.activeAccount$.pipe(getUserId),
]).pipe(
switchMap(([providerId, userId]) => this.providerService.get$(providerId, userId)),
takeUntil(this.destroy$),
);