UNPKG

@wordpress/edit-post

Version:
61 lines (55 loc) 2.13 kB
import { createElement, Fragment } from "@wordpress/element"; /** * WordPress dependencies */ import { __ } from '@wordpress/i18n'; import { PanelBody } from '@wordpress/components'; import { withSelect, withDispatch } from '@wordpress/data'; import { compose, ifCondition } from '@wordpress/compose'; /** * Internal dependencies */ import PostVisibility from '../post-visibility'; import PostTrash from '../post-trash'; import PostSchedule from '../post-schedule'; import PostSticky from '../post-sticky'; import PostAuthor from '../post-author'; import PostSlug from '../post-slug'; import PostFormat from '../post-format'; import PostPendingStatus from '../post-pending-status'; import PluginPostStatusInfo from '../plugin-post-status-info'; import { store as editPostStore } from '../../../store'; /** * Module Constants */ const PANEL_NAME = 'post-status'; function PostStatus({ isOpened, onTogglePanel }) { return createElement(PanelBody, { className: "edit-post-post-status", title: __('Status & visibility'), opened: isOpened, onToggle: onTogglePanel }, createElement(PluginPostStatusInfo.Slot, null, fills => createElement(Fragment, null, createElement(PostVisibility, null), createElement(PostSchedule, null), createElement(PostFormat, null), createElement(PostSticky, null), createElement(PostPendingStatus, null), createElement(PostSlug, null), createElement(PostAuthor, null), fills, createElement(PostTrash, null)))); } export default compose([withSelect(select => { // We use isEditorPanelRemoved to hide the panel if it was programatically removed. We do // not use isEditorPanelEnabled since this panel should not be disabled through the UI. const { isEditorPanelRemoved, isEditorPanelOpened } = select(editPostStore); return { isRemoved: isEditorPanelRemoved(PANEL_NAME), isOpened: isEditorPanelOpened(PANEL_NAME) }; }), ifCondition(({ isRemoved }) => !isRemoved), withDispatch(dispatch => ({ onTogglePanel() { return dispatch(editPostStore).toggleEditorPanelOpened(PANEL_NAME); } }))])(PostStatus); //# sourceMappingURL=index.js.map