From 659427ca3a2fe64543417d63d5d19ae1c2925021 Mon Sep 17 00:00:00 2001 From: cd-bitwarden <106776772+cd-bitwarden@users.noreply.github.com> Date: Fri, 11 Jul 2025 11:25:49 -0400 Subject: [PATCH] [SM-1476] config tab (#15133) * Updating config component to use the new environmentService.environment$ * Updating config.component.ts to use the environment$ observable * changes to improve the environment logic update --- .../config/config.component.ts | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts b/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts index e796c4758ea..f85cde90306 100644 --- a/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts +++ b/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts @@ -1,10 +1,13 @@ // FIXME: Update this file to be type safe and remove this and next line // @ts-strict-ignore import { Component, OnDestroy, OnInit } from "@angular/core"; -import { ActivatedRoute, Params } from "@angular/router"; -import { Subject, concatMap, takeUntil } from "rxjs"; +import { ActivatedRoute } from "@angular/router"; +import { Subject, combineLatest, from, switchMap, takeUntil } from "rxjs"; -import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service"; +import { + Environment, + EnvironmentService, +} from "@bitwarden/common/platform/abstractions/environment.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { ToastService } from "@bitwarden/components"; @@ -48,11 +51,11 @@ export class ServiceAccountConfigComponent implements OnInit, OnDestroy { ) {} async ngOnInit() { - this.route.params + combineLatest([this.route.params, this.environmentService.environment$]) .pipe( - concatMap(async (params: Params) => { - return await this.load(params.organizationId, params.serviceAccountId); - }), + switchMap(([params, env]) => + from(this.load(env, params.organizationId, params.serviceAccountId)), + ), takeUntil(this.destroy$), ) .subscribe((smConfig) => { @@ -67,9 +70,11 @@ export class ServiceAccountConfigComponent implements OnInit, OnDestroy { }); } - async load(organizationId: string, serviceAccountId: string): Promise { - const environment = await this.environmentService.getEnvironment(); - + private async load( + environment: Environment, + organizationId: string, + serviceAccountId: string, + ): Promise { const allProjects = await this.projectService.getProjects(organizationId); const policies = await this.accessPolicyService.getServiceAccountGrantedPolicies( organizationId, @@ -88,11 +93,11 @@ export class ServiceAccountConfigComponent implements OnInit, OnDestroy { }); return { - organizationId: organizationId, - serviceAccountId: serviceAccountId, + organizationId, + serviceAccountId, identityUrl: environment.getIdentityUrl(), apiUrl: environment.getApiUrl(), - projects: projects, + projects, } as ServiceAccountConfig; }