From dbafdbed72ca4f29df3714b6901fb8d338c79e80 Mon Sep 17 00:00:00 2001 From: sunil25393 Date: Fri, 26 Apr 2024 23:02:53 +0530 Subject: [PATCH] Added doc for PostLastRevision components --- packages/editor/README.md | 23 ++++++++++++++++--- .../components/post-last-revision/check.js | 8 +++++++ .../components/post-last-revision/index.js | 9 ++++++-- .../components/post-last-revision/panel.js | 5 ++++ 4 files changed, 40 insertions(+), 5 deletions(-) diff --git a/packages/editor/README.md b/packages/editor/README.md index 5c363c27058f36..ac5afeb35be588 100644 --- a/packages/editor/README.md +++ b/packages/editor/README.md @@ -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 diff --git a/packages/editor/src/components/post-last-revision/check.js b/packages/editor/src/components/post-last-revision/check.js index 44f96b9cf7acb0..c570f5e42cdc32 100644 --- a/packages/editor/src/components/post-last-revision/check.js +++ b/packages/editor/src/components/post-last-revision/check.js @@ -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 } = diff --git a/packages/editor/src/components/post-last-revision/index.js b/packages/editor/src/components/post-last-revision/index.js index e747befefe44e0..97031106772ada 100644 --- a/packages/editor/src/components/post-last-revision/index.js +++ b/packages/editor/src/components/post-last-revision/index.js @@ -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 ); @@ -42,4 +47,4 @@ function LastRevision() { ); } -export default LastRevision; +export default PostLastRevision; diff --git a/packages/editor/src/components/post-last-revision/panel.js b/packages/editor/src/components/post-last-revision/panel.js index de0aee0ab77503..e87475cc2b34e9 100644 --- a/packages/editor/src/components/post-last-revision/panel.js +++ b/packages/editor/src/components/post-last-revision/panel.js @@ -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 (