@wordpress/editor
Version:
Enhanced block editor for WordPress posts.
37 lines (32 loc) • 736 B
JavaScript
/**
* WordPress dependencies
*/
import { withSelect } from '@wordpress/data';
/**
* Internal dependencies
*/
import PostTypeSupportCheck from '../post-type-support-check';
export function PostLastRevisionCheck( {
lastRevisionId,
revisionsCount,
children,
} ) {
if ( ! lastRevisionId || revisionsCount < 2 ) {
return null;
}
return (
<PostTypeSupportCheck supportKeys="revisions">
{ children }
</PostTypeSupportCheck>
);
}
export default withSelect( ( select ) => {
const {
getCurrentPostLastRevisionId,
getCurrentPostRevisionsCount,
} = select( 'core/editor' );
return {
lastRevisionId: getCurrentPostLastRevisionId(),
revisionsCount: getCurrentPostRevisionsCount(),
};
} )( PostLastRevisionCheck );