-
Notifications
You must be signed in to change notification settings - Fork 18
fix(internet-header): add self admin url prop to override menu links #4936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: release/v8
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@swisspost/internet-header': patch | ||
--- | ||
|
||
Added a `selfAdminOrigin` prop to the `swisspost-internet-header` component in order to let users override the calculated URL that is currently based on the `logoutURL`. |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -405,8 +405,8 @@ const vertx = window.vertx || {}; | |||||
const getLocation = function (url) { | ||||||
return new URL(url); | ||||||
}; | ||||||
const url = getLocation(logoutURL()); | ||||||
originUrl = url.origin; | ||||||
|
||||||
originUrl = platform.selfAdminOrigin ? platform.selfAdminOrigin : getLocation(logoutURL()).origin; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a nitpick, but since it's available, could as well use the nullish coalescing operator here.
Suggested change
|
||||||
const menuLinks = [ | ||||||
{ | ||||||
description: texts[currentLang].userProfile, | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,10 +104,15 @@ export class PostInternetHeader { | |
@Prop() languageLocalStorageKey?: string = 'swisspost-internet-header-language'; | ||
|
||
/** | ||
* Override the logout-url provided by the portal config. | ||
* Overrides the logout-url provided by the portal config. | ||
*/ | ||
@Prop() logoutUrl?: string; | ||
|
||
/** | ||
* Overrides the logout-url provided by the portal config. | ||
*/ | ||
@Prop() selfAdminOrigin?: string; | ||
Comment on lines
+107
to
+114
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we be a bit more specific here? These properties don't have the same effect and this comment will show up as type hint in project devs IDEs. |
||
|
||
/** | ||
* Set the currently activated route. If there is a link matching this URL in the header, it will be highlighted. | ||
* Will also highlight partly matching URLs. When set to auto, will use current location.href for comparison. | ||
|
@@ -182,6 +187,7 @@ export class PostInternetHeader { | |
try { | ||
state.projectId = this.project; | ||
state.stickyness = this.stickyness; | ||
state.selfAdminOrigin = this.selfAdminOrigin; | ||
state.environment = this.environment.toLocaleLowerCase() as Environment; | ||
if (this.language !== undefined) state.currentLanguage = this.language; | ||
state.languageSwitchOverrides = | ||
|
@@ -528,7 +534,10 @@ export class PostInternetHeader { | |
<post-search onDropdownToggled={e => this.handleDropdownToggled(e)}></post-search> | ||
</If> | ||
<If condition={!!renderLogin}> | ||
<post-klp-login-widget logout-url={this.logoutUrl}> | ||
<post-klp-login-widget | ||
logout-url={this.logoutUrl} | ||
self-admin-origin={this.selfAdminOrigin} | ||
> | ||
<slot name="login-widget"></slot> | ||
</post-klp-login-widget> | ||
</If> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the config is not hosted or served by the Design System, we can't alter it. Also, the system serving it is due to be deprecated, so it probably won't make sense to update it there either.