-
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
Add Navigation menu to known entities #39498
Conversation
Size Change: +22 B (0%) Total Size: 1.16 MB
ℹ️ View Unchanged
|
We have menus, menu items, menu locations, navigation menus – it is getting confusing. Would you please add a few comments inside entities.js to explain how are these different from each other? |
@@ -175,6 +175,14 @@ export const rootEntitiesConfig = [ | |||
baseURLParams: { context: 'edit' }, | |||
key: 'plugin', | |||
}, | |||
{ | |||
label: __( 'Navigation' ), // Block based Navigation Menus |
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.
Is it a post type? If so, do we refer to it with kind="postType"
in other packages?
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's a custom post type yes. That's why it's
wp.data.select('core').getEntityRecords('postType','wp_navigation')
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's a custom post type yes. That's why it's
wp.data.select('core').getEntityRecords('postType','wp_navigation')
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.
In this case this needs a follow up to replace all the getEntityRecords('postType','wp_navigation')
calls for the getEntityRecords('root','navigationMenus')
.
But thinking more about this – introducing two different ways to refer to the same thing will likely lead to, well, two different ways of using it. Shall we rollback this PR and instead hardcode a shortcut that would refer to the postType, wp_navigation
pair?
ed3e2e0
to
be9d317
Compare
Rebasing in the hope that the e2e tests have been fixed on |
I revert this PR in #39572 because it appeared to cause a regression whereby Templates wouldn't load in the Site Editor. |
* Add Navigation menu to known entities * Add comments for clarity Addresses WordPress#39498 (comment)
…enus (#39290) * Navigation: try adding dedicated sidebar for managing layout of navigation menus * Fix table width to avoid overflow * Iterate on var naming and code comments * Further naming refinement * More var renaming * Rename panel title for clarity * Improve a11y of component * Revert addition of fixed table layout. Introduces too many visual bugs * Wrap items to avoid off screen movers where possible * Move additional padding * Revert id on ListView This is now handled in #39494 * Use standard getEntityRecords and remove custom entity selector Now moved to #39498 * Add handling for no data or limited data * Collapse all Nav nodes by default * Only show empty message when there are no menus * Guard against editing unpublished Menus * Select Gallery block in list view correctly * Remove rebase artifact * Add empty message in case of empty menu Co-authored-by: Dave Smith <getdavemail@gmail.com>
What?
This PR adds a new
navigationMenus
entity (wp_navigation
) to the list of "known" entities. This enables use of selector "shortcuts" to fetch Navigation Menus.Why?
Spun out of #39290 in order to simplify that PR.
We often want to fetch data about Navigation Menus. To do this we have to write out the full
getEntityRecords()
providing all the correct parameters. This is rather verbose and requires remember all the correct params:Given that
wp_navigation
is now part of WP Core it makes sense to add a shortcut to enable shorthand selectors.With this PR we can now achieve the same result with the following selector:
How?
By adding the new entity to the root entity records
core-data
will generate a selector which will fetch Navigation Menus.Testing Instructions
First verify that Navigatoin Menus are available in the root entity records.
navigationMenu
entry.Now check you can call the shortcut selector to return available Navigation posts.
Also verify you can utilise the singular form of the selector:
Screenshots or screencast