mirror of
https://github.com/bitwarden/browser
synced 2025-12-12 14:23:32 +00:00
[PM-21021] - fix toggled hidden field state for custom fields view (#14595)
* fix toggled hidden field state for custom fields view * fix hidden field toggle for cards and login details
This commit is contained in:
@@ -33,6 +33,7 @@
|
|||||||
bitIconButton
|
bitIconButton
|
||||||
bitPasswordInputToggle
|
bitPasswordInputToggle
|
||||||
data-testid="toggle-number"
|
data-testid="toggle-number"
|
||||||
|
[toggled]="revealCardNumber"
|
||||||
(toggledChange)="logCardEvent($event, EventType.Cipher_ClientToggledCardNumberVisible)"
|
(toggledChange)="logCardEvent($event, EventType.Cipher_ClientToggledCardNumberVisible)"
|
||||||
></button>
|
></button>
|
||||||
<button
|
<button
|
||||||
@@ -76,6 +77,7 @@
|
|||||||
bitIconButton
|
bitIconButton
|
||||||
bitPasswordInputToggle
|
bitPasswordInputToggle
|
||||||
data-testid="toggle-code"
|
data-testid="toggle-code"
|
||||||
|
[toggled]="revealCardCode"
|
||||||
(toggledChange)="logCardEvent($event, EventType.Cipher_ClientToggledCardCodeVisible)"
|
(toggledChange)="logCardEvent($event, EventType.Cipher_ClientToggledCardCodeVisible)"
|
||||||
></button>
|
></button>
|
||||||
<button
|
<button
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// FIXME: Update this file to be type safe and remove this and next line
|
// FIXME: Update this file to be type safe and remove this and next line
|
||||||
// @ts-strict-ignore
|
// @ts-strict-ignore
|
||||||
import { CommonModule } from "@angular/common";
|
import { CommonModule } from "@angular/common";
|
||||||
import { Component, Input } from "@angular/core";
|
import { Component, Input, OnChanges, SimpleChanges } from "@angular/core";
|
||||||
|
|
||||||
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
||||||
import { EventCollectionService } from "@bitwarden/common/abstractions/event/event-collection.service";
|
import { EventCollectionService } from "@bitwarden/common/abstractions/event/event-collection.service";
|
||||||
@@ -35,10 +35,13 @@ import { ReadOnlyCipherCardComponent } from "../read-only-cipher-card/read-only-
|
|||||||
ReadOnlyCipherCardComponent,
|
ReadOnlyCipherCardComponent,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class CardDetailsComponent {
|
export class CardDetailsComponent implements OnChanges {
|
||||||
@Input() cipher: CipherView;
|
@Input() cipher: CipherView;
|
||||||
EventType = EventType;
|
EventType = EventType;
|
||||||
|
|
||||||
|
revealCardNumber: boolean = false;
|
||||||
|
revealCardCode: boolean = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private i18nService: I18nService,
|
private i18nService: I18nService,
|
||||||
private eventCollectionService: EventCollectionService,
|
private eventCollectionService: EventCollectionService,
|
||||||
@@ -48,6 +51,13 @@ export class CardDetailsComponent {
|
|||||||
return this.cipher.card;
|
return this.cipher.card;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnChanges(changes: SimpleChanges): void {
|
||||||
|
if (changes["cipher"]) {
|
||||||
|
this.revealCardNumber = false;
|
||||||
|
this.revealCardCode = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
get setSectionTitle() {
|
get setSectionTitle() {
|
||||||
if (this.card.brand && this.card.brand !== "Other") {
|
if (this.card.brand && this.card.brand !== "Other") {
|
||||||
return this.i18nService.t("cardBrandDetails", this.card.brand);
|
return this.i18nService.t("cardBrandDetails", this.card.brand);
|
||||||
@@ -56,6 +66,11 @@ export class CardDetailsComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async logCardEvent(conditional: boolean, event: EventType) {
|
async logCardEvent(conditional: boolean, event: EventType) {
|
||||||
|
if (event === EventType.Cipher_ClientToggledCardNumberVisible) {
|
||||||
|
this.revealCardNumber = conditional;
|
||||||
|
} else if (event === EventType.Cipher_ClientToggledCardCodeVisible) {
|
||||||
|
this.revealCardCode = conditional;
|
||||||
|
}
|
||||||
if (conditional) {
|
if (conditional) {
|
||||||
await this.eventCollectionService.collect(
|
await this.eventCollectionService.collect(
|
||||||
event,
|
event,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// FIXME: Update this file to be type safe and remove this and next line
|
// FIXME: Update this file to be type safe and remove this and next line
|
||||||
// @ts-strict-ignore
|
// @ts-strict-ignore
|
||||||
import { CommonModule } from "@angular/common";
|
import { CommonModule } from "@angular/common";
|
||||||
import { Component, Input, OnInit } from "@angular/core";
|
import { Component, Input, OnChanges, OnInit, SimpleChanges } from "@angular/core";
|
||||||
|
|
||||||
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
||||||
import { EventCollectionService } from "@bitwarden/common/abstractions/event/event-collection.service";
|
import { EventCollectionService } from "@bitwarden/common/abstractions/event/event-collection.service";
|
||||||
@@ -45,7 +45,7 @@ import { VaultAutosizeReadOnlyTextArea } from "../../directives/readonly-textare
|
|||||||
VaultAutosizeReadOnlyTextArea,
|
VaultAutosizeReadOnlyTextArea,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class CustomFieldV2Component implements OnInit {
|
export class CustomFieldV2Component implements OnInit, OnChanges {
|
||||||
@Input() cipher: CipherView;
|
@Input() cipher: CipherView;
|
||||||
fieldType = FieldType;
|
fieldType = FieldType;
|
||||||
fieldOptions: any;
|
fieldOptions: any;
|
||||||
@@ -67,6 +67,12 @@ export class CustomFieldV2Component implements OnInit {
|
|||||||
this.fieldOptions = this.getLinkedFieldsOptionsForCipher();
|
this.fieldOptions = this.getLinkedFieldsOptionsForCipher();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnChanges(changes: SimpleChanges): void {
|
||||||
|
if (changes["cipher"]) {
|
||||||
|
this.revealedHiddenFields = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
getLinkedType(linkedId: LinkedIdType) {
|
getLinkedType(linkedId: LinkedIdType) {
|
||||||
const linkedType = this.fieldOptions.get(linkedId);
|
const linkedType = this.fieldOptions.get(linkedId);
|
||||||
return this.i18nService.t(linkedType.i18nKey);
|
return this.i18nService.t(linkedType.i18nKey);
|
||||||
|
|||||||
@@ -73,6 +73,7 @@
|
|||||||
type="button"
|
type="button"
|
||||||
bitIconButton
|
bitIconButton
|
||||||
bitPasswordInputToggle
|
bitPasswordInputToggle
|
||||||
|
[toggled]="passwordRevealed"
|
||||||
data-testid="toggle-password"
|
data-testid="toggle-password"
|
||||||
(toggledChange)="pwToggleValue($event)"
|
(toggledChange)="pwToggleValue($event)"
|
||||||
></button>
|
></button>
|
||||||
|
|||||||
@@ -1,7 +1,15 @@
|
|||||||
// FIXME: Update this file to be type safe and remove this and next line
|
// FIXME: Update this file to be type safe and remove this and next line
|
||||||
// @ts-strict-ignore
|
// @ts-strict-ignore
|
||||||
import { CommonModule, DatePipe } from "@angular/common";
|
import { CommonModule, DatePipe } from "@angular/common";
|
||||||
import { Component, EventEmitter, inject, Input, Output } from "@angular/core";
|
import {
|
||||||
|
Component,
|
||||||
|
EventEmitter,
|
||||||
|
inject,
|
||||||
|
Input,
|
||||||
|
OnChanges,
|
||||||
|
Output,
|
||||||
|
SimpleChanges,
|
||||||
|
} from "@angular/core";
|
||||||
import { Observable, switchMap } from "rxjs";
|
import { Observable, switchMap } from "rxjs";
|
||||||
|
|
||||||
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
||||||
@@ -51,7 +59,7 @@ type TotpCodeValues = {
|
|||||||
LinkModule,
|
LinkModule,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class LoginCredentialsViewComponent {
|
export class LoginCredentialsViewComponent implements OnChanges {
|
||||||
@Input() cipher: CipherView;
|
@Input() cipher: CipherView;
|
||||||
@Input() activeUserId: UserId;
|
@Input() activeUserId: UserId;
|
||||||
@Input() hadPendingChangePasswordTask: boolean;
|
@Input() hadPendingChangePasswordTask: boolean;
|
||||||
@@ -85,6 +93,13 @@ export class LoginCredentialsViewComponent {
|
|||||||
return `${dateCreated} ${creationDate}`;
|
return `${dateCreated} ${creationDate}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnChanges(changes: SimpleChanges): void {
|
||||||
|
if (changes["cipher"]) {
|
||||||
|
this.passwordRevealed = false;
|
||||||
|
this.showPasswordCount = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async getPremium(organizationId?: string) {
|
async getPremium(organizationId?: string) {
|
||||||
await this.premiumUpgradeService.promptForPremium(organizationId);
|
await this.premiumUpgradeService.promptForPremium(organizationId);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user