diff --git a/client/gutenberg/editor/edit-post/components/header/index.js b/client/gutenberg/editor/edit-post/components/header/index.js
index c76b7333fc98f..9f82139d9600b 100644
--- a/client/gutenberg/editor/edit-post/components/header/index.js
+++ b/client/gutenberg/editor/edit-post/components/header/index.js
@@ -1,3 +1,5 @@
+/** @format */
+
/**
* External dependencies
*/
@@ -8,13 +10,10 @@ import React from 'react';
*/
import { __ } from '@wordpress/i18n';
import { IconButton } from '@wordpress/components';
-import {
- PostPreviewButton,
- PostSavedState,
- PostPublishPanelToggle,
-} from '@wordpress/editor';
+import { PostPreviewButton, PostSavedState } from '@wordpress/editor';
import { withDispatch, withSelect } from '@wordpress/data';
import { compose } from '@wordpress/compose';
+import { DotTip } from '@wordpress/nux';
/**
* Internal dependencies
@@ -22,17 +21,17 @@ import { compose } from '@wordpress/compose';
import MoreMenu from './more-menu';
import HeaderToolbar from './header-toolbar';
import PinnedPlugins from './pinned-plugins';
+import shortcuts from '../../keyboard-shortcuts';
+import PostPublishButtonOrToggle from './post-publish-button-or-toggle';
function Header( {
- isEditorSidebarOpened,
- openGeneralSidebar,
closeGeneralSidebar,
+ isEditorSidebarOpened,
isPublishSidebarOpened,
- togglePublishSidebar,
+ openGeneralSidebar,
} ) {
const toggleGeneralSidebar = isEditorSidebarOpened ? closeGeneralSidebar : openGeneralSidebar;
- /* eslint-disable wpcalypso/jsx-classname-namespace */
return (
{ ! isPublishSidebarOpened && (
-
+
-
-
-
+
+
+
+
+ { __(
+ 'You’ll find more settings for your page and blocks in the sidebar. Click “Settings” to open it.'
+ ) }
+
+
) }
);
- /* eslint-enable wpcalypso/jsx-classname-namespace */
}
export default compose(
- withSelect( ( select ) => ( {
+ withSelect( select => ( {
+ hasBlockSelection: !! select( 'core/editor' ).getBlockSelectionStart(),
isEditorSidebarOpened: select( 'core/edit-post' ).isEditorSidebarOpened(),
isPublishSidebarOpened: select( 'core/edit-post' ).isPublishSidebarOpened(),
- hasBlockSelection: !! select( 'core/editor' ).getBlockSelectionStart(),
} ) ),
withDispatch( ( dispatch, { hasBlockSelection } ) => {
- const { openGeneralSidebar, closeGeneralSidebar, togglePublishSidebar } = dispatch( 'core/edit-post' );
+ const { openGeneralSidebar, closeGeneralSidebar } = dispatch( 'core/edit-post' );
const sidebarToOpen = hasBlockSelection ? 'edit-post/block' : 'edit-post/document';
return {
openGeneralSidebar: () => openGeneralSidebar( sidebarToOpen ),
closeGeneralSidebar: closeGeneralSidebar,
- togglePublishSidebar: togglePublishSidebar,
hasBlockSelection: undefined,
};
- } ),
+ } )
)( Header );
diff --git a/client/gutenberg/editor/edit-post/components/header/post-publish-button-or-toggle.js b/client/gutenberg/editor/edit-post/components/header/post-publish-button-or-toggle.js
new file mode 100644
index 0000000000000..22fce3a9d760d
--- /dev/null
+++ b/client/gutenberg/editor/edit-post/components/header/post-publish-button-or-toggle.js
@@ -0,0 +1,96 @@
+/** @format */
+/**
+ * External Dependencies
+ */
+import React from 'react';
+import { get } from 'lodash';
+
+/**
+ * WordPress dependencies.
+ */
+import { PostPublishPanelToggle, PostPublishButton } from '@wordpress/editor';
+import { compose } from '@wordpress/compose';
+import { withDispatch, withSelect } from '@wordpress/data';
+import { withViewportMatch } from '@wordpress/viewport';
+
+export function PostPublishButtonOrToggle( {
+ forceIsDirty,
+ forceIsSaving,
+ hasPublishAction,
+ isBeingScheduled,
+ isLessThanMediumViewport,
+ isPending,
+ isPublished,
+ isPublishSidebarEnabled,
+ isPublishSidebarOpened,
+ isScheduled,
+ togglePublishSidebar,
+} ) {
+ const button = (
+
+ );
+ const toggle = (
+
+ );
+
+ /**
+ * We want to show a BUTTON when the post status is at the _final stage_
+ * for a particular role (see https://codex.wordpress.org/Post_Status):
+ *
+ * - is published
+ * - is scheduled to be published
+ * - is pending and can't be published (but only for viewports >= medium)
+ *
+ * Originally we considered showing a button for pending posts
+ * that couldn't be published (for ex, for a contributor role).
+ * Some languages can have really long translations for "Submit for review",
+ * so given the lack of UI real state we decided to take into account the viewport
+ * in that particular case.
+ */
+ if (
+ isPublished ||
+ ( isScheduled && isBeingScheduled ) ||
+ ( isPending && ! hasPublishAction && ! isLessThanMediumViewport )
+ ) {
+ return button;
+ }
+
+ /**
+ * Then, we take other things into account:
+ *
+ * - Show TOGGLE if it is small viewport.
+ * - Otherwise, use publish sidebar status to decide - TOGGLE if enabled, BUTTON if not.
+ */
+ if ( isLessThanMediumViewport ) {
+ return toggle;
+ }
+
+ return isPublishSidebarEnabled ? toggle : button;
+}
+
+export default compose(
+ withSelect( select => ( {
+ hasPublishAction: get(
+ select( 'core/editor' ).getCurrentPost(),
+ [ '_links', 'wp:action-publish' ],
+ false
+ ),
+ isBeingScheduled: select( 'core/editor' ).isEditedPostBeingScheduled(),
+ isPending: select( 'core/editor' ).isCurrentPostPending(),
+ isPublished: select( 'core/editor' ).isCurrentPostPublished(),
+ isPublishSidebarEnabled: select( 'core/editor' ).isPublishSidebarEnabled(),
+ isPublishSidebarOpened: select( 'core/edit-post' ).isPublishSidebarOpened(),
+ isScheduled: select( 'core/editor' ).isCurrentPostScheduled(),
+ } ) ),
+ withDispatch( dispatch => {
+ const { togglePublishSidebar } = dispatch( 'core/edit-post' );
+ return {
+ togglePublishSidebar,
+ };
+ } ),
+ withViewportMatch( { isLessThanMediumViewport: '< medium' } )
+)( PostPublishButtonOrToggle );