From 7f3488aa0314c8f912c074917a0af24b55b1ed87 Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Tue, 3 May 2022 09:18:43 +0100 Subject: [PATCH] Remove Navigation Area block (#40645) * Remove all references to Navigation Area block * Remove rest init * Remove Nav Area from ts entities * Remove refs to Nav Areas from Core Data tests --- docs/reference-guides/core-blocks.md | 9 - ...rest-block-navigation-areas-controller.php | 285 ------------------ lib/experimental/rest-api.php | 9 - lib/load.php | 3 - packages/block-library/src/index.js | 2 - .../src/navigation-area/block.json | 23 -- .../block-library/src/navigation-area/edit.js | 111 ------- .../src/navigation-area/index.js | 26 -- .../src/navigation-area/index.php | 22 -- .../src/navigation-area/inner-blocks.js | 24 -- .../block-library/src/navigation-area/save.js | 8 - .../block-library/src/navigation/block.json | 1 - .../src/navigation/edit/index.js | 42 +-- packages/core-data/src/entities.ts | 10 - packages/core-data/src/entity-types/index.ts | 3 - .../src/entity-types/navigation-area.ts | 29 -- packages/core-data/src/test/actions.js | 28 +- .../blocks/core__navigation-area.html | 1 - .../blocks/core__navigation-area.json | 10 - .../blocks/core__navigation-area.parsed.json | 11 - .../core__navigation-area.serialized.html | 1 - 21 files changed, 20 insertions(+), 638 deletions(-) delete mode 100644 lib/experimental/class-wp-rest-block-navigation-areas-controller.php delete mode 100644 packages/block-library/src/navigation-area/block.json delete mode 100644 packages/block-library/src/navigation-area/edit.js delete mode 100644 packages/block-library/src/navigation-area/index.js delete mode 100644 packages/block-library/src/navigation-area/index.php delete mode 100644 packages/block-library/src/navigation-area/inner-blocks.js delete mode 100644 packages/block-library/src/navigation-area/save.js delete mode 100644 packages/core-data/src/entity-types/navigation-area.ts delete mode 100644 test/integration/fixtures/blocks/core__navigation-area.html delete mode 100644 test/integration/fixtures/blocks/core__navigation-area.json delete mode 100644 test/integration/fixtures/blocks/core__navigation-area.parsed.json delete mode 100644 test/integration/fixtures/blocks/core__navigation-area.serialized.html diff --git a/docs/reference-guides/core-blocks.md b/docs/reference-guides/core-blocks.md index 5b31b1be281c57..260212e376174a 100644 --- a/docs/reference-guides/core-blocks.md +++ b/docs/reference-guides/core-blocks.md @@ -395,15 +395,6 @@ A collection of blocks that allow visitors to get around your site. ([Source](ht - **Supports:** align (full, wide), anchor, inserter, spacing (blockGap, units), typography (fontSize, lineHeight), ~~html~~ - **Attributes:** __unstableLocation, backgroundColor, customBackgroundColor, customOverlayBackgroundColor, customOverlayTextColor, customTextColor, hasIcon, maxNestingLevel, openSubmenusOnClick, overlayBackgroundColor, overlayMenu, overlayTextColor, ref, rgbBackgroundColor, rgbTextColor, showSubmenuIcon, textColor -## Navigation Area - -Define a navigation area for your theme. The navigation block associated with this area will be automatically displayed. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/navigation-area)) - -- **Name:** core/navigation-area -- **Category:** theme -- **Supports:** ~~html~~, ~~inserter~~ -- **Attributes:** area - ## Custom Link Add a page, link, or another item to your navigation. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/navigation-link)) diff --git a/lib/experimental/class-wp-rest-block-navigation-areas-controller.php b/lib/experimental/class-wp-rest-block-navigation-areas-controller.php deleted file mode 100644 index fef584e04c3cdd..00000000000000 --- a/lib/experimental/class-wp-rest-block-navigation-areas-controller.php +++ /dev/null @@ -1,285 +0,0 @@ -namespace = 'wp/v2'; - $this->rest_base = 'block-navigation-areas'; - } - - /** - * Registers the routes for the objects of the controller. - * - * @see register_rest_route() - */ - public function register_routes() { - register_rest_route( - $this->namespace, - '/' . $this->rest_base, - array( - array( - 'methods' => WP_REST_Server::READABLE, - 'callback' => array( $this, 'get_items' ), - 'permission_callback' => array( $this, 'get_items_permissions_check' ), - 'args' => $this->get_collection_params(), - ), - 'schema' => array( $this, 'get_public_item_schema' ), - ) - ); - - register_rest_route( - $this->namespace, - '/' . $this->rest_base . '/(?P[\w-]+)', - array( - 'args' => array( - 'area' => array( - 'description' => __( 'An alphanumeric identifier for the navigation area.', 'gutenberg' ), - 'type' => 'string', - ), - ), - array( - 'methods' => WP_REST_Server::READABLE, - 'callback' => array( $this, 'get_item' ), - 'permission_callback' => array( $this, 'get_item_permissions_check' ), - 'args' => array( - 'context' => $this->get_context_param( array( 'default' => 'view' ) ), - ), - ), - array( - 'methods' => WP_REST_Server::EDITABLE, - 'callback' => array( $this, 'update_item' ), - 'permission_callback' => array( $this, 'update_item_permissions_check' ), - 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), - ), - 'schema' => array( $this, 'get_public_item_schema' ), - 'allow_batch' => array( 'v1' => true ), - ) - ); - } - - /** - * Checks whether a given request has permission to read navigation areas. - * - * @param WP_REST_Request $request Full details about the request. - * - * @return WP_Error|bool True if the request has read access, WP_Error object otherwise. - */ - public function get_items_permissions_check( $request ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable - if ( ! current_user_can( 'edit_theme_options' ) ) { - return new WP_Error( - 'rest_cannot_view', - __( 'Sorry, you are not allowed to view navigation areas.', 'gutenberg' ), - array( 'status' => rest_authorization_required_code() ) - ); - } - - return true; - } - - /** - * Retrieves all navigation areas, depending on user context. - * - * @param WP_REST_Request $request Full details about the request. - * - * @return WP_Error|WP_REST_Response Response object on success, or WP_Error object on failure. - */ - public function get_items( $request ) { - $data = array(); - foreach ( gutenberg_get_navigation_areas() as $name => $description ) { - $area = $this->get_navigation_area_object( $name ); - $area = $this->prepare_item_for_response( $area, $request ); - $data[ $name ] = $this->prepare_response_for_collection( $area ); - } - return rest_ensure_response( $data ); - } - - /** - * Checks if a given request has access to read a navigation area. - * - * @param WP_REST_Request $request Full details about the request. - * - * @return WP_Error|bool True if the request has read access for the item, WP_Error object otherwise. - */ - public function get_item_permissions_check( $request ) { - if ( ! current_user_can( 'edit_theme_options' ) ) { - return new WP_Error( - 'rest_cannot_view', - __( 'Sorry, you are not allowed to view navigation areas.', 'gutenberg' ), - array( 'status' => rest_authorization_required_code() ) - ); - } - if ( ! array_key_exists( $request['area'], gutenberg_get_navigation_areas() ) ) { - return new WP_Error( 'rest_navigation_area_invalid', __( 'Invalid navigation area.', 'gutenberg' ), array( 'status' => 404 ) ); - } - - return true; - } - - /** - * Checks if a request has access to update the specified term. - * - * @param WP_REST_Request $request Full details about the request. - * - * @return bool|WP_Error True if the request has access to update the item, false or WP_Error object otherwise. - */ - public function update_item_permissions_check( $request ) { - return $this->get_item_permissions_check( $request ); - } - - /** - * Retrieves a specific navigation area. - * - * @param WP_REST_Request $request Full details about the request. - * - * @return WP_Error|WP_REST_Response Response object on success, or WP_Error object on failure. - */ - public function get_item( $request ) { - $name = $request['area']; - $area = $this->get_navigation_area_object( $name ); - $data = $this->prepare_item_for_response( $area, $request ); - - return rest_ensure_response( $data ); - } - - /** - * Updates a specific navigation area. - * - * @param WP_REST_Request $request Full details about the request. - * - * @return WP_Error|WP_REST_Response Response object on success, or WP_Error object on failure. - */ - public function update_item( $request ) { - $name = $request['area']; - - $mapping = gutenberg_get_navigation_areas_menus(); - $mapping[ $name ] = $request['navigation']; - update_option( 'wp_navigation_areas', $mapping ); - - $area = $this->get_navigation_area_object( $name ); - $data = $this->prepare_item_for_response( $area, $request ); - return rest_ensure_response( $data ); - } - - /** - * Converts navigation area name to a convenient object that this endpoint can reason about. - * - * @param string $name Navigation area name. - * @return stdClass An object representation of the navigation area. - */ - private function get_navigation_area_object( $name ) { - $available_areas = gutenberg_get_navigation_areas(); - $mapping = gutenberg_get_navigation_areas_menus(); - $area = new stdClass(); - $area->name = $name; - $area->navigation = ! empty( $mapping[ $name ] ) ? $mapping[ $name ] : null; - $area->description = $available_areas[ $name ]; - return $area; - } - - /** - * Prepares a navigation area object for serialization. - * - * @param stdClass $area Post status data. - * @param WP_REST_Request $request Full details about the request. - * - * @return WP_REST_Response Post status data. - */ - public function prepare_item_for_response( $area, $request ) { - $areas = gutenberg_get_navigation_areas(); - $navigation = ( isset( $areas[ $area->name ] ) ) ? $area->navigation : 0; - - $fields = $this->get_fields_for_response( $request ); - $data = array(); - - if ( rest_is_field_included( 'name', $fields ) ) { - $data['name'] = $area->name; - } - - if ( rest_is_field_included( 'description', $fields ) ) { - $data['description'] = $area->description; - } - - if ( rest_is_field_included( 'navigation', $fields ) ) { - $data['navigation'] = (int) $navigation; - } - - $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; - $data = $this->add_additional_fields_to_object( $data, $request ); - $data = $this->filter_response_by_context( $data, $context ); - - $response = rest_ensure_response( $data ); - - /** - * Filters a navigation area returned from the REST API. - * - * Allows modification of the navigation area data right before it is - * returned. - * - * @param WP_REST_Response $response The response object. - * @param object $area The original status object. - * @param WP_REST_Request $request Request used to generate the response. - */ - return apply_filters( 'rest_prepare_navigation_area', $response, $area, $request ); - } - - /** - * Retrieves the navigation area's schema, conforming to JSON Schema. - * - * @return array Item schema data. - */ - public function get_item_schema() { - $schema = array( - '$schema' => 'http://json-schema.org/draft-04/schema#', - 'title' => 'navigation-area', - 'type' => 'object', - 'properties' => array( - 'name' => array( - 'description' => __( 'The name of the navigation area.', 'gutenberg' ), - 'type' => 'string', - 'context' => array( 'embed', 'view', 'edit' ), - 'readonly' => true, - ), - 'description' => array( - 'description' => __( 'The description of the navigation area.', 'gutenberg' ), - 'type' => 'string', - 'context' => array( 'embed', 'view', 'edit' ), - 'readonly' => true, - ), - 'navigation' => array( - 'description' => __( 'The ID of the assigned navigation.', 'gutenberg' ), - 'type' => 'integer', - 'context' => array( 'embed', 'view', 'edit' ), - 'readonly' => true, - ), - ), - ); - - return $this->add_additional_fields_schema( $schema ); - } - - /** - * Retrieves the query params for collections. - * - * @return array Collection parameters. - */ - public function get_collection_params() { - return array( - 'context' => $this->get_context_param( array( 'default' => 'view' ) ), - ); - } - -} diff --git a/lib/experimental/rest-api.php b/lib/experimental/rest-api.php index fc242a2f91a079..8ab4b1ad509fe7 100644 --- a/lib/experimental/rest-api.php +++ b/lib/experimental/rest-api.php @@ -10,15 +10,6 @@ die( 'Silence is golden.' ); } -/** - * Registers the navigation areas REST API routes. - */ -function gutenberg_register_rest_navigation_areas() { - $navigation_areas = new WP_REST_Block_Navigation_Areas_Controller(); - $navigation_areas->register_routes(); -} -add_action( 'rest_api_init', 'gutenberg_register_rest_navigation_areas' ); - /** * Registers the customizer nonces REST API routes. */ diff --git a/lib/load.php b/lib/load.php index 4c503c5ebf6b3c..2aad01171461f3 100644 --- a/lib/load.php +++ b/lib/load.php @@ -68,9 +68,6 @@ function gutenberg_is_experiment_enabled( $name ) { if ( ! class_exists( 'WP_Rest_Customizer_Nonces' ) ) { require_once __DIR__ . '/experimental/class-wp-rest-customizer-nonces.php'; } - if ( ! class_exists( 'WP_REST_Block_Navigation_Areas_Controller' ) ) { - require_once __DIR__ . '/experimental/class-wp-rest-block-navigation-areas-controller.php'; - } require_once __DIR__ . '/experimental/rest-api.php'; } diff --git a/packages/block-library/src/index.js b/packages/block-library/src/index.js index fb033052907e3d..4db6f860b6cd3d 100644 --- a/packages/block-library/src/index.js +++ b/packages/block-library/src/index.js @@ -54,7 +54,6 @@ import * as mediaText from './media-text'; import * as missing from './missing'; import * as more from './more'; import * as navigation from './navigation'; -import * as navigationArea from './navigation-area'; import * as navigationLink from './navigation-link'; import * as navigationSubmenu from './navigation-submenu'; import * as nextpage from './nextpage'; @@ -279,7 +278,6 @@ export const __experimentalRegisterExperimentalCoreBlocks = process.env ...( enableFSEBlocks ? [ commentAuthorAvatar, - navigationArea, postComment, postCommentsCount, postCommentsLink, diff --git a/packages/block-library/src/navigation-area/block.json b/packages/block-library/src/navigation-area/block.json deleted file mode 100644 index 07a6188efa1379..00000000000000 --- a/packages/block-library/src/navigation-area/block.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "$schema": "https://schemas.wp.org/trunk/block.json", - "apiVersion": 2, - "name": "core/navigation-area", - "title": "Navigation Area", - "category": "theme", - "description": "Define a navigation area for your theme. The navigation block associated with this area will be automatically displayed.", - "keywords": [ "menu", "navigation", "links", "location" ], - "textdomain": "default", - "attributes": { - "area": { - "type": "string", - "default": "primary" - } - }, - "providesContext": { - "navigationArea": "area" - }, - "supports": { - "html": false, - "inserter": false - } -} diff --git a/packages/block-library/src/navigation-area/edit.js b/packages/block-library/src/navigation-area/edit.js deleted file mode 100644 index ffee78ad8c982c..00000000000000 --- a/packages/block-library/src/navigation-area/edit.js +++ /dev/null @@ -1,111 +0,0 @@ -/** - * WordPress dependencies - */ -import { __, _x } from '@wordpress/i18n'; -import deprecated from '@wordpress/deprecated'; -import { store as coreStore } from '@wordpress/core-data'; -import { - MenuGroup, - MenuItemsChoice, - PanelBody, - SelectControl, - ToolbarDropdownMenu, - ToolbarGroup, -} from '@wordpress/components'; -import { useMemo } from '@wordpress/element'; -import { BlockControls, InspectorControls } from '@wordpress/block-editor'; -import { useSelect } from '@wordpress/data'; - -/** - * Internal dependencies - */ -import InnerBlocks from './inner-blocks'; -import PlaceholderPreview from '../navigation/edit/placeholder/placeholder-preview'; - -function NavigationAreaBlock( { attributes, setAttributes } ) { - const { area } = attributes; - - const { navigationAreas, hasResolvedNavigationAreas } = useSelect( - ( select ) => { - const { getEntityRecords, hasFinishedResolution } = select( - coreStore - ); - return { - navigationAreas: getEntityRecords( 'root', 'navigationArea' ), - hasResolvedNavigationAreas: hasFinishedResolution( - 'getEntityRecords', - [ 'root', 'navigationArea' ] - ), - }; - } - ); - const navigationMenuId = navigationAreas?.length - ? navigationAreas[ area ] - : undefined; - - const choices = useMemo( - () => - navigationAreas?.map( ( { name, description } ) => ( { - label: description, - value: name, - } ) ), - [ navigationAreas ] - ); - - deprecated( 'wp.blockLibrary.NavigationArea', { - since: '12.0', - plugin: 'gutenberg', - } ); - - return ( - <> - - - - { ( { onClose } ) => ( - - { - setAttributes( { area: selectedArea } ); - onClose(); - } } - choices={ choices } - /> - - ) } - - - - - - - setAttributes( { - area: value, - } ) - } - options={ choices } - /> - - - { ! hasResolvedNavigationAreas && } - { - // Render inner blocks only when navigationMenuId is known so - // that inner blocks template is correct from the start. - hasResolvedNavigationAreas && ( - - ) - } - - ); -} - -export default NavigationAreaBlock; diff --git a/packages/block-library/src/navigation-area/index.js b/packages/block-library/src/navigation-area/index.js deleted file mode 100644 index c848d3d7c06129..00000000000000 --- a/packages/block-library/src/navigation-area/index.js +++ /dev/null @@ -1,26 +0,0 @@ -/** - * WordPress dependencies - */ -import { symbolFilled as icon } from '@wordpress/icons'; - -/** - * Internal dependencies - */ -import edit from './edit'; -import metadata from './block.json'; -import save from './save'; - -const { name } = metadata; - -export { metadata, name }; - -export const settings = { - icon, - example: { - attributes: { - area: 'primary', - }, - }, - edit, - save, -}; diff --git a/packages/block-library/src/navigation-area/index.php b/packages/block-library/src/navigation-area/index.php deleted file mode 100644 index 65c64428d0c2e2..00000000000000 --- a/packages/block-library/src/navigation-area/index.php +++ /dev/null @@ -1,22 +0,0 @@ - array( - 'navigationArea' => 'area', - ), - ) - ); -} -add_action( 'init', 'register_block_core_navigation_area' ); diff --git a/packages/block-library/src/navigation-area/inner-blocks.js b/packages/block-library/src/navigation-area/inner-blocks.js deleted file mode 100644 index d123b93f9ed39d..00000000000000 --- a/packages/block-library/src/navigation-area/inner-blocks.js +++ /dev/null @@ -1,24 +0,0 @@ -/** - * WordPress dependencies - */ -import { useMemo } from '@wordpress/element'; -import { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor'; - -const ALLOWED_BLOCKS = [ 'core/navigation' ]; - -export default function NavigationAreaInnerBlocks( { navigationMenuId } ) { - const template = useMemo( - () => [ [ 'core/navigation', { navigationMenuId } ] ], - [ navigationMenuId ] - ); - - const blockProps = useBlockProps(); - const innerBlocksProps = useInnerBlocksProps( blockProps, { - orientation: 'horizontal', - renderAppender: false, - template, - templateLock: 'all', - allowedBlocks: ALLOWED_BLOCKS, - } ); - return
; -} diff --git a/packages/block-library/src/navigation-area/save.js b/packages/block-library/src/navigation-area/save.js deleted file mode 100644 index 17571d8f30d2de..00000000000000 --- a/packages/block-library/src/navigation-area/save.js +++ /dev/null @@ -1,8 +0,0 @@ -/** - * WordPress dependencies - */ -import { InnerBlocks } from '@wordpress/block-editor'; - -export default function save() { - return ; -} diff --git a/packages/block-library/src/navigation/block.json b/packages/block-library/src/navigation/block.json index cb930d0a8fb45d..954d7577558acc 100644 --- a/packages/block-library/src/navigation/block.json +++ b/packages/block-library/src/navigation/block.json @@ -65,7 +65,6 @@ "default": 5 } }, - "usesContext": [ "navigationArea" ], "providesContext": { "textColor": "textColor", "customTextColor": "customTextColor", diff --git a/packages/block-library/src/navigation/edit/index.js b/packages/block-library/src/navigation/edit/index.js index 8040565fad771c..65ff0d13cac0d1 100644 --- a/packages/block-library/src/navigation/edit/index.js +++ b/packages/block-library/src/navigation/edit/index.js @@ -2,7 +2,6 @@ * External dependencies */ import classnames from 'classnames'; -import { noop } from 'lodash'; /** * WordPress dependencies @@ -26,7 +25,7 @@ import { getColorClassName, Warning, } from '@wordpress/block-editor'; -import { EntityProvider, useEntityProp } from '@wordpress/core-data'; +import { EntityProvider } from '@wordpress/core-data'; import { useDispatch, useSelect, useRegistry } from '@wordpress/data'; import { @@ -109,7 +108,6 @@ function Navigation( { setOverlayBackgroundColor, overlayTextColor, setOverlayTextColor, - context: { navigationArea }, // These props are used by the navigation editor to override specific // navigation block settings. @@ -129,34 +127,12 @@ function Navigation( { hasIcon, } = attributes; - let areaMenu, - setAreaMenu = noop; - // Navigation areas are deprecated and on their way out. Let's not perform - // the request unless we're in an environment where the endpoint exists. - if ( process.env.IS_GUTENBERG_PLUGIN ) { - // eslint-disable-next-line react-hooks/rules-of-hooks - [ areaMenu, setAreaMenu ] = useEntityProp( - 'root', - 'navigationArea', - 'navigation', - navigationArea - ); - } - - const navigationAreaMenu = areaMenu === 0 ? undefined : areaMenu; - - const ref = navigationArea ? navigationAreaMenu : attributes.ref; + const ref = attributes.ref; const registry = useRegistry(); - const setRef = useCallback( - ( postId ) => { - setAttributes( { ref: postId } ); - if ( navigationArea ) { - setAreaMenu( postId ); - } - }, - [ navigationArea ] - ); + const setRef = ( postId ) => { + setAttributes( { ref: postId } ); + }; const [ hasAlreadyRendered, RecursionProvider ] = useNoRecursiveRenders( `navigationMenu/${ ref }` @@ -261,8 +237,6 @@ function Navigation( { setHasSavedUnsavedInnerBlocks, ] = useState( false ); - const isWithinUnassignedArea = !! navigationArea && ! ref; - const [ isResponsiveMenuOpen, setResponsiveMenuVisibility ] = useState( false ); @@ -322,13 +296,12 @@ function Navigation( { // - there is no classic menu conversion process in progress. // - there is no menu creation process in progress. // - there are no uncontrolled blocks. - // - (legacy) there is a Navigation Area without a ref attribute pointing to a Navigation Post. const isPlaceholder = ! ref && ! isCreatingNavigationMenu && ! isConvertingClassicMenu && hasResolvedNavigationMenus && - ( ! hasUncontrolledInnerBlocks || isWithinUnassignedArea ); + ! hasUncontrolledInnerBlocks; const isEntityAvailable = ! isNavigationMenuMissing && isNavigationMenuResolved; @@ -567,9 +540,6 @@ function Navigation( { const resetToEmptyBlock = useCallback( () => { registry.batch( () => { - if ( navigationArea ) { - setAreaMenu( 0 ); - } setAttributes( { ref: undefined, } ); diff --git a/packages/core-data/src/entities.ts b/packages/core-data/src/entities.ts index b45362be78f815..1f08c8ec6f6c4a 100644 --- a/packages/core-data/src/entities.ts +++ b/packages/core-data/src/entities.ts @@ -143,16 +143,6 @@ export const rootEntitiesConfig = [ label: __( 'Menu Location' ), key: 'name', }, - { - name: 'navigationArea', - kind: 'root', - baseURL: '/wp/v2/block-navigation-areas', - baseURLParams: { context: 'edit' }, - plural: 'navigationAreas', - label: __( 'Navigation Area' ), - key: 'name', - getTitle: ( record ) => record?.description, - }, { label: __( 'Global Styles' ), name: 'globalStyles', diff --git a/packages/core-data/src/entity-types/index.ts b/packages/core-data/src/entity-types/index.ts index f96b686ad03ee8..f302cab40ee5e9 100644 --- a/packages/core-data/src/entity-types/index.ts +++ b/packages/core-data/src/entity-types/index.ts @@ -7,7 +7,6 @@ import type { Comment } from './comment'; import type { MenuLocation } from './menu-location'; import type { NavMenu } from './nav-menu'; import type { NavMenuItem } from './nav-menu-item'; -import type { NavigationArea } from './navigation-area'; import type { Page } from './page'; import type { Plugin } from './plugin'; import type { Post } from './post'; @@ -31,7 +30,6 @@ export type { MenuLocation, NavMenu, NavMenuItem, - NavigationArea, Page, Plugin, Post, @@ -54,7 +52,6 @@ export type EntityRecord< C extends Context > = | MenuLocation< C > | NavMenu< C > | NavMenuItem< C > - | NavigationArea< C > | Page< C > | Plugin< C > | Post< C > diff --git a/packages/core-data/src/entity-types/navigation-area.ts b/packages/core-data/src/entity-types/navigation-area.ts deleted file mode 100644 index 06250433f46387..00000000000000 --- a/packages/core-data/src/entity-types/navigation-area.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Internal dependencies - */ -import type { Context, OmitNevers } from './helpers'; - -import type { BaseEntityRecords as _BaseEntityRecords } from './base-entity-records'; - -declare module './base-entity-records' { - export namespace BaseEntityRecords { - export interface NavigationArea< C extends Context > { - /** - * The name of the navigation area. - */ - name: string; - /** - * The description of the navigation area. - */ - description: string; - /** - * The ID of the assigned navigation. - */ - navigation: number; - } - } -} - -export type NavigationArea< C extends Context > = OmitNevers< - _BaseEntityRecords.NavigationArea< C > ->; diff --git a/packages/core-data/src/test/actions.js b/packages/core-data/src/test/actions.js index 125cb9da1128c1..8700ef7af78d66 100644 --- a/packages/core-data/src/test/actions.js +++ b/packages/core-data/src/test/actions.js @@ -191,12 +191,12 @@ describe( 'saveEditedEntityRecord', () => { } ); it( 'Uses "id" as a key when no entity key is provided', async () => { - const area = { id: 1, menu: 0 }; + const item = { id: 1, menu: 0 }; const configs = [ { kind: 'root', - name: 'navigationArea', - baseURL: '/wp/v2/block-navigation-areas', + name: 'menuItem', + baseURL: '/wp/v2/menu-items', }, ]; const select = { @@ -211,33 +211,33 @@ describe( 'saveEditedEntityRecord', () => { dispatch.mockReturnValueOnce( configs ); // Provide response - const updatedRecord = { ...area, menu: 10 }; + const updatedRecord = { ...item, menu: 10 }; apiFetch.mockImplementation( () => { return updatedRecord; } ); await saveEditedEntityRecord( 'root', - 'navigationArea', + 'menuItem', 1 )( { dispatch, select } ); expect( dispatch.saveEntityRecord ).toHaveBeenCalledWith( 'root', - 'navigationArea', + 'menuItem', { id: 1 }, undefined ); } ); it( 'Uses the entity key when provided', async () => { - const area = { area: 'primary', menu: 0 }; + const item = { name: 'primary', menu: 0 }; const configs = [ { kind: 'root', - name: 'navigationArea', - baseURL: '/wp/v2/block-navigation-areas', - key: 'area', + name: 'menuLocation', + baseURL: '/wp/v2/menu-items', + key: 'name', }, ]; const select = { @@ -252,21 +252,21 @@ describe( 'saveEditedEntityRecord', () => { dispatch.mockReturnValueOnce( configs ); // Provide response - const updatedRecord = { ...area, menu: 10 }; + const updatedRecord = { ...item, menu: 10 }; apiFetch.mockImplementation( () => { return updatedRecord; } ); await saveEditedEntityRecord( 'root', - 'navigationArea', + 'menuLocation', 'primary' )( { dispatch, select } ); expect( dispatch.saveEntityRecord ).toHaveBeenCalledWith( 'root', - 'navigationArea', - { area: 'primary' }, + 'menuLocation', + { name: 'primary' }, undefined ); } ); diff --git a/test/integration/fixtures/blocks/core__navigation-area.html b/test/integration/fixtures/blocks/core__navigation-area.html deleted file mode 100644 index 34145ae3ebe319..00000000000000 --- a/test/integration/fixtures/blocks/core__navigation-area.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/test/integration/fixtures/blocks/core__navigation-area.json b/test/integration/fixtures/blocks/core__navigation-area.json deleted file mode 100644 index ca3faf0de6e838..00000000000000 --- a/test/integration/fixtures/blocks/core__navigation-area.json +++ /dev/null @@ -1,10 +0,0 @@ -[ - { - "name": "core/navigation-area", - "isValid": true, - "attributes": { - "area": "secondary" - }, - "innerBlocks": [] - } -] diff --git a/test/integration/fixtures/blocks/core__navigation-area.parsed.json b/test/integration/fixtures/blocks/core__navigation-area.parsed.json deleted file mode 100644 index a5882f26b157ba..00000000000000 --- a/test/integration/fixtures/blocks/core__navigation-area.parsed.json +++ /dev/null @@ -1,11 +0,0 @@ -[ - { - "blockName": "core/navigation-area", - "attrs": { - "area": "secondary" - }, - "innerBlocks": [], - "innerHTML": "", - "innerContent": [] - } -] diff --git a/test/integration/fixtures/blocks/core__navigation-area.serialized.html b/test/integration/fixtures/blocks/core__navigation-area.serialized.html deleted file mode 100644 index 34145ae3ebe319..00000000000000 --- a/test/integration/fixtures/blocks/core__navigation-area.serialized.html +++ /dev/null @@ -1 +0,0 @@ -