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

Documentation: PostPendingStatus + PostPendingStatusCheck editor components #61970

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
17 changes: 15 additions & 2 deletions packages/editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1105,11 +1105,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
Loading