Skip to content

Commit

Permalink
Navigation in Site View: Readd the edit button
Browse files Browse the repository at this point in the history
  • Loading branch information
scruffian committed Jun 29, 2023
1 parent 55c18fc commit c9749a2
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 @@ -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,
Expand All @@ -22,12 +23,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={ buildNavigationLabel(
navigationMenu?.title,
Expand Down

0 comments on commit c9749a2

Please sign in to comment.