diff --git a/packages/edit-site/src/components/layout/router.js b/packages/edit-site/src/components/layout/router.js index fc19ca9242eace..20d5b463852ff3 100644 --- a/packages/edit-site/src/components/layout/router.js +++ b/packages/edit-site/src/components/layout/router.js @@ -31,7 +31,7 @@ export default function useLayoutAreas() { const isSiteEditorLoading = useIsSiteEditorLoading(); const history = useHistory(); const { params } = useLocation(); - const { postType, postId, path, layout, isCustom, canvas } = params ?? {}; + const { postType, postId, path, layout, isCustom, canvas } = params; // Note: Since "sidebar" is not yet supported here, // returning undefined from "mobile" means show the sidebar. @@ -45,6 +45,7 @@ export default function useLayoutAreas() { sidebar: ( } /> ), @@ -78,13 +79,33 @@ export default function useLayoutAreas() { if ( postType && postId ) { let sidebar; if ( postType === 'wp_template_part' || postType === 'wp_block' ) { - sidebar = ; + sidebar = ( + + ); } else if ( postType === 'wp_template' ) { - sidebar = ; + sidebar = ( + + ); } else if ( postType === 'page' ) { - sidebar = ; + sidebar = ( + + ); } else { - sidebar = ; + sidebar = ( + + ); } return { key: 'page', @@ -104,7 +125,9 @@ export default function useLayoutAreas() { return { key: 'templates-list', areas: { - sidebar: , + sidebar: ( + + ), content: , preview: isListLayout && ( @@ -125,7 +148,7 @@ export default function useLayoutAreas() { return { key: 'patterns', areas: { - sidebar: , + sidebar: , content: , mobile: , }, @@ -137,7 +160,9 @@ export default function useLayoutAreas() { return { key: 'styles', areas: { - sidebar: , + sidebar: ( + + ), preview: , mobile: canvas === 'edit' && ( @@ -152,7 +177,11 @@ export default function useLayoutAreas() { return { key: 'navigation', areas: { - sidebar: , + sidebar: ( + + ), preview: , mobile: canvas === 'edit' && ( @@ -163,7 +192,9 @@ export default function useLayoutAreas() { return { key: 'navigation', areas: { - sidebar: , + sidebar: ( + + ), preview: , mobile: canvas === 'edit' && ( diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-global-styles/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-global-styles/index.js index f0585b410e40dc..87a7b6d9d15f27 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-global-styles/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-global-styles/index.js @@ -103,7 +103,7 @@ function SidebarNavigationScreenGlobalStylesContent() { ); } -export default function SidebarNavigationScreenGlobalStyles() { +export default function SidebarNavigationScreenGlobalStyles( { backPath } ) { const { revisions, isLoading: isLoadingRevisions } = useGlobalStylesRevisions(); const { openGeneralSidebar } = useDispatch( editSiteStore ); @@ -179,6 +179,7 @@ export default function SidebarNavigationScreenGlobalStyles() { description={ __( 'Choose a different style combination for the theme styles.' ) } + backPath={ backPath } content={ } footer={ shouldShowGlobalStylesFooter && ( diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/index.js index 2fcac0250c2bf5..24fb9372b4fff0 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/index.js @@ -22,7 +22,7 @@ const { useLocation } = unlock( routerPrivateApis ); export const postType = `wp_navigation`; -export default function SidebarNavigationScreenNavigationMenu() { +export default function SidebarNavigationScreenNavigationMenu( { backPath } ) { const { params: { postId }, } = useLocation(); @@ -67,6 +67,7 @@ export default function SidebarNavigationScreenNavigationMenu() { description={ __( 'Navigation Menus are a curated collection of blocks that allow visitors to get around your site.' ) } + backPath={ backPath } > @@ -77,6 +78,7 @@ export default function SidebarNavigationScreenNavigationMenu() { return ( ); } @@ -93,6 +95,7 @@ export default function SidebarNavigationScreenNavigationMenu() { onDuplicate={ _handleDuplicate } /> } + backPath={ backPath } title={ buildNavigationLabel( navigationMenu?.title, navigationMenu?.id, @@ -106,6 +109,7 @@ export default function SidebarNavigationScreenNavigationMenu() { return ( } + backPath={ backPath } title={ buildNavigationLabel( navigationMenu?.title, navigationMenu?.id, 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 65f80349ddaca2..d5c3fa92c902f9 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 @@ -46,7 +46,7 @@ function buildMenuLabel( title, id, status ) { // Save a boolean to prevent us creating a fallback more than once per session. let hasCreatedFallback = false; -export default function SidebarNavigationScreenNavigationMenus() { +export default function SidebarNavigationScreenNavigationMenus( { backPath } ) { const { records: navigationMenus, isResolving: isResolvingNavigationMenus, @@ -87,7 +87,7 @@ export default function SidebarNavigationScreenNavigationMenus() { if ( isLoading ) { return ( - + ); @@ -97,6 +97,7 @@ export default function SidebarNavigationScreenNavigationMenus() { return ( ); } @@ -106,6 +107,7 @@ export default function SidebarNavigationScreenNavigationMenus() { return ( handleDelete( firstNavigationMenu ) } handleDuplicate={ () => handleDuplicate( firstNavigationMenu ) } handleSave={ ( edits ) => @@ -116,7 +118,7 @@ export default function SidebarNavigationScreenNavigationMenus() { } return ( - + { navigationMenus?.map( ( { id, title, status }, index ) => ( ); diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-pattern/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-pattern/index.js index 6058b7d907d821..1b21466576f8ef 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-pattern/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-pattern/index.js @@ -19,11 +19,11 @@ import TemplateActions from '../template-actions'; const { useLocation, useHistory } = unlock( routerPrivateApis ); -export default function SidebarNavigationScreenPattern() { +export default function SidebarNavigationScreenPattern( { backPath } ) { const history = useHistory(); const location = useLocation(); const { - params: { postType, postId, categoryId, categoryType }, + params: { postType, postId }, } = location; const { setCanvasMode } = unlock( useDispatch( editSiteStore ) ); @@ -31,12 +31,6 @@ export default function SidebarNavigationScreenPattern() { const patternDetails = usePatternDetails( postType, postId ); - const backPath = { - categoryId, - categoryType, - path: '/patterns', - }; - return ( } content={ <> diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-template/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-template/index.js index ff12434b278952..76641f969fca79 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-template/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-template/index.js @@ -94,7 +94,7 @@ function useTemplateDetails( postType, postId ) { return { title, description, content, footer }; } -export default function SidebarNavigationScreenTemplate() { +export default function SidebarNavigationScreenTemplate( { backPath } ) { const history = useHistory(); const { params: { postType, postId }, @@ -108,6 +108,7 @@ export default function SidebarNavigationScreenTemplate() { return ( { - const backPath = - backPathProp ?? - location.state?.backPath ?? - getBackPath( location.params ); history.push( backPath ); navigate( 'back' ); } }