Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publicize: Adding to Gutenberg Extensibility for Publicize Support #5795

Closed
wants to merge 12 commits into from
25 changes: 25 additions & 0 deletions edit-post/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,28 @@ const MyPluginPostStatusInfo = () => (
```


### PluginPrePublishPanel
**Experimental**

Renders provided content to the pre-publish side panel in the publish flow (side panel that opens when user first pushes "Publish" from main editor).

#### Usage

```jsx
<PluginPrePublishPanel>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be Post not Pre 😃

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed 😃

<div>My plugin content</div>
</PluginPrePublishPanel>
```

### PluginPostPublishPanel
**Experimental**

Renders provided content to the post-publish panel in the publish flow (panel that opens after user publishes the post)

#### Usage

```jsx
<PluginPostPublishPanel>
<div>My plugin content</div>
</PluginPostPublishPanel>
```
8 changes: 7 additions & 1 deletion edit-post/components/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import EditorModeKeyboardShortcuts from '../keyboard-shortcuts';
import MetaBoxes from '../meta-boxes';
import { getMetaBoxContainer } from '../../utils/meta-boxes';
import Sidebar from '../sidebar';
import PluginPostPublishPanel from '../plugin-post-publish-panel';
import PluginPrePublishPanel from '../plugin-pre-publish-panel';

function Layout( {
mode,
Expand Down Expand Up @@ -84,7 +86,11 @@ function Layout( {
onClose={ closePublishSidebar }
forceIsDirty={ hasActiveMetaboxes }
forceIsSaving={ isSaving }
/>
prePublishExtension={ <PluginPrePublishPanel.Slot /> }
postPublishExtension={ <PluginPostPublishPanel.Slot /> }
>
<PluginPostPublishPanel.Slot />
</PostPublishPanel>
) }
<DocumentSidebar />
<BlockSidebar />
Expand Down
16 changes: 16 additions & 0 deletions edit-post/components/plugin-post-publish-panel/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Defines extensibility slot for post-publish sidebar.
*
* Defines slot to be used by plugins to insert content in the post-publish sidebar
* (which appears after a user fully publishes a post).
*
* @file This files defines the PluginPostPublishPanel extension
* @since 2.7.0
*/

/**
* Internal dependencies
*/
import { createSlotFill } from '../../../components/slot-fill';

export default createSlotFill( 'PluginPostPublishPanel' );
16 changes: 16 additions & 0 deletions edit-post/components/plugin-pre-publish-panel/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Defines extensibility slot for pre-publish sidebar.
*
* Defines slot to be used by plugins to insert content in the pre-publish sidebar
* (which appears when a user pushes "Publish" from the main editor).
*
* @file This files defines the PluginPrePublishPanel extension
* @since 2.7.0
*/

/**
* Internal dependencies
*/
import { createSlotFill } from '../../../components/slot-fill';

export default createSlotFill( 'PluginPrePublishPanel' );
2 changes: 2 additions & 0 deletions edit-post/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ export function initializeEditor( id, post, settings ) {
};
}

export { default as PluginPostPublishPanel } from './components/sidebar/plugin-post-status-info';
export { default as PluginPostStatusInfo } from './components/sidebar/plugin-post-status-info';
export { default as PluginPrePublishPanel } from './components/sidebar/plugin-post-status-info';
export { default as PluginSidebar } from './components/sidebar/plugin-sidebar';
export { default as PluginSidebarMoreMenuItem } from './components/header/plugin-sidebar-more-menu-item';
6 changes: 3 additions & 3 deletions editor/components/post-publish-panel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class PostPublishPanel extends Component {
}

render() {
const { isScheduled, onClose, forceIsDirty, forceIsSaving } = this.props;
const { isScheduled, onClose, forceIsDirty, forceIsSaving, prePublishExtension, postPublishExtension } = this.props;
const { loading, submitted } = this.state;
return (
<div className="editor-post-publish-panel">
Expand All @@ -82,9 +82,9 @@ class PostPublishPanel extends Component {
/>
</div>
<div className="editor-post-publish-panel__content">
{ ! loading && ! submitted && <PostPublishPanelPrepublish /> }
{ ! loading && ! submitted && <PostPublishPanelPrepublish>{ prePublishExtension }</PostPublishPanelPrepublish> }
{ loading && ! submitted && <Spinner /> }
{ submitted && <PostPublishPanelPostpublish /> }
{ submitted && <PostPublishPanelPostpublish>{ postPublishExtension }</PostPublishPanelPostpublish> }
</div>
</div>
);
Expand Down
1 change: 1 addition & 0 deletions editor/components/post-publish-panel/postpublish.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class PostPublishPanelPostpublish extends Component {
</ClipboardButton>
</div>
</PanelBody>
{ this.props.children }
</div>
);
}
Expand Down
3 changes: 2 additions & 1 deletion editor/components/post-publish-panel/prepublish.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import PostVisibilityLabel from '../post-visibility/label';
import PostSchedule from '../post-schedule';
import PostScheduleLabel from '../post-schedule/label';

function PostPublishPanelPrepublish() {
function PostPublishPanelPrepublish( props ) {
return (
<div className="editor-post-publish-panel__prepublish">
<div><strong>{ __( 'Are you ready to publish?' ) }</strong></div>
Expand All @@ -29,6 +29,7 @@ function PostPublishPanelPrepublish() {
] }>
<PostSchedule />
</PanelBody>
{ props.children }
</div>
);
}
Expand Down