From d5d64f37688c403e060ce476948e271eaf5d25dc Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Fri, 30 Jun 2023 21:07:58 +0100 Subject: [PATCH] Navigation in Site View: Readd the edit button (#52111) --- .../edit-button.js | 19 ++++++++----------- .../single-navigation-menu.js | 16 ++++++++++------ 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/edit-button.js b/packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/edit-button.js index 7d084b6db4e260..391017796b5e64 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/edit-button.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/edit-button.js @@ -2,23 +2,20 @@ * WordPress dependencies */ import { __ } from '@wordpress/i18n'; -import { useDispatch } from '@wordpress/data'; import { pencil } from '@wordpress/icons'; /** * Internal dependencies */ -import { store as editSiteStore } from '../../store'; import SidebarButton from '../sidebar-button'; -import { unlock } from '../../lock-unlock'; - -export default function EditButton() { - const { setCanvasMode } = unlock( useDispatch( editSiteStore ) ); +import { useLink } from '../routes/link'; +export default function EditButton( { postId } ) { + const linkInfo = useLink( { + postId, + postType: 'wp_navigation', + canvas: 'edit', + } ); return ( - setCanvasMode( 'edit' ) } - label={ __( 'Edit' ) } - icon={ pencil } - /> + ); } diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js b/packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js index d988308b167135..d985ac0e60fc4e 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js @@ -10,6 +10,7 @@ import { SidebarNavigationScreenWrapper } from '../sidebar-navigation-screen-nav import ScreenNavigationMoreMenu from './more-menu'; import NavigationMenuEditor from './navigation-menu-editor'; import buildNavigationLabel from '../sidebar-navigation-screen-navigation-menus/build-navigation-label'; +import EditButton from './edit-button'; export default function SingleNavigationMenu( { navigationMenu, @@ -22,12 +23,15 @@ export default function SingleNavigationMenu( { return ( + <> + + + } title={ buildNavigationLabel( navigationMenu?.title,