-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Edit Site: Refactor business logic into store. #22844
Conversation
Size Change: +1.09 kB (0%) Total Size: 1.12 MB
ℹ️ View Unchanged
|
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.
This is looking great and cleans things up quite a bit. Thank you!
Reading through the code changes things look good.
From what I can tell mostly everything in the site editor works as expected in testing. However, I notice that when I test the template switcher's "Overwrite Template" / "Revert to Parent" functionality for a page, the revert doesn't go through as on Master. Eventually get a 410 console error with Uncaught (in promise) {code: "rest_already_trashed", message: "The post has already been deleted.", data: {…}}
Oops, I missed that part while refactoring. All done now 😄 |
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.
Awesome, thanks for the quick fix there too!
Ive gone through and tested everything I can think of again in the site editor, and it's all working as expected. After combing through the code again, things look good to me!
/** | ||
* Returns the current template IDs. | ||
* | ||
* @param {Object} state Global application state. | ||
* | ||
* @return {number[]} Template IDs. | ||
*/ | ||
export function getTemplateIds( state ) { | ||
return state.templateIds; | ||
} |
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.
AFAICS, the getTemplateIds
selector isn't used anywhere. We could consider dropping it (and the corresponding templateIds
reducer, plus potentially some related actions, resolvers, and editorInitialState
).
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 think they might come in handy down the road though? If I'm understanding it right their values are being initialized from the edit-site-page.php
, so now getting them will be easily accessible in future development. I'm assuming there are plans to use this (I'm kind of surprised its not already)?
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.
Nice to see this PR. Thanks @epiqueras |
Description
This PR refactors all of the
edit-site
business logic and editor state into the store.It also moves a local utility,
getPathAndQueryString
, into the@wordpress/url
package.How has this been tested?
Tests were written for all the new functions, and it was verified that nothing changed in the site editor.
Types of Changes
New Feature:
@wordpress/url
now has agetPathAndQueryString
utility.Checklist: