Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix importing classic menus #52573

Merged
merged 2 commits into from
Jul 13, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
use the same create hook for classic import
  • Loading branch information
draganescu committed Jul 12, 2023
commit 12ea114e0c24092011ab26d2158facbae1a8a193
2 changes: 1 addition & 1 deletion packages/block-library/src/navigation/edit/index.js
Original file line number Diff line number Diff line change
@@ -197,7 +197,7 @@ function Navigation( {
convert: convertClassicMenu,
status: classicMenuConversionStatus,
error: classicMenuConversionError,
} = useConvertClassicToBlockMenu( clientId );
} = useConvertClassicToBlockMenu( clientId, createNavigationMenu );

const isConvertingClassicMenu =
classicMenuConversionStatus === CLASSIC_MENU_CONVERSION_PENDING;
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@ import { __, sprintf } from '@wordpress/i18n';
/**
* Internal dependencies
*/
import useCreateNavigationMenu from './use-create-navigation-menu';
import menuItemsToBlocks from '../menu-items-to-blocks';

export const CLASSIC_MENU_CONVERSION_SUCCESS = 'success';
@@ -21,15 +20,7 @@ export const CLASSIC_MENU_CONVERSION_IDLE = 'idle';
// do not import the same classic menu twice.
let classicMenuBeingConvertedId = null;

function useConvertClassicToBlockMenu( clientId ) {
/*
* The wp_navigation post is created as a draft so the changes on the frontend and
* the site editor are not permanent without a save interaction done by the user.
*/
const { create: createNavigationMenu } = useCreateNavigationMenu(
clientId,
'draft'
);
function useConvertClassicToBlockMenu( clientId, createNavigationMenu ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

clientId is now unused?

Suggested change
function useConvertClassicToBlockMenu( clientId, createNavigationMenu ) {
function useConvertClassicToBlockMenu( createNavigationMenu ) {

You'd need to amend all calls to the hook.

Copy link
Contributor

Choose a reason for hiding this comment

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

I've gone ahead and actioned this for you.

const registry = useRegistry();
const { editEntityRecord } = useDispatch( coreStore );