Skip to content

Commit

Permalink
Post fields: move comment_status from edit-site to fields packa…
Browse files Browse the repository at this point in the history
…ge (WordPress#66934)

Co-authored-by: oandregal <oandregal@git.wordpress.org>
Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
  • Loading branch information
3 people authored and karthick-murugan committed Nov 13, 2024
1 parent 5625cf1 commit 2844f0e
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 26 deletions.
28 changes: 2 additions & 26 deletions packages/edit-site/src/components/post-fields/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
parentField,
passwordField,
statusField,
commentStatusField,
} from '@wordpress/fields';
import {
createInterpolateElement,
Expand Down Expand Up @@ -230,32 +231,7 @@ function usePostFields() {
},
slugField,
parentField,
{
id: 'comment_status',
label: __( 'Discussion' ),
type: 'text',
Edit: 'radio',
enableSorting: false,
filterBy: {
operators: [],
},
elements: [
{
value: 'open',
label: __( 'Open' ),
description: __(
'Visitors can add new comments and replies.'
),
},
{
value: 'closed',
label: __( 'Closed' ),
description: __(
'Visitors cannot add new comments or replies. Existing comments remain visible.'
),
},
],
},
commentStatusField,
passwordField,
],
[ authors, frontPageId, postsPageId ]
Expand Down
4 changes: 4 additions & 0 deletions packages/fields/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ npm install @wordpress/fields --save

<!-- START TOKEN(Autogenerated API docs) -->

### commentStatusField

Comment status field for BasePost.

### deletePost

Undocumented declaration.
Expand Down
40 changes: 40 additions & 0 deletions packages/fields/src/fields/comment-status/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* WordPress dependencies
*/
import type { Field } from '@wordpress/dataviews';
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import type { BasePost } from '../../types';

const commentStatusField: Field< BasePost > = {
id: 'comment_status',
label: __( 'Discussion' ),
type: 'text',
Edit: 'radio',
enableSorting: false,
filterBy: {
operators: [],
},
elements: [
{
value: 'open',
label: __( 'Open' ),
description: __( 'Visitors can add new comments and replies.' ),
},
{
value: 'closed',
label: __( 'Closed' ),
description: __(
'Visitors cannot add new comments or replies. Existing comments remain visible.'
),
},
],
};

/**
* Comment status field for BasePost.
*/
export default commentStatusField;
1 change: 1 addition & 0 deletions packages/fields/src/fields/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export { default as featuredImageField } from './featured-image';
export { default as parentField } from './parent';
export { default as passwordField } from './password';
export { default as statusField } from './status';
export { default as commentStatusField } from './comment-status';

0 comments on commit 2844f0e

Please sign in to comment.