diff --git a/editor/actions.js b/editor/actions.js index 445a91787839a..5a168aecf19fa 100644 --- a/editor/actions.js +++ b/editor/actions.js @@ -263,6 +263,30 @@ export function stopTyping() { }; } +/** + * Returns an action object used in signalling that the user toggled the sidebar + * + * @return {Object} Action object + */ +export function toggleSidebar() { + return { + type: 'TOGGLE_SIDEBAR', + }; +} + +/** + * Returns an action object used in signalling that the user switched the active sidebar tab panel + * + * @param {String} panel The panel name + * @return {Object} Action object + */ +export function setActivePanel( panel ) { + return { + type: 'SET_ACTIVE_PANEL', + panel, + }; +} + /** * Returns an action object used in signalling that the user toggled a sidebar panel * diff --git a/editor/block-settings-menu/content.js b/editor/block-settings-menu/content.js index 27ed09e50bf11..3b2b0dfac5d6a 100644 --- a/editor/block-settings-menu/content.js +++ b/editor/block-settings-menu/content.js @@ -13,14 +13,14 @@ import { IconButton } from '@wordpress/components'; * Internal dependencies */ import { isEditorSidebarOpened } from '../selectors'; -import { selectBlock } from '../actions'; +import { selectBlock, removeBlock, toggleSidebar, setActivePanel } from '../actions'; -function BlockSettingsMenuContent( { onDelete, onSelect, isSidebarOpened, toggleSidebar, setActivePanel } ) { +function BlockSettingsMenuContent( { onDelete, onSelect, isSidebarOpened, onToggleSidebar, onShowInspector } ) { const toggleInspector = () => { onSelect(); - setActivePanel(); + onShowInspector(); if ( ! isSidebarOpened ) { - toggleSidebar(); + onToggleSidebar(); } }; @@ -48,22 +48,16 @@ export default connect( } ), ( dispatch, ownProps ) => ( { onDelete() { - dispatch( { - type: 'REMOVE_BLOCKS', - uids: [ ownProps.uid ], - } ); + dispatch( removeBlock( ownProps.uid ) ); }, onSelect() { dispatch( selectBlock( ownProps.uid ) ); }, - setActivePanel() { - dispatch( { - type: 'SET_ACTIVE_PANEL', - panel: 'block', - } ); + onShowInspector() { + dispatch( setActivePanel( 'block' ) ); }, - toggleSidebar() { - dispatch( { type: 'TOGGLE_SIDEBAR' } ); + onToggleSidebar() { + dispatch( toggleSidebar() ); }, } ) )( BlockSettingsMenuContent ); diff --git a/editor/header/index.js b/editor/header/index.js index aa0f6a0e0f8b7..0d48769319655 100644 --- a/editor/header/index.js +++ b/editor/header/index.js @@ -19,7 +19,7 @@ import PreviewButton from './preview-button'; import ModeSwitcher from './mode-switcher'; import Inserter from '../inserter'; import { getMultiSelectedBlockUids, hasEditorUndo, hasEditorRedo, isEditorSidebarOpened } from '../selectors'; -import { clearSelectedBlock } from '../actions'; +import { clearSelectedBlock, toggleSidebar, removeBlocks } from '../actions'; function Header( { multiSelectedBlockUids, @@ -29,7 +29,7 @@ function Header( { redo, hasRedo, hasUndo, - toggleSidebar, + onToggleSidebar, isSidebarOpened, } ) { const count = multiSelectedBlockUids.length; @@ -90,7 +90,7 @@ function Header( { @@ -109,12 +109,9 @@ export default connect( } ), ( dispatch ) => ( { onDeselect: () => dispatch( clearSelectedBlock() ), - onRemove: ( uids ) => dispatch( { - type: 'REMOVE_BLOCKS', - uids, - } ), + onRemove: ( uids ) => dispatch( removeBlocks( uids ) ), undo: () => dispatch( { type: 'UNDO' } ), redo: () => dispatch( { type: 'REDO' } ), - toggleSidebar: () => dispatch( { type: 'TOGGLE_SIDEBAR' } ), + onToggleSidebar: () => dispatch( toggleSidebar() ), } ) )( Header ); diff --git a/editor/sidebar/header.js b/editor/sidebar/header.js index 8f589fe84b0ba..3970128ef4061 100644 --- a/editor/sidebar/header.js +++ b/editor/sidebar/header.js @@ -13,8 +13,9 @@ import { IconButton } from '@wordpress/components'; * Internal Dependencies */ import { getActivePanel } from '../selectors'; +import { toggleSidebar, setActivePanel } from '../actions'; -const SidebarHeader = ( { panel, onSetPanel, toggleSidebar } ) => { +const SidebarHeader = ( { panel, onSetPanel, onToggleSidebar } ) => { return (
@@ -45,12 +46,7 @@ export default connect( panel: getActivePanel( state ), } ), ( dispatch ) => ( { - onSetPanel( panel ) { - dispatch( { - type: 'SET_ACTIVE_PANEL', - panel: panel, - } ); - }, - toggleSidebar: () => dispatch( { type: 'TOGGLE_SIDEBAR' } ), + onSetPanel: ( panel ) => dispatch( setActivePanel( panel ) ), + onToggleSidebar: () => dispatch( toggleSidebar() ), } ) )( SidebarHeader );