Skip to content
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
19 changes: 19 additions & 0 deletions packages/edit-site/src/components/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
*/
import { SlotFillProvider } from '@wordpress/components';
import { UnsavedChangesWarning } from '@wordpress/editor';
import { store as noticesStore } from '@wordpress/notices';
import { useDispatch } from '@wordpress/data';
import { __, sprintf } from '@wordpress/i18n';
import { PluginArea } from '@wordpress/plugins';

/**
* Internal dependencies
Expand All @@ -14,6 +18,20 @@ import NavigationSidebar from '../navigation-sidebar';
import getIsListPage from '../../utils/get-is-list-page';

export default function EditSiteApp( { reboot } ) {
const { createErrorNotice } = useDispatch( noticesStore );

function onPluginAreaError( name ) {
createErrorNotice(
sprintf(
/* translators: %s: plugin name */
__(
'The "%s" plugin has encountered an error and cannot be rendered.'
),
name
)
);
}

return (
<SlotFillProvider>
<UnsavedChangesWarning />
Expand All @@ -29,6 +47,7 @@ export default function EditSiteApp( { reboot } ) {
) : (
<Editor onError={ reboot } />
) }
<PluginArea onError={ onPluginAreaError } />
{ /* Keep the instance of the sidebar to ensure focus will not be lost
* when navigating to other pages. */ }
<NavigationSidebar
Expand Down
20 changes: 1 addition & 19 deletions packages/edit-site/src/components/editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ import {
EditorSnackbars,
EntitiesSavedStates,
} from '@wordpress/editor';
import { __, sprintf } from '@wordpress/i18n';
import { PluginArea } from '@wordpress/plugins';
import { __ } from '@wordpress/i18n';
import {
ShortcutProvider,
store as keyboardShortcutsStore,
} from '@wordpress/keyboard-shortcuts';
import { store as noticesStore } from '@wordpress/notices';

/**
* Internal dependencies
Expand Down Expand Up @@ -111,7 +109,6 @@ function Editor( { onError } ) {
}, [] );
const { setPage, setIsInserterOpened } = useDispatch( editSiteStore );
const { enableComplementaryArea } = useDispatch( interfaceStore );
const { createErrorNotice } = useDispatch( noticesStore );

const [
isEntitiesSavedStatesOpen,
Expand Down Expand Up @@ -183,18 +180,6 @@ function Editor( { onError } ) {
return null;
};

function onPluginAreaError( name ) {
createErrorNotice(
sprintf(
/* translators: %s: plugin name */
__(
'The "%s" plugin has encountered an error and cannot be rendered.'
),
name
)
);
}

// Only announce the title once the editor is ready to prevent "Replace"
// action in <URlQueryController> from double-announcing.
useTitle( isReady && __( 'Editor (beta)' ) );
Expand Down Expand Up @@ -314,9 +299,6 @@ function Editor( { onError } ) {
/>
<WelcomeGuide />
<Popover.Slot />
<PluginArea
onError={ onPluginAreaError }
/>
</ErrorBoundary>
</BlockContextProvider>
</GlobalStylesProvider>
Expand Down