Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation for PostLastRevision, PostLastRevisionCheck, PostLastRevisionPanel components #61166

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 20 additions & 3 deletions packages/editor/README.md
Expand Up @@ -974,15 +974,32 @@ Undocumented declaration.

### PostLastRevision

Undocumented declaration.
Renders the component for displaying the last revision of a post.

_Returns_

- `Component`: The component to be rendered.

### PostLastRevisionCheck

Undocumented declaration.
Wrapper component that renders its children if the post has more than one revision.

_Parameters_

- _props_ `Object`: Props.
- _props.children_ `Element`: Children to be rendered.

_Returns_

- `Component|null`: Rendered child components if post has more than one revision, otherwise null.

### PostLastRevisionPanel

Undocumented declaration.
Renders the panel for displaying the last revision of a post.

_Returns_

- `Component`: The component to be rendered.

### PostLockedModal

Expand Down
8 changes: 8 additions & 0 deletions packages/editor/src/components/post-last-revision/check.js
Expand Up @@ -9,6 +9,14 @@ import { useSelect } from '@wordpress/data';
import PostTypeSupportCheck from '../post-type-support-check';
import { store as editorStore } from '../../store';

/**
* Wrapper component that renders its children if the post has more than one revision.
*
* @param {Object} props Props.
* @param {Element} props.children Children to be rendered.
*
* @return {Component|null} Rendered child components if post has more than one revision, otherwise null.
*/
function PostLastRevisionCheck( { children } ) {
const { lastRevisionId, revisionsCount } = useSelect( ( select ) => {
const { getCurrentPostLastRevisionId, getCurrentPostRevisionsCount } =
Expand Down
9 changes: 7 additions & 2 deletions packages/editor/src/components/post-last-revision/index.js
Expand Up @@ -13,7 +13,12 @@ import { addQueryArgs } from '@wordpress/url';
import PostLastRevisionCheck from './check';
import { store as editorStore } from '../../store';

function LastRevision() {
/**
* Renders the component for displaying the last revision of a post.
*
* @return {Component} The component to be rendered.
*/
function PostLastRevision() {
const { lastRevisionId, revisionsCount } = useSelect( ( select ) => {
const { getCurrentPostLastRevisionId, getCurrentPostRevisionsCount } =
select( editorStore );
Expand Down Expand Up @@ -42,4 +47,4 @@ function LastRevision() {
);
}

export default LastRevision;
export default PostLastRevision;
5 changes: 5 additions & 0 deletions packages/editor/src/components/post-last-revision/panel.js
Expand Up @@ -9,6 +9,11 @@ import { PanelBody } from '@wordpress/components';
import PostLastRevision from './';
import PostLastRevisionCheck from './check';

/**
* Renders the panel for displaying the last revision of a post.
*
* @return {Component} The component to be rendered.
*/
function PostLastRevisionPanel() {
return (
<PostLastRevisionCheck>
Expand Down