Skip to content

Commit

Permalink
Added doc for PostLastRevision components (WordPress#61166)
Browse files Browse the repository at this point in the history
  • Loading branch information
akasunil authored and carstingaxion committed Jun 4, 2024
1 parent 6d1b7ad commit d58c117
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 5 deletions.
23 changes: 20 additions & 3 deletions packages/editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1047,15 +1047,32 @@ _Returns_

### 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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit d58c117

Please sign in to comment.