UNPKG

@wordpress/editor

Version:
51 lines (48 loc) 1.45 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PostPendingStatusCheck = PostPendingStatusCheck; exports.default = void 0; var _data = require("@wordpress/data"); var _store = require("../../store"); /** * WordPress dependencies */ /** * Internal dependencies */ /** * This component checks the publishing status of the current post. * If the post is already published or the user doesn't have the * capability to publish, it returns null. * * @param {Object} props Component properties. * @param {Element} props.children Children to be rendered. * * @return {JSX.Element|null} The rendered child elements or null if the post is already published or the user doesn't have the capability to publish. */ function PostPendingStatusCheck({ children }) { const { hasPublishAction, isPublished } = (0, _data.useSelect)(select => { var _getCurrentPost$_link; const { isCurrentPostPublished, getCurrentPost } = select(_store.store); return { hasPublishAction: (_getCurrentPost$_link = getCurrentPost()._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false, isPublished: isCurrentPostPublished() }; }, []); if (isPublished || !hasPublishAction) { return null; } return children; } var _default = exports.default = PostPendingStatusCheck; //# sourceMappingURL=check.js.map