1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 00:33:44 +00:00

refactor to use a uiState enum for UI states

This commit is contained in:
rr-bw
2024-09-11 16:47:43 -07:00
parent 96f31ecf61
commit f9dc91228b
2 changed files with 15 additions and 12 deletions

View File

@@ -1,6 +1,6 @@
import { CommonModule } from "@angular/common";
import { Component, ElementRef, Input, NgZone, OnDestroy, OnInit, ViewChild } from "@angular/core";
import { FormBuilder, ReactiveFormsModule, Validators } from "@angular/forms";
import { FormBuilder, FormControl, ReactiveFormsModule, Validators } from "@angular/forms";
import { ActivatedRoute, Router, RouterModule } from "@angular/router";
import { first, firstValueFrom, of, Subject, switchMap, take, takeUntil } from "rxjs";
@@ -43,6 +43,11 @@ import { LoginService } from "./login.service";
const BroadcasterSubscriptionId = "LoginComponent";
export enum LoginUiState {
EMAIL_ENTRY = "EmailEntry",
MASTER_PASSWORD_ENTRY = "MasterPasswordEntry",
}
@Component({
standalone: true,
templateUrl: "./login.component.html",
@@ -68,6 +73,7 @@ export class LoginComponentV2 implements OnInit, OnDestroy {
captchaToken: string = null;
clientType: ClientType;
ClientType = ClientType;
LoginUiState = LoginUiState;
registerRoute$ = this.registerRouteService.registerRoute$(); // TODO: remove when email verification flag is removed
showLoginWithDevice = false;
validatedEmail = false;
@@ -81,14 +87,18 @@ export class LoginComponentV2 implements OnInit, OnDestroy {
rememberEmail: [false],
});
get emailFormControl() {
get emailFormControl(): FormControl<string> {
return this.formGroup.controls.email;
}
get loggedEmail() {
get loggedEmail(): string {
return this.formGroup.value.email;
}
get uiState(): LoginUiState {
return this.validatedEmail ? LoginUiState.MASTER_PASSWORD_ENTRY : LoginUiState.EMAIL_ENTRY;
}
// Web properties
enforcedPasswordPolicyOptions: MasterPasswordPolicyOptions;
policies: Policy[];