-
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
Posts DataViews: Refactor the router to use route registration #67160
Conversation
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. |
|
||
const { RouterProvider } = unlock( routerPrivateApis ); | ||
const { GlobalStylesProvider } = unlock( editorPrivateApis ); | ||
|
||
function PostsLayout() { | ||
useRegisterPostsAppRoutes(); | ||
const route = useActiveRoute(); |
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.
One interesting thing here, is that now this hook is the exact same one used in the site editor.
content: <PostList postType="post" />, | ||
mobile: <PostList postType="post" />, | ||
}, | ||
}; |
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.
Another interesting thing is that all these routes are the exact same ones that exist in the site editor, there are just very small differences:
postType
is "post" instead of "page"- isRoot in the sidebar instead of
backPath={}
(this is just temporary because the posts page doesn't have categories and tags yet so it's top level) - isPostsPage argument passed to the
Editor
component.
This is a good thing and an indication that we can easily support custom post types with the same routes (by making the post type dynamic)
Size Change: +71 B (0%) Total Size: 1.82 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.
LGTM, thanks!
The bug you noticed exists in trunk too.
e40691b
to
674916a
Compare
Flaky tests detected in 674916a. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/11954760904
|
#62371
What?
This PR refactors the experimental "posts dataviews" pages to use route registration just like the regular site editor.
Testing Instructions
There should be no functional changes here, it's just the same as trunk.
One bug I noticed is that when you navigate in the app, the "page" argument is removed from the url which means when you refresh the page, you end up with a white screen. I don't think this bug is specific to this PR though.