Skip to content

Commit

Permalink
no userInfo for profile-menu (#2339)
Browse files Browse the repository at this point in the history
* fix(header): fixes issue when no service links are provided in hide-login mode for profile-menu
  • Loading branch information
tshimber authored Oct 10, 2024
1 parent 1c98c49 commit d1209c5
Show file tree
Hide file tree
Showing 3 changed files with 614 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ scale-telekom-profile-menu scale-menu-flyout {
height: 12px;
}

.scale-telekom-nav-item > button {
scale-telekom-profile-menu .scale-telekom-nav-item > button {
padding-bottom: var(--_spacing-bottom-slotted-bottom);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export class TelekomProfileMenu {
buildLogoutButton() {
return {
type: 'button',
name: this.logoutLabel,
name: this.logoutLabel || 'Logout',
href: this.logoutUrl || LOGOUT_DEFAULT,
variant: 'secondary',
onClick: this.logoutHandler,
Expand All @@ -176,17 +176,11 @@ export class TelekomProfileMenu {
const divider = [{ type: 'divider' }];

const userInfo = readData(this.userInfo);
if (!userInfo) {
// console.error("userInfo missing");
}
userInfo.type = 'userInfo';

let serviceLinks = readData(this.serviceLinks);
if (!serviceLinks) {
// console.error("serviceLinks missing");
serviceLinks = [];
if (userInfo) {
userInfo.type = 'userInfo';
}

const serviceLinks = readData(this.serviceLinks) || [];
for (const el of serviceLinks) {
el.type = 'item';
}
Expand All @@ -200,9 +194,11 @@ export class TelekomProfileMenu {

let menu = [];

menu = menu.concat(userInfo);
if (userInfo) {
menu = menu.concat(userInfo);
}

if (!this.serviceLinksEmpty()) {
if (userInfo && !this.serviceLinksEmpty()) {
menu = menu.concat(divider);
}

Expand All @@ -221,7 +217,10 @@ export class TelekomProfileMenu {
}

serviceLinksEmpty() {
return (this.hideLoginSettings && this.serviceLinks.length < 1) === true;
return (
this.hideLoginSettings &&
(!this.serviceLinks || this.serviceLinks.length < 1)
);
}

buildDesktopMenuStyles() {
Expand Down
Loading

0 comments on commit d1209c5

Please sign in to comment.