Image: Replace 'getEntityRecordPermissions` with 'canUser'#76125
Image: Replace 'getEntityRecordPermissions` with 'canUser'#76125
Conversation
Use the public 'canUser' selector instead of the private 'getEntityRecordPermissions'. Gate the check on 'imageRecord' availability to avoid fetching permissions before the record is loaded.
|
Size Change: -10 B (0%) Total Size: 6.87 MB
ℹ️ View Unchanged
|
|
Flaky tests detected in 2e5ab67. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/22657610427
|
andrewserong
left a comment
There was a problem hiding this comment.
Nice follow-up, thanks for catching this!
Waiting for imageRecord ensures there's no separate OPTIONS requests. Selector will use pre-resolved data. It also ensures we don't display control if media is missing.
Waiting for imageRecord seems to be the key that I was missing when I tried it last time, thanks for digging in!
LGTM 🚀
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
What?
This is a follow-up to #74601.
Use the public
canUserselector instead of the privategetEntityRecordPermissions. Gate the check onimageRecordavailability to avoid fetching permissions before the record is loaded.Why?
canUserdirectly should be preferred, just checking a single permission.OPTIONSrequests. Selector will use pre-resolved data. It also ensures we don't display control if media is missing.Testing Instructions
Testing Instructions for Keyboard
Same.
Screenshots or screencast