Skip to content

Commit

Permalink
Site Editor: Fix sidebar plugins (#67557)
Browse files Browse the repository at this point in the history
Co-authored-by: youknowriad <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: matiasbenedetto <[email protected]>
  • Loading branch information
4 people authored Dec 4, 2024
1 parent dc532bb commit ae3e115
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
18 changes: 1 addition & 17 deletions packages/edit-site/src/components/app/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
/**
* WordPress dependencies
*/
import { store as noticesStore } from '@wordpress/notices';
import { useDispatch, useSelect } from '@wordpress/data';
import { __, sprintf } from '@wordpress/i18n';
import { PluginArea } from '@wordpress/plugins';
import { useSelect } from '@wordpress/data';
import { privateApis as routerPrivateApis } from '@wordpress/router';
import { useCallback } from '@wordpress/element';

Expand Down Expand Up @@ -33,21 +30,9 @@ function AppLayout() {

export default function App() {
useRegisterSiteEditorRoutes();
const { createErrorNotice } = useDispatch( noticesStore );
const routes = useSelect( ( select ) => {
return unlock( select( editSiteStore ) ).getRoutes();
}, [] );
function onPluginAreaError( name ) {
createErrorNotice(
sprintf(
/* translators: %s: plugin name */
__(
'The "%s" plugin has encountered an error and cannot be rendered.'
),
name
)
);
}
const beforeNavigate = useCallback( ( { path, query } ) => {
if ( ! isPreviewingTheme() ) {
return { path, query };
Expand All @@ -72,7 +57,6 @@ export default function App() {
beforeNavigate={ beforeNavigate }
>
<AppLayout />
<PluginArea onError={ onPluginAreaError } />
</RouterProvider>
);
}
20 changes: 19 additions & 1 deletion packages/edit-site/src/components/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
useResizeObserver,
usePrevious,
} from '@wordpress/compose';
import { __ } from '@wordpress/i18n';
import { __, sprintf } from '@wordpress/i18n';
import { useState, useRef, useEffect } from '@wordpress/element';
import { CommandMenu } from '@wordpress/commands';
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
Expand All @@ -29,6 +29,9 @@ import {
} from '@wordpress/editor';
import { privateApis as coreCommandsPrivateApis } from '@wordpress/core-commands';
import { privateApis as routerPrivateApis } from '@wordpress/router';
import { PluginArea } from '@wordpress/plugins';
import { store as noticesStore } from '@wordpress/notices';
import { useDispatch } from '@wordpress/data';

/**
* Internal dependencies
Expand Down Expand Up @@ -235,9 +238,24 @@ function Layout() {
}

export default function LayoutWithGlobalStylesProvider( props ) {
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>
<GlobalStylesProvider>
{ /** This needs to be within the SlotFillProvider */ }
<PluginArea onError={ onPluginAreaError } />
<Layout { ...props } />
</GlobalStylesProvider>
</SlotFillProvider>
Expand Down

1 comment on commit ae3e115

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in ae3e115.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12157351447
📝 Reported issues:

Please sign in to comment.