Skip to content

Commit

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

Co-authored-by: sunil25393 <[email protected]>
Co-authored-by: youknowriad <[email protected]>
  • Loading branch information
3 people authored Apr 26, 2024
1 parent 7846a1a commit 6a0120b
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

1 comment on commit 6a0120b

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 6a0120b.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/8848577519
📝 Reported issues:

Please sign in to comment.