mirror of
https://github.com/bitwarden/browser.git
synced 2025-01-09 19:28:06 +01:00
refactor to use a uiState enum for UI states
This commit is contained in:
parent
96f31ecf61
commit
f9dc91228b
@ -42,11 +42,7 @@
|
|||||||
[bitSubmit]="submit"
|
[bitSubmit]="submit"
|
||||||
[formGroup]="formGroup"
|
[formGroup]="formGroup"
|
||||||
>
|
>
|
||||||
<!-----------------------------
|
<ng-container *ngIf="uiState === LoginUiState.EMAIL_ENTRY">
|
||||||
Web UI State 1: Email Entry
|
|
||||||
------------------------------>
|
|
||||||
<!-- TODO-rr-bw: consider refactoring this *ngIf check to something like LoginState.EmailEntry and LoginState.MasterPasswordEntry -->
|
|
||||||
<ng-container *ngIf="!validatedEmail">
|
|
||||||
<!-- Email Address input -->
|
<!-- Email Address input -->
|
||||||
<div class="tw-mb-3">
|
<div class="tw-mb-3">
|
||||||
<bit-form-field>
|
<bit-form-field>
|
||||||
@ -105,16 +101,13 @@
|
|||||||
</p>
|
</p>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<!---------------------------------------
|
|
||||||
Web UI State 2: Master Password Entry
|
|
||||||
---------------------------------------->
|
|
||||||
<!--
|
<!--
|
||||||
Why not use <ng-container *ngIf="validatedEmail"> to display this section?
|
Why not use <ng-container *ngIf="validatedEmail"> to display this section?
|
||||||
Because we want access to the masterPasswordInput reference in the class file.
|
Because we want access to the masterPasswordInput reference in the class file.
|
||||||
- Using a hidden div allows us to access the reference without rendering the div initially.
|
- Using a hidden div allows us to access the reference without rendering the div initially.
|
||||||
- Using *ngIf would not allow us to access the reference without rendering the ng-container initially.
|
- Using *ngIf would not allow us to access the reference without rendering the ng-container initially.
|
||||||
-->
|
-->
|
||||||
<div [ngClass]="{ 'tw-hidden': !validatedEmail }">
|
<div [ngClass]="{ 'tw-hidden': uiState !== LoginUiState.MASTER_PASSWORD_ENTRY }">
|
||||||
<div class="tw-mb-6 tw-h-28">
|
<div class="tw-mb-6 tw-h-28">
|
||||||
<!-- Master Password input -->
|
<!-- Master Password input -->
|
||||||
<bit-form-field class="!tw-mb-1">
|
<bit-form-field class="!tw-mb-1">
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { CommonModule } from "@angular/common";
|
import { CommonModule } from "@angular/common";
|
||||||
import { Component, ElementRef, Input, NgZone, OnDestroy, OnInit, ViewChild } from "@angular/core";
|
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 { ActivatedRoute, Router, RouterModule } from "@angular/router";
|
||||||
import { first, firstValueFrom, of, Subject, switchMap, take, takeUntil } from "rxjs";
|
import { first, firstValueFrom, of, Subject, switchMap, take, takeUntil } from "rxjs";
|
||||||
|
|
||||||
@ -43,6 +43,11 @@ import { LoginService } from "./login.service";
|
|||||||
|
|
||||||
const BroadcasterSubscriptionId = "LoginComponent";
|
const BroadcasterSubscriptionId = "LoginComponent";
|
||||||
|
|
||||||
|
export enum LoginUiState {
|
||||||
|
EMAIL_ENTRY = "EmailEntry",
|
||||||
|
MASTER_PASSWORD_ENTRY = "MasterPasswordEntry",
|
||||||
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
standalone: true,
|
standalone: true,
|
||||||
templateUrl: "./login.component.html",
|
templateUrl: "./login.component.html",
|
||||||
@ -68,6 +73,7 @@ export class LoginComponentV2 implements OnInit, OnDestroy {
|
|||||||
captchaToken: string = null;
|
captchaToken: string = null;
|
||||||
clientType: ClientType;
|
clientType: ClientType;
|
||||||
ClientType = ClientType;
|
ClientType = ClientType;
|
||||||
|
LoginUiState = LoginUiState;
|
||||||
registerRoute$ = this.registerRouteService.registerRoute$(); // TODO: remove when email verification flag is removed
|
registerRoute$ = this.registerRouteService.registerRoute$(); // TODO: remove when email verification flag is removed
|
||||||
showLoginWithDevice = false;
|
showLoginWithDevice = false;
|
||||||
validatedEmail = false;
|
validatedEmail = false;
|
||||||
@ -81,14 +87,18 @@ export class LoginComponentV2 implements OnInit, OnDestroy {
|
|||||||
rememberEmail: [false],
|
rememberEmail: [false],
|
||||||
});
|
});
|
||||||
|
|
||||||
get emailFormControl() {
|
get emailFormControl(): FormControl<string> {
|
||||||
return this.formGroup.controls.email;
|
return this.formGroup.controls.email;
|
||||||
}
|
}
|
||||||
|
|
||||||
get loggedEmail() {
|
get loggedEmail(): string {
|
||||||
return this.formGroup.value.email;
|
return this.formGroup.value.email;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get uiState(): LoginUiState {
|
||||||
|
return this.validatedEmail ? LoginUiState.MASTER_PASSWORD_ENTRY : LoginUiState.EMAIL_ENTRY;
|
||||||
|
}
|
||||||
|
|
||||||
// Web properties
|
// Web properties
|
||||||
enforcedPasswordPolicyOptions: MasterPasswordPolicyOptions;
|
enforcedPasswordPolicyOptions: MasterPasswordPolicyOptions;
|
||||||
policies: Policy[];
|
policies: Policy[];
|
||||||
|
Loading…
Reference in New Issue
Block a user