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 Jun 30, 2023
1 parent 6915ce8 commit d5d64f3
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

1 comment on commit d5d64f3

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in d5d64f3.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5426607135
📝 Reported issues:

Please sign in to comment.