AnonLayoutWrapperComponents - Add reset support for null values (#11651)

This commit is contained in:
Jared Snider 2024-10-21 18:52:07 -04:00 committed by GitHub
parent 79cdf3bf50
commit c16d1e0e74
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 28 additions and 20 deletions

View File

@ -131,31 +131,35 @@ export class ExtensionAnonLayoutWrapperComponent implements OnInit, OnDestroy {
return; return;
} }
if (data.pageTitle) { // Null emissions are used to reset the page data as all fields are optional.
this.pageTitle = this.handleStringOrTranslation(data.pageTitle);
if (data.pageTitle !== undefined) {
this.pageTitle =
data.pageTitle !== null ? this.handleStringOrTranslation(data.pageTitle) : null;
} }
if (data.pageSubtitle) { if (data.pageSubtitle !== undefined) {
this.pageSubtitle = this.handleStringOrTranslation(data.pageSubtitle); this.pageSubtitle =
data.pageSubtitle !== null ? this.handleStringOrTranslation(data.pageSubtitle) : null;
} }
if (data.pageIcon) { if (data.pageIcon !== undefined) {
this.pageIcon = data.pageIcon; this.pageIcon = data.pageIcon !== null ? data.pageIcon : null;
} }
if (data.showReadonlyHostname != null) { if (data.showReadonlyHostname !== undefined) {
this.showReadonlyHostname = data.showReadonlyHostname; this.showReadonlyHostname = data.showReadonlyHostname;
} }
if (data.showAcctSwitcher != null) { if (data.showAcctSwitcher !== undefined) {
this.showAcctSwitcher = data.showAcctSwitcher; this.showAcctSwitcher = data.showAcctSwitcher;
} }
if (data.showBackButton != null) { if (data.showBackButton !== undefined) {
this.showBackButton = data.showBackButton; this.showBackButton = data.showBackButton;
} }
if (data.showLogo != null) { if (data.showLogo !== undefined) {
this.showLogo = data.showLogo; this.showLogo = data.showLogo;
} }
} }

View File

@ -14,17 +14,17 @@ export interface AnonLayoutWrapperData {
* If a string is provided, it will be presented as is (ex: Organization name) * 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 * 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. * The optional subtitle of the page.
* If a string is provided, it will be presented as is (ex: user's email) * 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 * 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. * 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). * Optional flag to either show the optional environment selector (false) or just a readonly hostname (true).
*/ */
@ -114,19 +114,23 @@ export class AnonLayoutWrapperComponent implements OnInit, OnDestroy {
return; return;
} }
if (data.pageTitle) { // Null emissions are used to reset the page data as all fields are optional.
this.pageTitle = this.handleStringOrTranslation(data.pageTitle);
if (data.pageTitle !== undefined) {
this.pageTitle =
data.pageTitle !== null ? this.handleStringOrTranslation(data.pageTitle) : null;
} }
if (data.pageSubtitle) { if (data.pageSubtitle !== undefined) {
this.pageSubtitle = this.handleStringOrTranslation(data.pageSubtitle); this.pageSubtitle =
data.pageSubtitle !== null ? this.handleStringOrTranslation(data.pageSubtitle) : null;
} }
if (data.pageIcon) { if (data.pageIcon !== undefined) {
this.pageIcon = data.pageIcon; this.pageIcon = data.pageIcon !== null ? data.pageIcon : null;
} }
if (data.showReadonlyHostname != null) { if (data.showReadonlyHostname !== undefined) {
this.showReadonlyHostname = data.showReadonlyHostname; this.showReadonlyHostname = data.showReadonlyHostname;
} }