From 6100ac34b2a0b2e6f5c555acb7d9d7efbc57f45a Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Wed, 16 Nov 2022 16:40:10 +0000 Subject: [PATCH] Navigation: Reduce duplicate code (#45779) --- .../src/navigation/edit/index.js | 160 +++++------------- 1 file changed, 47 insertions(+), 113 deletions(-) diff --git a/packages/block-library/src/navigation/edit/index.js b/packages/block-library/src/navigation/edit/index.js index e15619a2cc74d..6cf5eea22e0a0 100644 --- a/packages/block-library/src/navigation/edit/index.js +++ b/packages/block-library/src/navigation/edit/index.js @@ -693,48 +693,54 @@ function Navigation( { const isManageMenusButtonDisabled = ! hasManagePermissions || ! hasResolvedNavigationMenus; + const MenuInspectorControls = ( { currentMenuId = null } ) => ( + + + { isOffCanvasNavigationEditorEnabled ? ( + <> + + + { __( 'Menu' ) } + + + + { currentMenuId && isNavigationMenuMissing ? ( +

{ __( 'Select or create a menu' ) }

+ ) : ( + + ) } + + ) : ( + <> + + + + ) } +
+
+ ); + if ( hasUnsavedBlocks && ! isCreatingNavigationMenu ) { return ( - - - { isOffCanvasNavigationEditorEnabled ? ( - <> - - - { __( 'Menu' ) } - - - - - - ) : ( - <> - - - - ) } - - + { stylingInspectorControls } - - - { isOffCanvasNavigationEditorEnabled ? ( - <> - - - { __( 'Menu' ) } - - - -

Select or create a menu

- - ) : ( - <> - - - - ) } -
-
+ { __( 'Navigation menu has been deleted or is unavailable. ' @@ -873,45 +845,7 @@ function Navigation( { return ( - - - { isOffCanvasNavigationEditorEnabled ? ( - <> - - - { __( 'Menu' ) } - - - - - - ) : ( - <> - - - - ) } - - + { stylingInspectorControls } { isEntityAvailable && (