From 85e2715a117dc6028b31a0be139f3bea2b5e7575 Mon Sep 17 00:00:00 2001 From: Robyn MacCallum Date: Tue, 25 Oct 2022 17:18:11 -0400 Subject: [PATCH] [SG-753] Keep email after hint component is launched in browser (#3883) * Keep email after hint component is launched in browser * Use query params instead of state for consistency --- .../src/popup/accounts/hint.component.html | 4 ++- .../src/popup/accounts/hint.component.ts | 32 ++++++++++++++++--- .../src/popup/accounts/login.component.html | 7 +++- 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/apps/browser/src/popup/accounts/hint.component.html b/apps/browser/src/popup/accounts/hint.component.html index 828af9c5583d..d4fab78ae613 100644 --- a/apps/browser/src/popup/accounts/hint.component.html +++ b/apps/browser/src/popup/accounts/hint.component.html @@ -1,7 +1,9 @@
- +

{{ "passwordHint" | i18n }} diff --git a/apps/browser/src/popup/accounts/hint.component.ts b/apps/browser/src/popup/accounts/hint.component.ts index 7ecc9ef1cbb6..e92927621b7c 100644 --- a/apps/browser/src/popup/accounts/hint.component.ts +++ b/apps/browser/src/popup/accounts/hint.component.ts @@ -1,5 +1,6 @@ -import { Component } from "@angular/core"; -import { Router } from "@angular/router"; +import { Component, OnInit } from "@angular/core"; +import { ActivatedRoute, Router } from "@angular/router"; +import { Subject, takeUntil } from "rxjs"; import { HintComponent as BaseHintComponent } from "@bitwarden/angular/components/hint.component"; import { ApiService } from "@bitwarden/common/abstractions/api.service"; @@ -11,14 +12,37 @@ import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUti selector: "app-hint", templateUrl: "hint.component.html", }) -export class HintComponent extends BaseHintComponent { +export class HintComponent extends BaseHintComponent implements OnInit { + emailSent: string; + private destroy$ = new Subject(); + constructor( router: Router, platformUtilsService: PlatformUtilsService, i18nService: I18nService, apiService: ApiService, - logService: LogService + logService: LogService, + private route: ActivatedRoute ) { super(router, i18nService, apiService, platformUtilsService, logService); + + super.onSuccessfulSubmit = async () => { + this.router.navigate([this.successRoute], { queryParams: { email: this.emailSent } }); + }; + } + ngOnInit() { + this.route?.queryParams.pipe(takeUntil(this.destroy$)).subscribe((params) => { + if (params) { + const queryParamsEmail = params["email"]; + if (queryParamsEmail != null && queryParamsEmail.indexOf("@") > -1) { + this.emailSent = this.email = queryParamsEmail; + } + } + }); + } + + ngOnDestroy(): void { + this.destroy$.next(); + this.destroy$.complete(); } } diff --git a/apps/browser/src/popup/accounts/login.component.html b/apps/browser/src/popup/accounts/login.component.html index 4800fa4e8d60..b90e7eb0d98a 100644 --- a/apps/browser/src/popup/accounts/login.component.html +++ b/apps/browser/src/popup/accounts/login.component.html @@ -54,7 +54,12 @@