Skip to content

Commit

Permalink
Documentation: PostPendingStatus + PostPendingStatusCheck editor comp…
Browse files Browse the repository at this point in the history
…onents (WordPress#61970)

* Add PostPendingStatus editor component JSDocs

* Add PostPendingStatusCheck editor component JSDocs

* Auto-generate editor docs for PostPendingStatus additions

* Refine PostPendingStatusCheck component JSDocs

* Auto-generate editor docs for PostPendingStatusCheck updates
  • Loading branch information
colorful-tones authored and carstingaxion committed Jun 4, 2024
1 parent 4a70308 commit 8e9775d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
17 changes: 15 additions & 2 deletions packages/editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1113,11 +1113,24 @@ _Returns_

### PostPendingStatus

Undocumented declaration.
A component for displaying and toggling the pending status of a post.

_Returns_

- `JSX.Element`: The rendered component.

### PostPendingStatusCheck

Undocumented declaration.
This component checks the publishing status of the current post. If the post is already published or the user doesn't have the capability to publish, it returns null.

_Parameters_

- _props_ `Object`: Component properties.
- _props.children_ `Element`: Children to be rendered.

_Returns_

- `JSX.Element|null`: The rendered child elements or null if the post is already published or the user doesn't have the capability to publish.

### PostPingbacks

Expand Down
10 changes: 10 additions & 0 deletions packages/editor/src/components/post-pending-status/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ import { useSelect } from '@wordpress/data';
*/
import { store as editorStore } from '../../store';

/**
* This component checks the publishing status of the current post.
* If the post is already published or the user doesn't have the
* capability to publish, it returns null.
*
* @param {Object} props Component properties.
* @param {Element} props.children Children to be rendered.
*
* @return {JSX.Element|null} The rendered child elements or null if the post is already published or the user doesn't have the capability to publish.
*/
export function PostPendingStatusCheck( { children } ) {
const { hasPublishAction, isPublished } = useSelect( ( select ) => {
const { isCurrentPostPublished, getCurrentPost } =
Expand Down
5 changes: 5 additions & 0 deletions packages/editor/src/components/post-pending-status/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import { useDispatch, useSelect } from '@wordpress/data';
import PostPendingStatusCheck from './check';
import { store as editorStore } from '../../store';

/**
* A component for displaying and toggling the pending status of a post.
*
* @return {JSX.Element} The rendered component.
*/
export function PostPendingStatus() {
const status = useSelect(
( select ) => select( editorStore ).getEditedPostAttribute( 'status' ),
Expand Down

0 comments on commit 8e9775d

Please sign in to comment.