1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-20 10:13:31 +00:00

Vault Refactor: Clean up some strict types (#12357)

* update cipher-view to account for strict type checking

* update view-identity-sections to account for strict type checking

* update read-only-cipher-card to account for strict type checking

* remove unused card import

* remove unused card import

* update additional-options to account for strict type checking
This commit is contained in:
Nick Krantz
2024-12-20 10:16:34 -06:00
committed by GitHub
parent b27a1a5337
commit 6ad35e0871
5 changed files with 46 additions and 26 deletions

View File

@@ -1,12 +1,9 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { NgIf } from "@angular/common";
import { Component, Input, OnInit } from "@angular/core";
import { JslibModule } from "@bitwarden/angular/jslib.module";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import {
CardComponent,
FormFieldModule,
IconButtonModule,
SectionComponent,
@@ -23,7 +20,6 @@ import { ReadOnlyCipherCardComponent } from "../read-only-cipher-card/read-only-
imports: [
NgIf,
JslibModule,
CardComponent,
SectionComponent,
SectionHeaderComponent,
TypographyModule,
@@ -33,11 +29,11 @@ import { ReadOnlyCipherCardComponent } from "../read-only-cipher-card/read-only-
],
})
export class ViewIdentitySectionsComponent implements OnInit {
@Input() cipher: CipherView;
@Input({ required: true }) cipher: CipherView | null = null;
showPersonalDetails: boolean;
showIdentificationDetails: boolean;
showContactDetails: boolean;
showPersonalDetails: boolean = false;
showIdentificationDetails: boolean = false;
showContactDetails: boolean = false;
ngOnInit(): void {
this.showPersonalDetails = this.hasPersonalDetails();
@@ -47,6 +43,10 @@ export class ViewIdentitySectionsComponent implements OnInit {
/** Returns all populated address fields */
get addressFields(): string {
if (!this.cipher) {
return "";
}
const { address1, address2, address3, fullAddressPart2, country } = this.cipher.identity;
return [address1, address2, address3, fullAddressPart2, country].filter(Boolean).join("\n");
}
@@ -58,18 +58,30 @@ export class ViewIdentitySectionsComponent implements OnInit {
/** Returns true when any of the "personal detail" attributes are populated */
private hasPersonalDetails(): boolean {
if (!this.cipher) {
return false;
}
const { username, company, fullName } = this.cipher.identity;
return Boolean(fullName || username || company);
}
/** Returns true when any of the "identification detail" attributes are populated */
private hasIdentificationDetails(): boolean {
if (!this.cipher) {
return false;
}
const { ssn, passportNumber, licenseNumber } = this.cipher.identity;
return Boolean(ssn || passportNumber || licenseNumber);
}
/** Returns true when any of the "contact detail" attributes are populated */
private hasContactDetails(): boolean {
if (!this.cipher) {
return false;
}
const { email, phone } = this.cipher.identity;
return Boolean(email || phone || this.addressFields);