1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-22 11:13:46 +00:00

[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
This commit is contained in:
cd-bitwarden
2025-07-11 11:25:49 -04:00
committed by GitHub
parent a61d7fd4da
commit 659427ca3a

View File

@@ -1,10 +1,13 @@
// FIXME: Update this file to be type safe and remove this and next line // FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore // @ts-strict-ignore
import { Component, OnDestroy, OnInit } from "@angular/core"; import { Component, OnDestroy, OnInit } from "@angular/core";
import { ActivatedRoute, Params } from "@angular/router"; import { ActivatedRoute } from "@angular/router";
import { Subject, concatMap, takeUntil } from "rxjs"; 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 { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { ToastService } from "@bitwarden/components"; import { ToastService } from "@bitwarden/components";
@@ -48,11 +51,11 @@ export class ServiceAccountConfigComponent implements OnInit, OnDestroy {
) {} ) {}
async ngOnInit() { async ngOnInit() {
this.route.params combineLatest([this.route.params, this.environmentService.environment$])
.pipe( .pipe(
concatMap(async (params: Params) => { switchMap(([params, env]) =>
return await this.load(params.organizationId, params.serviceAccountId); from(this.load(env, params.organizationId, params.serviceAccountId)),
}), ),
takeUntil(this.destroy$), takeUntil(this.destroy$),
) )
.subscribe((smConfig) => { .subscribe((smConfig) => {
@@ -67,9 +70,11 @@ export class ServiceAccountConfigComponent implements OnInit, OnDestroy {
}); });
} }
async load(organizationId: string, serviceAccountId: string): Promise<ServiceAccountConfig> { private async load(
const environment = await this.environmentService.getEnvironment(); environment: Environment,
organizationId: string,
serviceAccountId: string,
): Promise<ServiceAccountConfig> {
const allProjects = await this.projectService.getProjects(organizationId); const allProjects = await this.projectService.getProjects(organizationId);
const policies = await this.accessPolicyService.getServiceAccountGrantedPolicies( const policies = await this.accessPolicyService.getServiceAccountGrantedPolicies(
organizationId, organizationId,
@@ -88,11 +93,11 @@ export class ServiceAccountConfigComponent implements OnInit, OnDestroy {
}); });
return { return {
organizationId: organizationId, organizationId,
serviceAccountId: serviceAccountId, serviceAccountId,
identityUrl: environment.getIdentityUrl(), identityUrl: environment.getIdentityUrl(),
apiUrl: environment.getApiUrl(), apiUrl: environment.getApiUrl(),
projects: projects, projects,
} as ServiceAccountConfig; } as ServiceAccountConfig;
} }