Skip to content

Commit

Permalink
Connect the dots: publish toggles publish sidebar or publish directly
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Sep 10, 2018
1 parent 20f109f commit a8a8bfe
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
9 changes: 6 additions & 3 deletions edit-post/components/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { IconButton } from '@wordpress/components';
import {
PostPreviewButton,
PostSavedState,
PostPublishPanelToggle,
} from '@wordpress/editor';
import { withDispatch, withSelect } from '@wordpress/data';
import { compose } from '@wordpress/compose';
Expand All @@ -19,13 +18,15 @@ import './style.scss';
import MoreMenu from './more-menu';
import HeaderToolbar from './header-toolbar';
import PinnedPlugins from './pinned-plugins';
import PublishButton from './publish-button';
import shortcuts from '../../keyboard-shortcuts';

function Header( {
isEditorSidebarOpened,
openGeneralSidebar,
closeGeneralSidebar,
isPublishSidebarOpened,
isPublishSidebarEnabled,
togglePublishSidebar,
hasActiveMetaboxes,
isSaving,
Expand All @@ -48,8 +49,9 @@ function Header( {
forceIsSaving={ isSaving }
/>
<PostPreviewButton />
<PostPublishPanelToggle
isOpen={ isPublishSidebarOpened }
<PublishButton
isSidebarOpen={ isPublishSidebarOpened }
isSidebarEnabled={ isPublishSidebarEnabled }
onToggle={ togglePublishSidebar }
forceIsDirty={ hasActiveMetaboxes }
forceIsSaving={ isSaving }
Expand Down Expand Up @@ -79,6 +81,7 @@ export default compose(
withSelect( ( select ) => ( {
isEditorSidebarOpened: select( 'core/edit-post' ).isEditorSidebarOpened(),
isPublishSidebarOpened: select( 'core/edit-post' ).isPublishSidebarOpened(),
isPublishSidebarEnabled: select( 'core/edit-post' ).isPublishSidebarEnabled(),
hasActiveMetaboxes: select( 'core/edit-post' ).hasMetaBoxes(),
isSaving: select( 'core/edit-post' ).isSavingMetaBoxes(),
hasBlockSelection: !! select( 'core/editor' ).getBlockSelectionStart(),
Expand Down
25 changes: 25 additions & 0 deletions edit-post/components/header/publish-button/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { PostPublishPanelToggle, PostPublishButton } from '@wordpress/editor';

const PublishButton = function( {
isSidebarOpen,
isSidebarEnabled,
onToggle,
forceIsDirty,
forceIsSaving } ) {
if ( isSidebarEnabled ) {
return (
<PostPublishPanelToggle
isSidebarOpen={ isSidebarOpen }
onToggle={ onToggle }
forceIsDirty={ forceIsDirty }
forceIsSaving={ forceIsSaving }
/>
);
}
return <PostPublishButton
forceIsDirty={ forceIsDirty }
forceIsSaving={ forceIsSaving }
/>;
};

export default PublishButton;

0 comments on commit a8a8bfe

Please sign in to comment.