Skip to content

Commit

Permalink
Add documentation for PostAuthor, PostAuthorCheck, PostAuthorPanel co…
Browse files Browse the repository at this point in the history
…mponents (WordPress#61090)

Co-authored-by: sunil25393 <[email protected]>
Co-authored-by: youknowriad <[email protected]>
  • Loading branch information
3 people authored and huubl committed Apr 26, 2024
1 parent 9f0a83a commit b0a1429
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
23 changes: 20 additions & 3 deletions packages/editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 9 additions & 0 deletions packages/editor/src/components/post-author/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 5 additions & 0 deletions packages/editor/src/components/post-author/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
5 changes: 5 additions & 0 deletions packages/editor/src/components/post-author/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<PostAuthorCheck>
Expand Down

0 comments on commit b0a1429

Please sign in to comment.