diff --git a/apps/web/src/app/admin-console/organizations/settings/account.component.html b/apps/web/src/app/admin-console/organizations/settings/account.component.html index e34972d36e..f453546fca 100644 --- a/apps/web/src/app/admin-console/organizations/settings/account.component.html +++ b/apps/web/src/app/admin-console/organizations/settings/account.component.html @@ -1,9 +1,8 @@ -
@@ -37,9 +36,9 @@

{{ "apiKey" | i18n }}

-

+

{{ "apiKeyDesc" | i18n }} - + {{ "learnMore" | i18n }}

@@ -56,7 +55,7 @@ [formGroup]="collectionManagementFormGroup" >

{{ "collectionManagement" | i18n }}

-

{{ "collectionManagementDesc" | i18n }}

+

{{ "collectionManagementDesc" | i18n }}

{{ "allowAdminAccessToAllCollectionItemsDesc" | i18n }} diff --git a/bitwarden_license/bit-web/src/app/admin-console/providers/settings/account.component.html b/bitwarden_license/bit-web/src/app/admin-console/providers/settings/account.component.html index 10f6d14425..a4e4587755 100644 --- a/bitwarden_license/bit-web/src/app/admin-console/providers/settings/account.component.html +++ b/bitwarden_license/bit-web/src/app/admin-console/providers/settings/account.component.html @@ -2,51 +2,35 @@
- {{ "loading" | i18n }} + {{ "loading" | i18n }}
-
-
-
-
- + +
+
+ + {{ "providerName" | i18n }} + + + + {{ "billingEmail" | i18n }} -
-
- - -
+
-
+
- diff --git a/bitwarden_license/bit-web/src/app/admin-console/providers/settings/account.component.ts b/bitwarden_license/bit-web/src/app/admin-console/providers/settings/account.component.ts index e2b8aeaffd..01e863a826 100644 --- a/bitwarden_license/bit-web/src/app/admin-console/providers/settings/account.component.ts +++ b/bitwarden_license/bit-web/src/app/admin-console/providers/settings/account.component.ts @@ -1,5 +1,7 @@ -import { Component } from "@angular/core"; +import { Component, OnDestroy, OnInit } from "@angular/core"; +import { FormBuilder, Validators } from "@angular/forms"; import { ActivatedRoute, Router } from "@angular/router"; +import { Subject, switchMap, takeUntil } from "rxjs"; import { UserVerificationDialogComponent } from "@bitwarden/auth/angular"; import { ApiService } from "@bitwarden/common/abstractions/api.service"; @@ -19,15 +21,18 @@ import { DialogService } from "@bitwarden/components"; templateUrl: "account.component.html", }) // eslint-disable-next-line rxjs-angular/prefer-takeuntil -export class AccountComponent { +export class AccountComponent implements OnDestroy, OnInit { selfHosted = false; loading = true; provider: ProviderResponse; - formPromise: Promise; taxFormPromise: Promise; + private destroy$ = new Subject(); private providerId: string; - + protected formGroup = this.formBuilder.group({ + providerName: ["" as ProviderResponse["name"]], + providerBillingEmail: ["" as ProviderResponse["billingEmail"], Validators.email], + }); protected enableDeleteProvider$ = this.configService.getFeatureFlag$( FeatureFlag.EnableDeleteProvider, ); @@ -42,39 +47,47 @@ export class AccountComponent { private dialogService: DialogService, private configService: ConfigService, private providerApiService: ProviderApiServiceAbstraction, + private formBuilder: FormBuilder, private router: Router, ) {} async ngOnInit() { this.selfHosted = this.platformUtilsService.isSelfHost(); - // eslint-disable-next-line rxjs-angular/prefer-takeuntil, rxjs/no-async-subscribe - this.route.parent.parent.params.subscribe(async (params) => { - this.providerId = params.providerId; - try { - this.provider = await this.providerApiService.getProvider(this.providerId); - } catch (e) { - this.logService.error(`Handled exception: ${e}`); - } - }); - this.loading = false; + this.route.parent.parent.params + .pipe( + switchMap(async (params) => { + this.providerId = params.providerId; + try { + this.provider = await this.providerApiService.getProvider(this.providerId); + this.formGroup.patchValue({ + providerName: this.provider.name, + providerBillingEmail: this.provider.billingEmail, + }); + } catch (e) { + this.logService.error(`Handled exception: ${e}`); + } finally { + this.loading = false; + } + }), + takeUntil(this.destroy$), + ) + .subscribe(); } - - async submit() { - try { - const request = new ProviderUpdateRequest(); - request.name = this.provider.name; - request.businessName = this.provider.businessName; - request.billingEmail = this.provider.billingEmail; - - this.formPromise = this.providerApiService.putProvider(this.providerId, request).then(() => { - return this.syncService.fullSync(true); - }); - await this.formPromise; - this.platformUtilsService.showToast("success", null, this.i18nService.t("providerUpdated")); - } catch (e) { - this.logService.error(`Handled exception: ${e}`); - } + ngOnDestroy() { + this.destroy$.next(); + this.destroy$.complete(); } + submit = async () => { + const request = new ProviderUpdateRequest(); + request.name = this.formGroup.value.providerName; + request.businessName = this.formGroup.value.providerName; + request.billingEmail = this.formGroup.value.providerBillingEmail; + + await this.providerApiService.putProvider(this.providerId, request); + await this.syncService.fullSync(true); + this.provider = await this.providerApiService.getProvider(this.providerId); + this.platformUtilsService.showToast("success", null, this.i18nService.t("providerUpdated")); + }; async deleteProvider() { const providerClients = await this.apiService.getProviderClients(this.providerId); @@ -105,7 +118,6 @@ export class AccountComponent { } catch (e) { this.logService.error(e); } - await this.router.navigate(["/"]); }