-
Notifications
You must be signed in to change notification settings - Fork 45
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
UI make navbar options configurable and filter menu items according to user groups #3154
UI make navbar options configurable and filter menu items according to user groups #3154
Conversation
34ed4dc
to
d47f6cd
Compare
11b39d9
to
63d8189
Compare
d47f6cd
to
43581e4
Compare
63d8189
to
e626624
Compare
0b00a42
to
428203e
Compare
9c96d6d
to
d695076
Compare
9e70a43
to
c7f33a8
Compare
0a7bd93
to
d695076
Compare
c7f33a8
to
904782f
Compare
d695076
to
73e4a52
Compare
904782f
to
d870add
Compare
Hello jbwatenbergscality,My role is to assist you with the merge of this Status report is not available. |
Waiting for approvalThe following approvals are needed before I can proceed with the merge:
Peer approvals must include at least 1 approval from the following list:
|
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.
Some small code improvements, behaviour looks good to me 👍
shell-ui/src/NavBar.js
Outdated
try { | ||
return { | ||
...renderer(path, translationAndGroup), | ||
selected: normalizedLocation === normalizePath(path), |
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.
Could be interesting to warn somehow (likely in console) when not a single entry matches the current location.
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.
Also, from what I can see, normalized paths are simply p.origin + p.pathname
. Isn't this going to break when a path is only linking to the root of a single-page app, and this app then manipulates the URL for virtual routes?
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.
You are right, I think I will add a regex in options to let solutions configure which routes should be considered as selected and maybe use this implementation as the default one if no regex is provided.
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.
Indeed, maybe assume that path
is always a regex (not sure how to handle escapes though).
Waiting for approvalThe following approvals are needed before I can proceed with the merge:
Peer approvals must include at least 1 approval from the following list:
The following reviewers are expecting changes from the author, or must review again: |
shell-ui/src/Navbar.spec.js
Outdated
@@ -62,7 +62,7 @@ describe('navbar', () => { | |||
/> |
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.
Would be great to format the code^^
shell-ui/src/setupTests.js
Outdated
@@ -2,6 +2,36 @@ import 'whatwg-fetch'; | |||
import "regenerator-runtime/runtime" |
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.
Missing the auto-format here too.
); | ||
}); | ||
|
||
it('should normalize path throw if invalid url', () => { |
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.
it('should normalize path throw if invalid url', () => { | |
it('should throw if the path is an invalid url', () => { |
41af475
to
06a5496
Compare
06a5496
to
06e1b08
Compare
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.
I'm OK with merging in this state 👌
For answering "which UI is active at the moment?", it will likely become easier once we switch tables and get the Shell to include other UIs instead of the opposite.
? new RegExp(translationAndGroup.activeIfMatches).test( | ||
location.href, | ||
) | ||
: normalizedLocation === normalizePath(path), |
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.
I'm afraid this default isn't really useful, since it will never match on "sub-paths"...
Maybe normalizedLocation.startsWith(normalizePath(path))
instead?
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.
I also thought about switching to startsWith but IMO it is not a correct approach because we can for example have a menu entry for /
and for /alerts
on the same UI where this default will make both entries selected. I think an exact match is the strongest default to avoid duplicated selected entries that could mislead the user.
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.
Mmh, right. So we'd need to sort by specificity of configured paths to know "which Ingress is catching the current page", I guess.
Waiting for approvalThe following approvals are needed before I can proceed with the merge:
Peer approvals must include at least 1 approval from the following list:
|
/approve |
In the queueThe changeset has received all authorizations and has been added to the The changeset will be merged in:
The following branches will NOT be impacted:
There is no action required on your side. You will be notified here once IMPORTANT Please do not attempt to modify this pull request.
If you need this pull request to be removed from the queue, please contact a The following options are set: approve |
I have successfully merged the changeset of this pull request
The following branches have NOT changed:
Please check the status of the associated issue None. Goodbye jbwatenbergscality. |
Component:
ui, shell-ui
Context:
Menu items displayed in the navbar should be configurable and filtered according to user groups (as provided as part of OIDC claims).
Acceptance criteria:
Unit tests
Closes : #3159