Skip to content

Commit

Permalink
Add JSDoc to PostVisibility, PostVisibilityCheck, and PostVisibilityL…
Browse files Browse the repository at this point in the history
…abel (#61735)

Co-authored-by: dbrian <bgosnell@git.wordpress.org>
Co-authored-by: colorful-tones <colorful-tones@git.wordpress.org>
Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org>
  • Loading branch information
4 people committed May 18, 2024
1 parent 7764796 commit 6398d34
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 4 deletions.
34 changes: 30 additions & 4 deletions packages/editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1184,15 +1184,37 @@ Undocumented declaration.

### PostVisibility

Undocumented declaration.
Allows users to set the visibility of a post.

_Parameters_

- _props_ `Object`: The component props.
- _props.onClose_ `Function`: Function to call when the popover is closed.

_Returns_

- `JSX.Element`: The rendered component.

### PostVisibilityCheck

Undocumented declaration.
Determines if the current post can be edited (published) and passes this information to the provided render function.

_Parameters_

- _props_ `Object`: The component props.
- _props.render_ `Function`: Function to render the component. Receives an object with a `canEdit` property.

_Returns_

- `JSX.Element`: The rendered component.

### PostVisibilityLabel

Undocumented declaration.
Returns the label for the current post visibility setting.

_Returns_

- `string`: Post visibility label.

### privateApis

Expand Down Expand Up @@ -1305,7 +1327,11 @@ Undocumented declaration.

### usePostVisibilityLabel

Undocumented declaration.
Get the label for the current post visibility setting.

_Returns_

- `string`: Post visibility label.

### userAutocompleter

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

/**
* Determines if the current post can be edited (published)
* and passes this information to the provided render function.
*
* @param {Object} props The component props.
* @param {Function} props.render Function to render the component.
* Receives an object with a `canEdit` property.
* @return {JSX.Element} The rendered component.
*/
export default function PostVisibilityCheck( { render } ) {
const canEdit = useSelect( ( select ) => {
return (
Expand Down
7 changes: 7 additions & 0 deletions packages/editor/src/components/post-visibility/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ import { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '
import { visibilityOptions } from './utils';
import { store as editorStore } from '../../store';

/**
* Allows users to set the visibility of a post.
*
* @param {Object} props The component props.
* @param {Function} props.onClose Function to call when the popover is closed.
* @return {JSX.Element} The rendered component.
*/
export default function PostVisibility( { onClose } ) {
const instanceId = useInstanceId( PostVisibility );

Expand Down
10 changes: 10 additions & 0 deletions packages/editor/src/components/post-visibility/label.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,20 @@ import { useSelect } from '@wordpress/data';
import { visibilityOptions } from './utils';
import { store as editorStore } from '../../store';

/**
* Returns the label for the current post visibility setting.
*
* @return {string} Post visibility label.
*/
export default function PostVisibilityLabel() {
return usePostVisibilityLabel();
}

/**
* Get the label for the current post visibility setting.
*
* @return {string} Post visibility label.
*/
export function usePostVisibilityLabel() {
const visibility = useSelect( ( select ) =>
select( editorStore ).getEditedPostVisibility()
Expand Down

0 comments on commit 6398d34

Please sign in to comment.