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
// @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<ServiceAccountConfig> {
const environment = await this.environmentService.getEnvironment();
private async load(
environment: Environment,
organizationId: string,
serviceAccountId: string,
): Promise<ServiceAccountConfig> {
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;
}