diff --git a/packages/block-library/src/navigation/edit/index.js b/packages/block-library/src/navigation/edit/index.js index 3a4f09ccfd0411..2855bc5e2b9ba7 100644 --- a/packages/block-library/src/navigation/edit/index.js +++ b/packages/block-library/src/navigation/edit/index.js @@ -727,6 +727,7 @@ function Navigation( { onCreateNew={ createUntitledEmptyNavigationMenu } onSelectClassicMenu={ onSelectClassicMenu } onSelectNavigationMenu={ onSelectNavigationMenu } + isLoading={ isLoading } /> { stylingInspectorControls } { __( @@ -842,6 +844,7 @@ function Navigation( { onCreateNew={ createUntitledEmptyNavigationMenu } onSelectClassicMenu={ onSelectClassicMenu } onSelectNavigationMenu={ onSelectNavigationMenu } + isLoading={ isLoading } /> { stylingInspectorControls } { isEntityAvailable && ( diff --git a/packages/block-library/src/navigation/edit/menu-inspector-controls.js b/packages/block-library/src/navigation/edit/menu-inspector-controls.js index 72d011f3a4e757..ff7faddd5822ba 100644 --- a/packages/block-library/src/navigation/edit/menu-inspector-controls.js +++ b/packages/block-library/src/navigation/edit/menu-inspector-controls.js @@ -10,6 +10,7 @@ import { PanelBody, __experimentalHStack as HStack, __experimentalHeading as Heading, + Spinner, } from '@wordpress/components'; import { useSelect } from '@wordpress/data'; import { __ } from '@wordpress/i18n'; @@ -21,25 +22,15 @@ import ManageMenusButton from './manage-menus-button'; import NavigationMenuSelector from './navigation-menu-selector'; import { LeafMoreMenu } from '../leaf-more-menu'; -const MenuInspectorControls = ( { +/* translators: %s: The name of a menu. */ +const actionLabel = __( "Switch to '%s'" ); + +const ExperimentMainContent = ( { clientId, - createNavigationMenuIsSuccess, - createNavigationMenuIsError, - currentMenuId = null, + currentMenuId, + isLoading, isNavigationMenuMissing, - isManageMenusButtonDisabled, - onCreateNew, - onSelectClassicMenu, - onSelectNavigationMenu, } ) => { - const isOffCanvasNavigationEditorEnabled = - window?.__experimentalEnableOffCanvasNavigationEditor === true; - const menuControlsSlot = window?.__experimentalEnableBlockInspectorTabs - ? 'list' - : undefined; - /* translators: %s: The name of a menu. */ - const actionLabel = __( "Switch to '%s'" ); - // Provide a hierarchy of clientIds for the given Navigation block (clientId). // This is required else the list view will display the entire block tree. const clientIdsTree = useSelect( @@ -50,6 +41,94 @@ const MenuInspectorControls = ( { [ clientId ] ); + if ( currentMenuId && isNavigationMenuMissing ) { + return { __( 'Select or create a menu' ) }; + } + + if ( isLoading ) { + return ; + } + + return ( + + ); +}; + +const ExperimentControls = ( props ) => { + const { + createNavigationMenuIsSuccess, + createNavigationMenuIsError, + currentMenuId = null, + onCreateNew, + onSelectClassicMenu, + onSelectNavigationMenu, + } = props; + + return ( + <> + + + { __( 'Menu' ) } + + + + + > + ); +}; + +const DefaultControls = ( props ) => { + const { + createNavigationMenuIsSuccess, + createNavigationMenuIsError, + currentMenuId = null, + isManageMenusButtonDisabled, + onCreateNew, + onSelectClassicMenu, + onSelectNavigationMenu, + } = props; + + return ( + <> + + + > + ); +}; + +const MenuInspectorControls = ( props ) => { + const isOffCanvasNavigationEditorEnabled = + window?.__experimentalEnableOffCanvasNavigationEditor === true; + const menuControlsSlot = window?.__experimentalEnableBlockInspectorTabs + ? 'list' + : undefined; + return ( { isOffCanvasNavigationEditorEnabled ? ( - <> - - - { __( 'Menu' ) } - - - - { currentMenuId && isNavigationMenuMissing ? ( - { __( 'Select or create a menu' ) } - ) : ( - - ) } - > + ) : ( - <> - - - > + ) }
{ __( 'Select or create a menu' ) }