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: Site Editor should display a 404 message #69009

Merged
merged 4 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions packages/edit-site/src/components/layout/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,10 @@ html.canvas-mode-edit-transition::view-transition-group(toggle) {
}
}

.edit-site-layout__area__404 {
margin: $canvas-padding;
}

.edit-site .components-editor-notices__snackbar {
position: fixed;
right: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export function MainSidebarNavigationContent( { isBlockBasedTheme = true } ) {
);
}

export default function SidebarNavigationScreenMain() {
export default function SidebarNavigationScreenMain( { customDescription } ) {
const isBlockBasedTheme = useSelect(
( select ) => select( coreStore ).getCurrentTheme()?.is_block_theme,
[]
Expand All @@ -91,19 +91,24 @@ export default function SidebarNavigationScreenMain() {
setEditorCanvasContainerView( undefined );
}, [ setEditorCanvasContainerView ] );

let description;
if ( customDescription ) {
description = customDescription;
} else if ( isBlockBasedTheme ) {
description = __(
'Customize the appearance of your website using the block editor.'
);
} else {
description = __(
'Explore block styles and patterns to refine your site'
);
}

return (
<SidebarNavigationScreen
isRoot
title={ __( 'Design' ) }
description={
isBlockBasedTheme
? __(
'Customize the appearance of your website using the block editor.'
)
: __(
'Explore block styles and patterns to refine your site'
)
}
description={ description }
content={
<MainSidebarNavigationContent
isBlockBasedTheme={ isBlockBasedTheme }
Expand Down
2 changes: 2 additions & 0 deletions packages/edit-site/src/components/site-editor-routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { templateItemRoute } from './template-item';
import { pagesRoute } from './pages';
import { pageItemRoute } from './page-item';
import { stylebookRoute } from './stylebook';
import { notFoundRoute } from './notfound';

const routes = [
pageItemRoute,
Expand All @@ -35,6 +36,7 @@ const routes = [
stylesRoute,
homeRoute,
stylebookRoute,
notFoundRoute,
];

export function useRegisterSiteEditorRoutes() {
Expand Down
27 changes: 27 additions & 0 deletions packages/edit-site/src/components/site-editor-routes/notfound.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import SidebarNavigationScreenMain from '../sidebar-navigation-screen-main';

export const notFoundRoute = {
name: 'notfound',
path: '*',
areas: {
sidebar: <SidebarNavigationScreenMain />,
mobile: (
<SidebarNavigationScreenMain
customDescription={ __( '404 (Not Found)' ) }
/>
),
content: (
<p className="edit-site-layout__area__404">
{ __( '404 (Not Found)' ) }
</p>
),
},
};
Loading