diff --git a/packages/edit-site/src/components/editor/index.js b/packages/edit-site/src/components/editor/index.js index bb81ddfde978df..a6ba9646d72b5f 100644 --- a/packages/edit-site/src/components/editor/index.js +++ b/packages/edit-site/src/components/editor/index.js @@ -3,7 +3,12 @@ */ import { useEffect, useState, useMemo, useCallback } from '@wordpress/element'; import { AsyncModeProvider, useSelect, useDispatch } from '@wordpress/data'; -import { SlotFillProvider, Popover, Button } from '@wordpress/components'; +import { + SlotFillProvider, + Popover, + Button, + Notice, +} from '@wordpress/components'; import { EntityProvider, store as coreStore } from '@wordpress/core-data'; import { BlockContextProvider, BlockBreadcrumb } from '@wordpress/block-editor'; import { @@ -217,6 +222,20 @@ function Editor( { initialSettings } ) { } /> ) } + { ! template && + settings?.siteUrl && + entityId && ( + + { __( + "You attempted to edit an item that doesn't exist. Perhaps it was deleted?" + ) } + + ) } } diff --git a/packages/edit-site/src/components/header/document-actions/index.js b/packages/edit-site/src/components/header/document-actions/index.js index 99fe151aae290f..fc9f592215df43 100644 --- a/packages/edit-site/src/components/header/document-actions/index.js +++ b/packages/edit-site/src/components/header/document-actions/index.js @@ -56,6 +56,7 @@ function useSecondaryText() { * @param {string} props.entityLabel A label to use for entity-related options. * E.g. "template" would be used for "edit * template" and "show template details". + * @param {boolean} props.isLoaded Whether the data is available. * @param {Function} props.children React component to use for the * information dropdown area. Should be a * function which accepts dropdown props. @@ -63,6 +64,7 @@ function useSecondaryText() { export default function DocumentActions( { entityTitle, entityLabel, + isLoaded, children: dropdownContent, } ) { const { label } = useSecondaryText(); @@ -73,7 +75,7 @@ export default function DocumentActions( { const titleRef = useRef(); // Return a simple loading indicator until we have information to show. - if ( ! entityTitle ) { + if ( ! isLoaded ) { return (
{ __( 'Loading…' ) } @@ -81,6 +83,15 @@ export default function DocumentActions( { ); } + // Return feedback that the template does not seem to exist. + if ( ! entityTitle ) { + return ( +
+ { __( 'Template not found' ) } +
+ ); + } + return (
{ const { __experimentalGetPreviewDeviceType, @@ -64,10 +65,12 @@ export default function Header( { 'wp_template' === postType ? getTemplateInfo( record ).title : record?.slug; + const _isLoaded = !! postId; return { deviceType: __experimentalGetPreviewDeviceType(), entityTitle: _entityTitle, + isLoaded: _isLoaded, hasFixedToolbar: isFeatureActive( 'fixedToolbar' ), template: record, templateType: postType, @@ -146,6 +149,7 @@ export default function Header( { { ( { onClose } ) => ( ) }