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 PostAuthor, PostAuthorCheck, PostAuthorPanel components #61090

Merged
merged 2 commits into from
Apr 26, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions packages/editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -801,15 +801,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
Loading