@wordpress/editor
Version:
Enhanced block editor for WordPress posts.
48 lines (41 loc) • 1.01 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _data = require("@wordpress/data");
/**
* WordPress dependencies
*/
function PostTrashCheck({
isNew,
postId,
canUserDelete,
children
}) {
if (isNew || !postId || !canUserDelete) {
return null;
}
return children;
}
var _default = (0, _data.withSelect)(select => {
const {
isEditedPostNew,
getCurrentPostId,
getCurrentPostType
} = select('core/editor');
const {
getPostType,
canUser
} = select('core');
const postId = getCurrentPostId();
const postType = getPostType(getCurrentPostType());
const resource = (postType === null || postType === void 0 ? void 0 : postType.rest_base) || ''; // eslint-disable-line camelcase
return {
isNew: isEditedPostNew(),
postId,
canUserDelete: postId && resource ? canUser('delete', resource, postId) : false
};
})(PostTrashCheck);
exports.default = _default;
//# sourceMappingURL=check.js.map