From d64509a5d96cf5dfbda8b32c9bc4f1e1304aab58 Mon Sep 17 00:00:00 2001 From: Jimmy Vo Date: Fri, 11 Apr 2025 12:56:31 -0400 Subject: [PATCH] [PM-19814] Disable the URL input and populate it with the phishing URL. --- .../pages/learn-more-component.ts | 24 +------- .../pages/phishing-warning.html | 12 ++-- .../pages/phishing-warning.ts | 57 +++++-------------- 3 files changed, 24 insertions(+), 69 deletions(-) diff --git a/apps/browser/src/phishing-detection/pages/learn-more-component.ts b/apps/browser/src/phishing-detection/pages/learn-more-component.ts index e4d842a75ba..252c6ea0c3c 100644 --- a/apps/browser/src/phishing-detection/pages/learn-more-component.ts +++ b/apps/browser/src/phishing-detection/pages/learn-more-component.ts @@ -1,34 +1,14 @@ -// FIXME: Update this file to be type safe and remove this and next line -// @ts-strict-ignore import { CommonModule } from "@angular/common"; import { Component } from "@angular/core"; -import { ActivatedRoute } from "@angular/router"; import { JslibModule } from "@bitwarden/angular/jslib.module"; -import { AnonLayoutComponent } from "@bitwarden/auth/angular"; import { ButtonModule } from "@bitwarden/components"; -import { PopOutComponent } from "../../platform/popup/components/pop-out.component"; -import { PopupPageComponent } from "../../platform/popup/layout/popup-page.component"; - @Component({ standalone: true, templateUrl: "learn-more-component.html", - imports: [ - AnonLayoutComponent, - CommonModule, - PopOutComponent, - PopupPageComponent, - PopupPageComponent, - CommonModule, - JslibModule, - ButtonModule, - ], + imports: [CommonModule, CommonModule, JslibModule, ButtonModule], }) export class LearnMoreComponent { - constructor(private activatedRoute: ActivatedRoute) {} - - closeTab(): void { - globalThis.close(); - } + constructor() {} } diff --git a/apps/browser/src/phishing-detection/pages/phishing-warning.html b/apps/browser/src/phishing-detection/pages/phishing-warning.html index b9350e330a5..fe547a72431 100644 --- a/apps/browser/src/phishing-detection/pages/phishing-warning.html +++ b/apps/browser/src/phishing-detection/pages/phishing-warning.html @@ -1,6 +1,8 @@ - - Phishing url - - +
+ + Phishing url + + - Exit page + Exit page +
diff --git a/apps/browser/src/phishing-detection/pages/phishing-warning.ts b/apps/browser/src/phishing-detection/pages/phishing-warning.ts index 4e96023f842..b343a685f2c 100644 --- a/apps/browser/src/phishing-detection/pages/phishing-warning.ts +++ b/apps/browser/src/phishing-detection/pages/phishing-warning.ts @@ -1,42 +1,25 @@ -// FIXME: Update this file to be type safe and remove this and next line -// @ts-strict-ignore import { CommonModule } from "@angular/common"; import { Component, OnDestroy, OnInit } from "@angular/core"; -import { ReactiveFormsModule } from "@angular/forms"; +import { FormBuilder, ReactiveFormsModule } from "@angular/forms"; import { ActivatedRoute, RouterModule } from "@angular/router"; -import { map, Observable, Subject, take } from "rxjs"; +import { Subject, takeUntil } from "rxjs"; import { JslibModule } from "@bitwarden/angular/jslib.module"; -import { AnonLayoutComponent, InputPasswordComponent } from "@bitwarden/auth/angular"; import { AsyncActionsModule, ButtonModule, CheckboxModule, FormFieldModule, - Icon, IconModule, LinkModule, } from "@bitwarden/components"; -import { PopOutComponent } from "../../platform/popup/components/pop-out.component"; -import { PopupHeaderComponent } from "../../platform/popup/layout/popup-header.component"; -import { PopupPageComponent } from "../../platform/popup/layout/popup-page.component"; - -interface ViewData { - phishingHost: string; -} - @Component({ standalone: true, templateUrl: "phishing-warning.html", imports: [ - AnonLayoutComponent, CommonModule, IconModule, - PopOutComponent, - InputPasswordComponent, - PopupHeaderComponent, - PopupPageComponent, JslibModule, LinkModule, ReactiveFormsModule, @@ -48,38 +31,28 @@ interface ViewData { ], }) export class PhishingWarning implements OnInit, OnDestroy { + formGroup = this.formBuilder.group({ + phishingHost: [""], + }); + private destroy$ = new Subject(); - protected showLogo: boolean = true; - protected hideIcon: boolean = false; - - protected pageTitle: string; - protected pageSubtitle: string; - protected pageIcon: Icon; - protected showReadonlyHostname: boolean; - protected maxWidth: "md" | "3xl"; - protected hasLoggedInAccount: boolean = false; - protected hideFooter: boolean; - - protected queryParams$: Observable; - - protected theme: string; - - constructor(private activatedRoute: ActivatedRoute) {} + constructor( + private activatedRoute: ActivatedRoute, + private formBuilder: FormBuilder, + ) {} async ngOnInit(): Promise { - this.queryParams$ = this.activatedRoute.queryParamMap.pipe( - take(1), - map((queryParamMap) => ({ - phishingHost: queryParamMap.get("phishingHost"), - })), - ); + this.activatedRoute.queryParamMap.pipe(takeUntil(this.destroy$)).subscribe((params) => { + this.formGroup.patchValue({ phishingHost: params.get("phishingHost") }); + this.formGroup.get("phishingHost")?.disable(); + }); } closeTab(): void { globalThis.close(); } - ngOnDestroy() { + ngOnDestroy(): void { this.destroy$.next(); this.destroy$.complete(); }