From b0a1429a2943b677cd67e492b63eebbc696d1d3e Mon Sep 17 00:00:00 2001 From: Sunil Prajapati <61308756+sunil25393@users.noreply.github.com> Date: Fri, 26 Apr 2024 18:23:18 +0530 Subject: [PATCH] Add documentation for PostAuthor, PostAuthorCheck, PostAuthorPanel components (#61090) Co-authored-by: sunil25393 Co-authored-by: youknowriad --- packages/editor/README.md | 23 ++++++++++++++++--- .../src/components/post-author/check.js | 9 ++++++++ .../src/components/post-author/index.js | 5 ++++ .../src/components/post-author/panel.js | 5 ++++ 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/packages/editor/README.md b/packages/editor/README.md index 7e81e4ec8d810..673d3d100a956 100644 --- a/packages/editor/README.md +++ b/packages/editor/README.md @@ -869,15 +869,32 @@ _Returns_ ### PostAuthor -Undocumented declaration. +Renders the component for selecting the post author. + +_Returns_ + +- `Component`: The component to be rendered. ### PostAuthorCheck -Undocumented declaration. +Wrapper component that renders its children only if the post type supports the author. + +_Parameters_ + +- _props_ `Object`: The component props. +- _props.children_ `Element`: Children to be rendered. + +_Returns_ + +- `Component|null`: The component to be rendered. Return `null` if the post type doesn't supports the author or if there are no authors available. ### PostAuthorPanel -Undocumented declaration. +Renders the Post Author Panel component. + +_Returns_ + +- `Component`: The component to be rendered. ### PostComments diff --git a/packages/editor/src/components/post-author/check.js b/packages/editor/src/components/post-author/check.js index ecda9e149b4ed..d10a0a2ccf0bd 100644 --- a/packages/editor/src/components/post-author/check.js +++ b/packages/editor/src/components/post-author/check.js @@ -11,6 +11,15 @@ import PostTypeSupportCheck from '../post-type-support-check'; import { store as editorStore } from '../../store'; import { AUTHORS_QUERY } from './constants'; +/** + * Wrapper component that renders its children only if the post type supports the author. + * + * @param {Object} props The component props. + * @param {Element} props.children Children to be rendered. + * + * @return {Component|null} The component to be rendered. Return `null` if the post type doesn't + * supports the author or if there are no authors available. + */ export default function PostAuthorCheck( { children } ) { const { hasAssignAuthorAction, hasAuthors } = useSelect( ( select ) => { const post = select( editorStore ).getCurrentPost(); diff --git a/packages/editor/src/components/post-author/index.js b/packages/editor/src/components/post-author/index.js index 7e734379f64f6..9ff3aaaf09a29 100644 --- a/packages/editor/src/components/post-author/index.js +++ b/packages/editor/src/components/post-author/index.js @@ -13,6 +13,11 @@ import { AUTHORS_QUERY } from './constants'; const minimumUsersForCombobox = 25; +/** + * Renders the component for selecting the post author. + * + * @return {Component} The component to be rendered. + */ function PostAuthor() { const showCombobox = useSelect( ( select ) => { const authors = select( coreStore ).getUsers( AUTHORS_QUERY ); diff --git a/packages/editor/src/components/post-author/panel.js b/packages/editor/src/components/post-author/panel.js index 78f0e0a5f2cc8..ad2aa01dee3ab 100644 --- a/packages/editor/src/components/post-author/panel.js +++ b/packages/editor/src/components/post-author/panel.js @@ -5,6 +5,11 @@ import PostAuthorCheck from './check'; import PostAuthorForm from './index'; import PostPanelRow from '../post-panel-row'; +/** + * Renders the Post Author Panel component. + * + * @return {Component} The component to be rendered. + */ export function PostAuthor() { return (