-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Fix permissions warning showing when inserting a navigation block #41862
Conversation
Size Change: +430 B (0%) Total Size: 1.25 MB
ℹ️ View Unchanged
|
@talldan good spot! It can be I'd change this fragment instead:
To say: canUserUpdateNavigationMenu: canUpdate,
hasResolvedCanUserUpdateNavigationMenu:
ref && hasResolvedPermissions,
canUserDeleteNavigationMenu: canDelete,
hasResolvedCanUserDeleteNavigationMenu:
ref && hasResolvedPermissions, |
Thank you for the fix 👏 This seems like a regression. Should we add a test for it or do we want to avoid another potentially flaky test? |
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 tested and was able to replicate the Issue on trunk
. I switched to this branch and it was fixed.
Thank you 👏
If there is no menu then this should be falsey. In fact any call to the hook when the |
I'm migrating the tests to playwright at the moment, which is how I discovered the bug. I think it may be a bit tricky to write a test that catches this, as it's always difficult to check for the absence of something. We can try asserting
I think it depends on the question being asked. If it's "can I update or delete the current menu", then it should probably be
I'll go for something like this |
From what I remember the permissions are on a per post (menu) basis. So you can ask "can I update Menu X" but not "can I update all menus". I wish I'd written this down when I was working on the permissions feature of Nav block but turns out I didn't so I can't be 100% sure. I remember discussing with @spacedmonkey who has a very good understanding of the permissions system. I agree regarding |
What?
Fixes #41858, an incorrect permissions warning was showing
Why?
I think the main reason for the bug is that
canUserUpdateNavigationMenu
isundefined
in this situation, so! canUserUpdateNavigationMenu
resolves as truthy. One way to fix it might be to make this a more explicitcanUserUpdateNavigationMenu === false
, but I don't know specifically if that'd be the right thing to do and what other values that variable can have.How?
This message should only show when the navigation block has an active navigation menu selected/assigned. There's no check for that, so I've added one (checking for the
ref
being truthy).Testing Instructions