-
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
[Navigation editor] Save menu items using the REST API #34541
[Navigation editor] Save menu items using the REST API #34541
Conversation
Size Change: -1.19 kB (0%) Total Size: 1.06 MB
ℹ️ View Unchanged
|
Every thunk receives const thunk = () => ( { registry } ) => {
const error = registry.select( 'core' ).getLastEntitySaveError( 'root', 'menu', menuId );
/* ... */
} |
Uuu that's nice and I totally missed that, thank you! |
ae9dba0
to
852db8c
Compare
Still pretty draft-y, but I like how thunks + locks = -500 lines so far |
Not quite there yet, but we're getting close. |
16f4642
to
ed9ea01
Compare
Aside of the API problems, I think this is in a pretty good shape. Let's discuss! CCing previously involved folks @noisysocks @talldan @draganescu @TimothyBJacobs @spacedmonkey |
} ); | ||
} ); | ||
|
||
describe( 'saveNavigationPost', () => { |
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 removed these saveNavigationPost
tests for now as they are customizer-specific. Let's discuss the ideas in this PR and then double down with more relevant tests.
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.
We could use unit tests for the async REST API-based version, but I think it's okay to follow-up with that to avoid inflating this PR more than it already it.
ceddec8
to
4ff8b16
Compare
I love that this is in. I wanted to mention that the saving of blocks as menu items is something that started as an experiment, but that in the meantime the understanding of what exactly the block navigation opt in will do has evolved quite significantly. So, the focus of optimization and fixing after this |
Description
This PR migrates navigation saving from
admin-ajax.php
to REST API v2. It ended up being pretty large PR, we may or may not need to split it into a few smaller ones.Known issues
Partial failure is very much possible. A lot of validation happens in
prepare_item_for_database
so we can't rely onrequire-all-validate
feature of batch requests. The more validation we move tovalidate_callback
, the more reliable this will be.I don't think there is a good way of communicating the partial failure to the user so we should minimize the risk as much as possible. Here's how it looks like for now:
Other considerations
Editor is in a dirty state after loading the page. This is not specific to this PR – trunk behaves the same.
What about using
<EntityProvider />
? Would it make the code simpler?We could get rid of the "stub post", that's for sure. About batch saving – we'd still need to compute the diff between what's persisted and what's in memory. I think that
<EntityProvider />
would just callblockToMenuItem
earlier than we do now, but we'd still need to compute a list of batch tasks and check for errors.Other changes:
serializeProcessing
was replaced by locks fromcore-data
Related to #24907
Test plan
Go to the experimental navigation screen, play with it, and keep saving the data. Expect to see frequent API errors, but no JS errors.