diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-main/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-main/index.js index 9df2e22b111d3..5c89c9f72a23b 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-main/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-main/index.js @@ -20,7 +20,6 @@ import SidebarNavigationItem from '../sidebar-navigation-item'; import { SidebarNavigationItemGlobalStyles } from '../sidebar-navigation-screen-global-styles'; import { unlock } from '../../lock-unlock'; import { store as editSiteStore } from '../../store'; -import SidebarNavigationScreenNavigationMenuButton from '../sidebar-navigation-screen-navigation-menus/navigator-button'; export default function SidebarNavigationScreenMain() { const { location } = useNavigator(); @@ -44,14 +43,14 @@ export default function SidebarNavigationScreenMain() { ) } content={ - { __( 'Navigation' ) } - - + - - - - } - title={ decodeEntities( menuTitle ) } - description={ - <> -

- { sprintf( - /* translators: %s: Navigation menu title */ - 'This is your "%s" navigation menu. ', - decodeEntities( menuTitle ) - ) } -

-

- { __( - 'You can edit this menu here, but be aware that visual styles might be applied separately in templates or template parts, so the preview shown here can be incomplete.' - ) } -

- - } - > - - + ); } diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js b/packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js new file mode 100644 index 0000000000000..6351c83323f98 --- /dev/null +++ b/packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js @@ -0,0 +1,39 @@ +/** + * WordPress dependencies + */ +import { __ } from '@wordpress/i18n'; +import { decodeEntities } from '@wordpress/html-entities'; +/** + * Internal dependencies + */ +import { SidebarNavigationScreenWrapper } from '../sidebar-navigation-screen-navigation-menus'; +import ScreenNavigationMoreMenu from './more-menu'; +import NavigationMenuEditor from './navigation-menu-editor'; + +export default function SingleNavigationMenu( { + navigationMenu, + handleDelete, + handleDuplicate, + handleSave, +} ) { + const menuTitle = navigationMenu?.title?.rendered; + + return ( + + } + title={ decodeEntities( menuTitle ) } + description={ __( + 'Navigation menus are a curated collection of blocks that allow visitors to get around your site.' + ) } + > + + + ); +} diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-navigation-menus/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-navigation-menus/index.js index 5706ff17bc038..8d3edad0de8d2 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-navigation-menus/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-navigation-menus/index.js @@ -18,6 +18,7 @@ import SidebarNavigationScreen from '../sidebar-navigation-screen'; import SidebarNavigationItem from '../sidebar-navigation-item'; import { PRELOADED_NAVIGATION_MENUS_QUERY } from './constants'; import { useLink } from '../routes/link'; +import NavigationMenuEditor from '../sidebar-navigation-screen-navigation-menu/navigation-menu-editor'; export default function SidebarNavigationScreenNavigationMenus() { const { records: navigationMenus, isResolving: isLoading } = @@ -45,6 +46,17 @@ export default function SidebarNavigationScreenNavigationMenus() { ); } + // if single menu then render it + if ( navigationMenus?.length === 1 ) { + return ( + + + + ); + } + return ( diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-navigation-menus/navigator-button.js b/packages/edit-site/src/components/sidebar-navigation-screen-navigation-menus/navigator-button.js deleted file mode 100644 index 7e75c544a0f16..0000000000000 --- a/packages/edit-site/src/components/sidebar-navigation-screen-navigation-menus/navigator-button.js +++ /dev/null @@ -1,47 +0,0 @@ -/** - * WordPress dependencies - */ - -import { __experimentalNavigatorButton as NavigatorButton } from '@wordpress/components'; -import { useEntityRecords } from '@wordpress/core-data'; - -/** - * Internal dependencies - */ -import { PRELOADED_NAVIGATION_MENUS_QUERY } from './constants'; - -export default function SidebarNavigationScreenNavigationMenuButton( { - children, - ...props -} ) { - const { records: navigationMenus, isResolving: isLoading } = - useEntityRecords( - 'postType', - `wp_navigation`, - PRELOADED_NAVIGATION_MENUS_QUERY - ); - - const hasNavigationMenus = !! navigationMenus?.length; - const hasSingleNavigationMenu = navigationMenus?.length === 1; - const firstNavigationMenu = navigationMenus?.[ 0 ]; - - const showNavigationScreen = process.env.IS_GUTENBERG_PLUGIN - ? hasNavigationMenus - : false; - - // If there is a single menu then we can go directly to that menu. - // Otherwise we go to the navigation listing screen. - const path = hasSingleNavigationMenu - ? `/navigation/wp_navigation/${ firstNavigationMenu?.id }` - : '/navigation'; - - if ( ! showNavigationScreen ) { - return null; - } - - return ( - - { children } - - ); -}