diff --git a/packages/edit-post/src/components/layout/index.js b/packages/edit-post/src/components/layout/index.js index e931a08402bbc..51311d59ea7b6 100644 --- a/packages/edit-post/src/components/layout/index.js +++ b/packages/edit-post/src/components/layout/index.js @@ -12,6 +12,7 @@ import { UnsavedChangesWarning, EditorNotices, EditorKeyboardShortcutsRegister, + EditorSnackbars, store as editorStore, } from '@wordpress/editor'; import { AsyncModeProvider, useSelect, useDispatch } from '@wordpress/data'; @@ -225,6 +226,7 @@ function Layout( { styles } ) { ) } + notices={ } content={ <> diff --git a/packages/edit-site/src/components/editor/index.js b/packages/edit-site/src/components/editor/index.js index 557e8dfa8e225..4d3eca9143f1f 100644 --- a/packages/edit-site/src/components/editor/index.js +++ b/packages/edit-site/src/components/editor/index.js @@ -19,6 +19,7 @@ import { } from '@wordpress/interface'; import { EditorNotices, + EditorSnackbars, EntitiesSavedStates, UnsavedChangesWarning, store as editorStore, @@ -213,6 +214,7 @@ function Editor( { initialSettings } ) { } /> } + notices={ } content={ <> diff --git a/packages/editor/src/components/editor-notices/index.js b/packages/editor/src/components/editor-notices/index.js index 734bb2dae2e01..1dd7b8e0e31bf 100644 --- a/packages/editor/src/components/editor-notices/index.js +++ b/packages/editor/src/components/editor-notices/index.js @@ -6,7 +6,7 @@ import { filter } from 'lodash'; /** * WordPress dependencies */ -import { NoticeList, SnackbarList } from '@wordpress/components'; +import { NoticeList } from '@wordpress/components'; import { withSelect, withDispatch } from '@wordpress/data'; import { compose } from '@wordpress/compose'; import { store as noticesStore } from '@wordpress/notices'; @@ -25,9 +25,6 @@ export function EditorNotices( { notices, onRemove } ) { isDismissible: false, type: 'default', } ); - const snackbarNotices = filter( notices, { - type: 'snackbar', - } ); return ( <> @@ -42,11 +39,6 @@ export function EditorNotices( { notices, onRemove } ) { > - ); } diff --git a/packages/editor/src/components/editor-snackbars/index.js b/packages/editor/src/components/editor-snackbars/index.js new file mode 100644 index 0000000000000..6dc01435eb4b4 --- /dev/null +++ b/packages/editor/src/components/editor-snackbars/index.js @@ -0,0 +1,30 @@ +/** + * External dependencies + */ +import { filter } from 'lodash'; + +/** + * WordPress dependencies + */ +import { SnackbarList } from '@wordpress/components'; +import { useSelect, useDispatch } from '@wordpress/data'; +import { store as noticesStore } from '@wordpress/notices'; + +export default function EditorSnackbars() { + const notices = useSelect( + ( select ) => select( noticesStore ).getNotices(), + [] + ); + const { removeNotice } = useDispatch( noticesStore ); + const snackbarNotices = filter( notices, { + type: 'snackbar', + } ); + + return ( + + ); +} diff --git a/packages/editor/src/components/index.js b/packages/editor/src/components/index.js index c2a281781a2ca..50dfd6885166d 100644 --- a/packages/editor/src/components/index.js +++ b/packages/editor/src/components/index.js @@ -11,6 +11,7 @@ export { default as EditorKeyboardShortcutsRegister } from './global-keyboard-sh export { default as EditorHistoryRedo } from './editor-history/redo'; export { default as EditorHistoryUndo } from './editor-history/undo'; export { default as EditorNotices } from './editor-notices'; +export { default as EditorSnackbars } from './editor-snackbars'; export { default as EntitiesSavedStates } from './entities-saved-states'; export { default as ErrorBoundary } from './error-boundary'; export { default as LocalAutosaveMonitor } from './local-autosave-monitor'; diff --git a/packages/interface/src/components/interface-skeleton/index.js b/packages/interface/src/components/interface-skeleton/index.js index 184f0ddde3005..26bf20681f659 100644 --- a/packages/interface/src/components/interface-skeleton/index.js +++ b/packages/interface/src/components/interface-skeleton/index.js @@ -3,6 +3,9 @@ */ import classnames from 'classnames'; +/** + * WordPress dependencies + */ /** * WordPress dependencies */ @@ -31,6 +34,7 @@ function InterfaceSkeleton( header, sidebar, secondarySidebar, + notices, content, drawer, actions, @@ -105,6 +109,11 @@ function InterfaceSkeleton( { secondarySidebar } ) } + { !! notices && ( +
+ { notices } +
+ ) }