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

QuickEdit: Add Parent field #66527

Merged
merged 9 commits into from
Oct 30, 2024
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
3 changes: 2 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/edit-site/src/components/post-edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ function PostEditForm( { postType, postId } ) {
'author',
'date',
'slug',
'parent',
'comment_status',
],
};
Expand Down
3 changes: 2 additions & 1 deletion packages/edit-site/src/components/post-fields/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import clsx from 'clsx';
*/
import { __, sprintf } from '@wordpress/i18n';
import { decodeEntities } from '@wordpress/html-entities';
import { featuredImageField, slugField } from '@wordpress/fields';
import { featuredImageField, slugField, parentField } from '@wordpress/fields';
import {
createInterpolateElement,
useMemo,
Expand Down Expand Up @@ -321,6 +321,7 @@ function usePostFields( viewType ) {
},
},
slugField,
parentField,
{
id: 'comment_status',
label: __( 'Discussion' ),
Expand Down
4 changes: 4 additions & 0 deletions packages/fields/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ Undocumented declaration.

Undocumented declaration.

### parentField

This field is used to display the post parent.

### permanentlyDeletePost

Undocumented declaration.
Expand Down
3 changes: 2 additions & 1 deletion packages/fields/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
"@wordpress/url": "*",
"@wordpress/warning": "*",
"change-case": "4.1.2",
"client-zip": "^2.4.5"
"client-zip": "^2.4.5",
"remove-accents": "^0.5.0"
},
"peerDependencies": {
"react": "^18.0.0"
Expand Down
1 change: 1 addition & 0 deletions packages/fields/src/fields/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export { default as slugField } from './slug';
export { default as titleField } from './title';
export { default as orderField } from './order';
export { default as featuredImageField } from './featured-image';
export { default as parentField } from './parent';
27 changes: 27 additions & 0 deletions packages/fields/src/fields/parent/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* WordPress dependencies
*/
import type { Field } from '@wordpress/dataviews';

/**
* Internal dependencies
*/
import type { BasePost } from '../../types';
import { __ } from '@wordpress/i18n';
import { ParentEdit } from './parent-edit';
import { ParentView } from './parent-view';

const parentField: Field< BasePost > = {
id: 'parent',
type: 'text',
label: __( 'Parent' ),
getValue: ( { item } ) => item.parent,
Edit: ParentEdit,
render: ParentView,
enableSorting: true,
};

/**
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for documenting it (README) :)

* This field is used to display the post parent.
*/
export default parentField;
Loading
Loading