Skip to content
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

Merged
merged 2 commits into from
Mar 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions packages/core-data/src/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ export const rootEntitiesConfig = [
label: __( 'Comment' ),
},
{
name: 'menu',
name: 'menu', // Classic Menus
kind: 'root',
baseURL: '/wp/v2/menus',
baseURLParams: { context: 'edit' },
plural: 'menus',
label: __( 'Menu' ),
},
{
name: 'menuItem',
name: 'menuItem', // Classic Menu Items
kind: 'root',
baseURL: '/wp/v2/menu-items',
baseURLParams: { context: 'edit' },
Expand All @@ -132,7 +132,7 @@ export const rootEntitiesConfig = [
rawAttributes: [ 'title', 'content' ],
},
{
name: 'menuLocation',
name: 'menuLocation', // Classic Menu Locations
kind: 'root',
baseURL: '/wp/v2/menu-locations',
baseURLParams: { context: 'edit' },
Expand All @@ -141,7 +141,7 @@ export const rootEntitiesConfig = [
key: 'name',
},
{
name: 'navigationArea',
name: 'navigationArea', // Deprecated - can be removed once the concepts of Navigation Areas is removed from the codebase.
kind: 'root',
baseURL: '/wp/v2/block-navigation-areas',
baseURLParams: { context: 'edit' },
Expand Down Expand Up @@ -175,6 +175,14 @@ export const rootEntitiesConfig = [
baseURLParams: { context: 'edit' },
key: 'plugin',
},
{
label: __( 'Navigation' ), // Block based Navigation Menus
Copy link
Contributor

@adamziel adamziel Mar 16, 2022

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?

Copy link
Contributor Author

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')

Copy link
Contributor Author

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')

Copy link
Contributor

@adamziel adamziel Mar 17, 2022

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?

name: 'navigationMenu',
kind: 'root',
baseURL: '/wp/v2/navigation',
baseURLParams: { context: 'edit' },
plural: 'navigationMenus',
},
];

export const additionalEntityConfigLoaders = [
Expand Down