Skip to content

Commit

Permalink
Navigation in Site View: Readd the edit button (#52111)
Browse files Browse the repository at this point in the history
  • Loading branch information
scruffian authored and tellthemachines committed Jul 7, 2023
1 parent 150b10c commit 1f60798
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<SidebarButton
onClick={ () => setCanvasMode( 'edit' ) }
label={ __( 'Edit' ) }
icon={ pencil }
/>
<SidebarButton { ...linkInfo } label={ __( 'Edit' ) } icon={ pencil } />
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { decodeEntities } from '@wordpress/html-entities';
import { SidebarNavigationScreenWrapper } from '../sidebar-navigation-screen-navigation-menus';
import ScreenNavigationMoreMenu from './more-menu';
import NavigationMenuEditor from './navigation-menu-editor';
import EditButton from './edit-button';

export default function SingleNavigationMenu( {
navigationMenu,
Expand All @@ -21,12 +22,15 @@ export default function SingleNavigationMenu( {
return (
<SidebarNavigationScreenWrapper
actions={
<ScreenNavigationMoreMenu
menuTitle={ decodeEntities( menuTitle ) }
onDelete={ handleDelete }
onSave={ handleSave }
onDuplicate={ handleDuplicate }
/>
<>
<EditButton postId={ navigationMenu?.id } />
<ScreenNavigationMoreMenu
menuTitle={ decodeEntities( menuTitle ) }
onDelete={ handleDelete }
onSave={ handleSave }
onDuplicate={ handleDuplicate }
/>
</>
}
title={ decodeEntities( menuTitle ) }
description={ __(
Expand Down

0 comments on commit 1f60798

Please sign in to comment.