mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 00:33:44 +00:00
[PM-8115] Desktop, Extension UI Refresh: Self-hosted Setup Dialog (#11597)
* Reimplement RegistrationSelfHostedEnvConfigDialogComponent * Update EnvironmentSelectorComponent text based on feature flag. * Initialize RegistrationSelfHostedEnvConfigDialog with existing values if self hosted * Cleanup debug * Add comment * Remove changes to home and login components * Remove changes to desktop login component * Remove changes to browser home component * Simplify accessing string. * Add environment selector service. * Cleanup unused imports in environment-selector * Launch new env selector dialog from desktop * Fix lint errors * Address PR feedback: move dialog component, remove EnvironmentSelectorService, remove unused translation string * Remove changes to AnonLayout * PM-8115 - Export Re-usable component from Libs/auth for clean import elsewhere in clients. * Remove unused accessingString variable * Add success toast --------- Co-authored-by: Jared Snider <jsnider@bitwarden.com>
This commit is contained in:
@@ -55,3 +55,6 @@ export * from "./lock/lock-component.service";
|
||||
|
||||
// vault timeout
|
||||
export * from "./vault-timeout-input/vault-timeout-input.component";
|
||||
|
||||
// self hosted environment configuration dialog
|
||||
export * from "./self-hosted-env-config-dialog/self-hosted-env-config-dialog.component";
|
||||
|
||||
@@ -15,7 +15,7 @@ import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.servic
|
||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||
import { DialogService, FormFieldModule, SelectModule, ToastService } from "@bitwarden/components";
|
||||
|
||||
import { RegistrationSelfHostedEnvConfigDialogComponent } from "./registration-self-hosted-env-config-dialog.component";
|
||||
import { SelfHostedEnvConfigDialogComponent } from "../../self-hosted-env-config-dialog/self-hosted-env-config-dialog.component";
|
||||
|
||||
/**
|
||||
* Component for selecting the environment to register with in the email verification registration flow.
|
||||
@@ -125,9 +125,7 @@ export class RegistrationEnvSelectorComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
if (selectedRegion === Region.SelfHosted) {
|
||||
return from(
|
||||
RegistrationSelfHostedEnvConfigDialogComponent.open(this.dialogService),
|
||||
).pipe(
|
||||
return from(SelfHostedEnvConfigDialogComponent.open(this.dialogService)).pipe(
|
||||
tap((result: boolean | undefined) =>
|
||||
this.handleSelfHostedEnvConfigDialogResult(result, prevSelectedRegion),
|
||||
),
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
ValidationErrors,
|
||||
ValidatorFn,
|
||||
} from "@angular/forms";
|
||||
import { Subject, firstValueFrom } from "rxjs";
|
||||
import { Subject, firstValueFrom, take, filter, takeUntil } from "rxjs";
|
||||
|
||||
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
||||
import {
|
||||
@@ -54,8 +54,8 @@ function selfHostedEnvSettingsFormValidator(): ValidatorFn {
|
||||
*/
|
||||
@Component({
|
||||
standalone: true,
|
||||
selector: "auth-registration-self-hosted-env-config-dialog",
|
||||
templateUrl: "registration-self-hosted-env-config-dialog.component.html",
|
||||
selector: "self-hosted-env-config-dialog",
|
||||
templateUrl: "self-hosted-env-config-dialog.component.html",
|
||||
imports: [
|
||||
CommonModule,
|
||||
JslibModule,
|
||||
@@ -68,14 +68,14 @@ function selfHostedEnvSettingsFormValidator(): ValidatorFn {
|
||||
AsyncActionsModule,
|
||||
],
|
||||
})
|
||||
export class RegistrationSelfHostedEnvConfigDialogComponent implements OnInit, OnDestroy {
|
||||
export class SelfHostedEnvConfigDialogComponent implements OnInit, OnDestroy {
|
||||
/**
|
||||
* Opens the dialog.
|
||||
* @param dialogService - Dialog service.
|
||||
* @returns Promise that resolves to true if the dialog was closed with a successful result, false otherwise.
|
||||
*/
|
||||
static async open(dialogService: DialogService): Promise<boolean> {
|
||||
const dialogRef = dialogService.open<boolean>(RegistrationSelfHostedEnvConfigDialogComponent, {
|
||||
const dialogRef = dialogService.open<boolean>(SelfHostedEnvConfigDialogComponent, {
|
||||
disableClose: false,
|
||||
});
|
||||
|
||||
@@ -131,7 +131,33 @@ export class RegistrationSelfHostedEnvConfigDialogComponent implements OnInit, O
|
||||
private environmentService: EnvironmentService,
|
||||
) {}
|
||||
|
||||
ngOnInit() {}
|
||||
ngOnInit() {
|
||||
/**
|
||||
* Populate the form with the current self-hosted environment settings.
|
||||
*/
|
||||
this.environmentService.environment$
|
||||
.pipe(
|
||||
take(1),
|
||||
filter((env) => {
|
||||
const region = env.getRegion();
|
||||
return region === Region.SelfHosted;
|
||||
}),
|
||||
takeUntil(this.destroy$),
|
||||
)
|
||||
.subscribe({
|
||||
next: (env) => {
|
||||
const urls = env.getUrls();
|
||||
this.formGroup.patchValue({
|
||||
baseUrl: urls.base || "",
|
||||
webVaultUrl: urls.webVault || "",
|
||||
apiUrl: urls.api || "",
|
||||
identityUrl: urls.identity || "",
|
||||
iconsUrl: urls.icons || "",
|
||||
notificationsUrl: urls.notifications || "",
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
submit = async () => {
|
||||
this.showErrorSummary = false;
|
||||
Reference in New Issue
Block a user