From 78db1392698643e6f716ebf8ec0df89fc1d5d459 Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Fri, 24 Nov 2017 12:38:40 +0100 Subject: [PATCH] Components: Extract Reusable Editor Notices Component --- editor/components/editor-notices/index.js | 22 ++++++++++++++++++++++ editor/components/index.js | 1 + editor/edit-post/layout/index.js | 12 ++++-------- 3 files changed, 27 insertions(+), 8 deletions(-) create mode 100644 editor/components/editor-notices/index.js diff --git a/editor/components/editor-notices/index.js b/editor/components/editor-notices/index.js new file mode 100644 index 00000000000000..52289374de60fa --- /dev/null +++ b/editor/components/editor-notices/index.js @@ -0,0 +1,22 @@ +/** + * External dependencies + */ +import { connect } from 'react-redux'; + +/** + * WordPress dependencies + */ +import { NoticeList } from '@wordpress/components'; + +/** + * Internal dependencies + */ +import { removeNotice } from '../../actions'; +import { getNotices } from '../../selectors'; + +export default connect( + ( state ) => ( { + notices: getNotices( state ), + } ), + { onRemove: removeNotice } +)( NoticeList ); diff --git a/editor/components/index.js b/editor/components/index.js index 716b468cb7a8e6..bcb399c1d52bf9 100644 --- a/editor/components/index.js +++ b/editor/components/index.js @@ -5,6 +5,7 @@ export { default as DocumentOutlineCheck } from './document-outline/check'; export { default as EditorGlobalKeyboardShortcuts } from './editor-global-keyboard-shortcuts'; 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 MetaBoxes } from './meta-boxes'; export { default as PageAttributes } from './page-attributes'; export { default as PageAttributesCheck } from './page-attributes/check'; diff --git a/editor/edit-post/layout/index.js b/editor/edit-post/layout/index.js index 0a9eceebb32665..db682fc605d096 100644 --- a/editor/edit-post/layout/index.js +++ b/editor/edit-post/layout/index.js @@ -7,7 +7,7 @@ import classnames from 'classnames'; /** * WordPress dependencies */ -import { NoticeList, Popover, navigateRegions } from '@wordpress/components'; +import { Popover, navigateRegions } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; /** @@ -19,15 +19,13 @@ import Sidebar from '../sidebar'; import TextEditor from '../modes/text-editor'; import VisualEditor from '../modes/visual-editor'; import DocumentTitle from '../document-title'; -import { removeNotice } from '../../actions'; -import { MetaBoxes, AutosaveMonitor, UnsavedChangesWarning } from '../../components'; +import { MetaBoxes, AutosaveMonitor, UnsavedChangesWarning, EditorNotices } from '../../components'; import { getEditorMode, isEditorSidebarOpened, - getNotices, } from '../../selectors'; -function Layout( { mode, isSidebarOpened, notices, ...props } ) { +function Layout( { mode, isSidebarOpened } ) { const className = classnames( 'editor-layout', { 'is-sidebar-opened': isSidebarOpened, } ); @@ -35,7 +33,7 @@ function Layout( { mode, isSidebarOpened, notices, ...props } ) { return (
- +
@@ -58,7 +56,5 @@ export default connect( ( state ) => ( { mode: getEditorMode( state ), isSidebarOpened: isEditorSidebarOpened( state ), - notices: getNotices( state ), } ), - { removeNotice } )( navigateRegions( Layout ) );