Skip to content

Commit

Permalink
AnonLayoutWrapperComponents - Add reset support for null values (#11651)
Browse files Browse the repository at this point in the history
  • Loading branch information
JaredSnider-Bitwarden authored Oct 21, 2024
1 parent 79cdf3b commit c16d1e0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,31 +131,35 @@ export class ExtensionAnonLayoutWrapperComponent implements OnInit, OnDestroy {
return;
}

if (data.pageTitle) {
this.pageTitle = this.handleStringOrTranslation(data.pageTitle);
// Null emissions are used to reset the page data as all fields are optional.

if (data.pageTitle !== undefined) {
this.pageTitle =
data.pageTitle !== null ? this.handleStringOrTranslation(data.pageTitle) : null;
}

if (data.pageSubtitle) {
this.pageSubtitle = this.handleStringOrTranslation(data.pageSubtitle);
if (data.pageSubtitle !== undefined) {
this.pageSubtitle =
data.pageSubtitle !== null ? this.handleStringOrTranslation(data.pageSubtitle) : null;
}

if (data.pageIcon) {
this.pageIcon = data.pageIcon;
if (data.pageIcon !== undefined) {
this.pageIcon = data.pageIcon !== null ? data.pageIcon : null;
}

if (data.showReadonlyHostname != null) {
if (data.showReadonlyHostname !== undefined) {
this.showReadonlyHostname = data.showReadonlyHostname;
}

if (data.showAcctSwitcher != null) {
if (data.showAcctSwitcher !== undefined) {
this.showAcctSwitcher = data.showAcctSwitcher;
}

if (data.showBackButton != null) {
if (data.showBackButton !== undefined) {
this.showBackButton = data.showBackButton;
}

if (data.showLogo != null) {
if (data.showLogo !== undefined) {
this.showLogo = data.showLogo;
}
}
Expand Down
24 changes: 14 additions & 10 deletions libs/auth/src/angular/anon-layout/anon-layout-wrapper.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ export interface AnonLayoutWrapperData {
* If a string is provided, it will be presented as is (ex: Organization name)
* If a Translation object (supports placeholders) is provided, it will be translated
*/
pageTitle?: string | Translation;
pageTitle?: string | Translation | null;
/**
* The optional subtitle of the page.
* If a string is provided, it will be presented as is (ex: user's email)
* If a Translation object (supports placeholders) is provided, it will be translated
*/
pageSubtitle?: string | Translation;
pageSubtitle?: string | Translation | null;
/**
* The optional icon to display on the page.
*/
pageIcon?: Icon;
pageIcon?: Icon | null;
/**
* Optional flag to either show the optional environment selector (false) or just a readonly hostname (true).
*/
Expand Down Expand Up @@ -114,19 +114,23 @@ export class AnonLayoutWrapperComponent implements OnInit, OnDestroy {
return;
}

if (data.pageTitle) {
this.pageTitle = this.handleStringOrTranslation(data.pageTitle);
// Null emissions are used to reset the page data as all fields are optional.

if (data.pageTitle !== undefined) {
this.pageTitle =
data.pageTitle !== null ? this.handleStringOrTranslation(data.pageTitle) : null;
}

if (data.pageSubtitle) {
this.pageSubtitle = this.handleStringOrTranslation(data.pageSubtitle);
if (data.pageSubtitle !== undefined) {
this.pageSubtitle =
data.pageSubtitle !== null ? this.handleStringOrTranslation(data.pageSubtitle) : null;
}

if (data.pageIcon) {
this.pageIcon = data.pageIcon;
if (data.pageIcon !== undefined) {
this.pageIcon = data.pageIcon !== null ? data.pageIcon : null;
}

if (data.showReadonlyHostname != null) {
if (data.showReadonlyHostname !== undefined) {
this.showReadonlyHostname = data.showReadonlyHostname;
}

Expand Down

0 comments on commit c16d1e0

Please sign in to comment.