@wordpress/editor
Version:
Enhanced block editor for WordPress posts.
39 lines (35 loc) • 870 B
JavaScript
/**
* WordPress dependencies
*/
import { withSelect } from '@wordpress/data';
function PostTrashCheck({
isNew,
postId,
canUserDelete,
children
}) {
if (isNew || !postId || !canUserDelete) {
return null;
}
return children;
}
export default 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);
//# sourceMappingURL=check.js.map