-
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
Core Data: Support entities in the 'canUser' selector #63322
Conversation
Size Change: +199 B (+0.01%) Total Size: 1.76 MB
ℹ️ View Unchanged
|
15462d4
to
a74fd72
Compare
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. |
I've tested editing post meta bindings and post title and everything seems to be working as expected 🙂 Regarding the code, it looks good after a quick look, but I'll defer the review to other folks because I am not fully familiar with the use cases, and I don't have the full context. |
Flaky tests detected in 19e01ea. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9874496323
|
config.name === resource.name && | ||
config.kind === resource.kind | ||
); | ||
if ( ! entityConfig ) { |
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.
Should we log an error in case kind
or name
don't correspond to an entity type?
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.
No other entity resolver does this; maybe we should re-evaluate missing config cases together?
const key = ( | ||
typeof resource === 'object' | ||
? [ action, resource.kind, resource.name, resource.id ] | ||
: [ action, resource, id ] |
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 could also be useful to log an error so the developer knows about unexpected usage.
@Mamaduka I see you mentioned those are rare in stores, but at the same time, when debugging store errors one often has to go deep, exactly because errors will often be silent or swallowed.
I have resolved most of the feedback and to-do items. It should be ready for another review. |
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.
🚢
f87e919
to
df1dbd2
Compare
Thanks everyone for the reviews and feedback. I rebased the branch just in case and will merge after the CI checks are green. |
* Core Data: Support entities in the 'canUser' selector * Cleanup 'canUser' unit tests * Add unit tests * Replace 'canUserEditEntityRecord' selector usages * Make 'canUserEditEntityRecord' forwarded selector/resolver * Add checks when the resource is an entity * Return false when entity arg is malformed * Update types and JSDoc * Throw an error when an entity resource object is malformed * Deprecate canUserEditEntityRecord Co-authored-by: Mamaduka <[email protected]> Co-authored-by: ellatrix <[email protected]> Co-authored-by: jsnajdr <[email protected]> Co-authored-by: tyxla <[email protected]> Co-authored-by: SantosGuillamot <[email protected]> Co-authored-by: adamziel <[email protected]> Co-authored-by: TimothyBJacobs <[email protected]>
Hey @Mamaduka 👋 Would you be able to help write a dev note for this for the 6.7 release? We are planning to have this as part of a larger Miscellaneous Editor Updates note. We are hoping to get all drafts in by October 13th to leave some time for reviews before the RC1. All Dev Notes get tracked in #65784 so feel free to leave a note there or ping me directly :) Please let us know if you can assist with that. Thanks in advance :) |
What?
Resolves #43751.
Alternative to #63292.
PR updates the
canUser
selector to support core data entities. The new supported and recommended syntax:Why?
canUser
- currently only supports resources in thewp/v2
namespace. Additionally, you must know the final REST API path. Typically, however, only an entity's kind and name are known.canUserEntityRecord
- is limited to only the edit action check. It was a wrapper forcanUser
and only supported thewp/v2
namespace, which hasn't been required since WP 5.9.The update also opens up the possibility of leveraging "target hints" and bulk fetch permissions data for DataViews.
Todo
canUserEditEntityRecord
selector.Testing Instructions
Basic Testing
Testing canUserEntityRecord changes
Testing Instructions for Keyboard
Same.
Screenshot