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

improve documentation for fields package #67580

Merged
merged 1 commit into from
Dec 5, 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
56 changes: 20 additions & 36 deletions packages/fields/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,107 +41,91 @@ Date field for BasePost.

### deletePost

Undocumented declaration.
Delete action for Templates, Patterns and Template Parts.

### duplicatePattern

Undocumented declaration.
Duplicate action for Pattern.

### duplicatePost

Undocumented declaration.

### duplicatePostNative

Undocumented declaration.
Duplicate action for BasePost.

### duplicateTemplatePart

This action is used to duplicate a template part.

_Type_

- `Action< TemplatePart >`
Duplicate action for TemplatePart.

### exportPattern

Undocumented declaration.

### exportPatternNative

Undocumented declaration.
Export action as JSON for Pattern.

### featuredImageField

Undocumented declaration.
Featured Image field for BasePost.

### orderField

Undocumented declaration.
Order field for BasePost.

### parentField

This field is used to display the post parent.
Parent field for BasePost.

### passwordField

This field is used to display the post password.
Password field for BasePost.

### permanentlyDeletePost

Undocumented declaration.
Delete action for PostWithPermissions.

### PostType

Undocumented declaration.

### renamePost

Undocumented declaration.
Rename action for PostWithPermissions.

### reorderPage

Undocumented declaration.

### reorderPageNative

Undocumented declaration.
Reorder action for BasePost.

### resetPost

Undocumented declaration.
Reset action for Template and TemplatePart.

### restorePost

Undocumented declaration.
Restore action for PostWithPermissions.

### slugField

Undocumented declaration.
Slug field for BasePost.

### statusField

Status field for BasePost.

### templateField

Undocumented declaration.
Template field for BasePost.

### titleField

Undocumented declaration.
Title field for BasePost.

### trashPost

Undocumented declaration.
Trash action for PostWithPermissions.

### viewPost

Undocumented declaration.
View post action for BasePost.

### viewPostRevisions

Undocumented declaration.
View post revisions action for Post.

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

Expand Down
3 changes: 3 additions & 0 deletions packages/fields/src/actions/delete-post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,7 @@ const deletePostAction: Action< Template | TemplatePart | Pattern > = {
},
};

/**
* Delete action for Templates, Patterns and Template Parts.
*/
export default deletePostAction;
3 changes: 3 additions & 0 deletions packages/fields/src/actions/duplicate-pattern.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@ const duplicatePattern: Action< Pattern > = {
},
};

/**
* Duplicate action for Pattern.
*/
export default duplicatePattern;
3 changes: 0 additions & 3 deletions packages/fields/src/actions/duplicate-post.native.tsx

This file was deleted.

9 changes: 6 additions & 3 deletions packages/fields/src/actions/duplicate-post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ const duplicatePost: Action< BasePost > = {
const [ item, setItem ] = useState< BasePost >( {
...items[ 0 ],
title: sprintf(
/* translators: %s: Existing template title */
Copy link
Member

Choose a reason for hiding this comment

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

Nice catch, thanks! We actually hide this action for templates.

_x( '%s (Copy)', 'template' ),
/* translators: %s: Existing post title */
_x( '%s (Copy)', 'post' ),
getItemTitle( items[ 0 ] )
),
} );
Expand Down Expand Up @@ -104,7 +104,7 @@ const duplicatePost: Action< BasePost > = {

createSuccessNotice(
sprintf(
// translators: %s: Title of the created post or template, e.g: "Hello world".
// translators: %s: Title of the created post, e.g: "Hello world".
__( '"%s" successfully created.' ),
decodeEntities( newItem.title?.rendered || item.title )
),
Expand Down Expand Up @@ -171,4 +171,7 @@ const duplicatePost: Action< BasePost > = {
},
};

/**
* Duplicate action for BasePost.
*/
export default duplicatePost;
4 changes: 3 additions & 1 deletion packages/fields/src/actions/duplicate-template-part.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,7 @@ const duplicateTemplatePart: Action< TemplatePart > = {
);
},
};

/**
* Duplicate action for TemplatePart.
*/
export default duplicateTemplatePart;
3 changes: 0 additions & 3 deletions packages/fields/src/actions/export-pattern.native.tsx

This file was deleted.

3 changes: 3 additions & 0 deletions packages/fields/src/actions/export-pattern.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,7 @@ const exportPattern: Action< Pattern > = {
},
};

/**
* Export action as JSON for Pattern.
*/
export default exportPattern;
3 changes: 0 additions & 3 deletions packages/fields/src/actions/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
export { default as viewPost } from './view-post';
export { default as reorderPage } from './reorder-page';
export { default as reorderPageNative } from './reorder-page.native';
Copy link
Member

Choose a reason for hiding this comment

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

@dcalhoun sorry to ping you so many times lately :)

Is it ok to remove the native actions here? They export undefined (reorder), export pattern, duplicate post, so we wonder why are they necessary?

Copy link
Contributor

Choose a reason for hiding this comment

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

Mostly to make unit tests pass. If nothing breaks, it's ok to remove IMO

Copy link
Member

Choose a reason for hiding this comment

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

I'll concede to @youknowriad's knowledge on this one. It appears the addition occurred in 94d1d2b to repair unit test failures. I agree it is safe to remove if unit tests continue passing.

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 the confirmation to both of you 🙇

export { default as duplicatePost } from './duplicate-post';
export { default as duplicatePostNative } from './duplicate-post.native';
export { default as renamePost } from './rename-post';
export { default as resetPost } from './reset-post';
export { default as duplicatePattern } from './duplicate-pattern';
export { default as exportPattern } from './export-pattern';
export { default as exportPatternNative } from './export-pattern.native';
export { default as viewPostRevisions } from './view-post-revisions';
export { default as permanentlyDeletePost } from './permanently-delete-post';
export { default as restorePost } from './restore-post';
Expand Down
3 changes: 3 additions & 0 deletions packages/fields/src/actions/permanently-delete-post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,7 @@ const permanentlyDeletePost: Action< PostWithPermissions > = {
},
};

/**
* Delete action for PostWithPermissions.
*/
export default permanentlyDeletePost;
3 changes: 3 additions & 0 deletions packages/fields/src/actions/rename-post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,7 @@ const renamePost: Action< PostWithPermissions > = {
},
};

/**
* Rename action for PostWithPermissions.
*/
export default renamePost;
3 changes: 0 additions & 3 deletions packages/fields/src/actions/reorder-page.native.tsx

This file was deleted.

3 changes: 3 additions & 0 deletions packages/fields/src/actions/reorder-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,7 @@ const reorderPage: Action< BasePost > = {
RenderModal: ReorderModal,
};

/**
* Reorder action for BasePost.
*/
export default reorderPage;
3 changes: 3 additions & 0 deletions packages/fields/src/actions/reset-post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -292,4 +292,7 @@ const resetPostAction: Action< Template | TemplatePart > = {
},
};

/**
* Reset action for Template and TemplatePart.
*/
export default resetPostAction;
3 changes: 3 additions & 0 deletions packages/fields/src/actions/restore-post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,7 @@ const restorePost: Action< PostWithPermissions > = {
},
};

/**
* Restore action for PostWithPermissions.
*/
export default restorePost;
3 changes: 3 additions & 0 deletions packages/fields/src/actions/trash-post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,7 @@ const trashPost: Action< PostWithPermissions > = {
},
};

/**
* Trash action for PostWithPermissions.
*/
export default trashPost;
3 changes: 3 additions & 0 deletions packages/fields/src/actions/view-post-revisions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,7 @@ const viewPostRevisions: Action< Post > = {
},
};

/**
* View post revisions action for Post.
*/
export default viewPostRevisions;
3 changes: 3 additions & 0 deletions packages/fields/src/actions/view-post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,7 @@ const viewPost: Action< BasePost > = {
},
};

/**
* View post action for BasePost.
*/
export default viewPost;
3 changes: 3 additions & 0 deletions packages/fields/src/fields/featured-image/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ const featuredImageField: Field< BasePost > = {
enableSorting: false,
};

/**
* Featured Image field for BasePost.
*/
export default featuredImageField;
3 changes: 3 additions & 0 deletions packages/fields/src/fields/order/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ const orderField: Field< BasePost > = {
description: __( 'Determines the order of pages.' ),
};

/**
* Order field for BasePost.
*/
export default orderField;
2 changes: 1 addition & 1 deletion packages/fields/src/fields/parent/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ const parentField: Field< BasePost > = {
};

/**
* This field is used to display the post parent.
* Parent field for BasePost.
*/
export default parentField;
2 changes: 1 addition & 1 deletion packages/fields/src/fields/password/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ const passwordField: Field< BasePost > = {
};

/**
* This field is used to display the post password.
* Password field for BasePost.
*/
export default passwordField;
3 changes: 3 additions & 0 deletions packages/fields/src/fields/slug/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ const slugField: Field< BasePost > = {
render: SlugView,
};

/**
* Slug field for BasePost.
*/
export default slugField;
4 changes: 3 additions & 1 deletion packages/fields/src/fields/template/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ const templateField: Field< BasePost > = {
id: 'template',
type: 'text',
label: __( 'Template' ),
getValue: ( { item } ) => item.template,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not necessary. I removed it. #66591 (comment)

Edit: TemplateEdit,
enableSorting: false,
};

/**
* Template field for BasePost.
*/
export default templateField;
3 changes: 3 additions & 0 deletions packages/fields/src/fields/title/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ const titleField: Field< BasePost > = {
enableHiding: false,
};

/**
* Title field for BasePost.
*/
export default titleField;
2 changes: 0 additions & 2 deletions packages/fields/src/index.native.ts
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
export * from './actions/duplicate-post.native';
export * from './actions/reorder-page.native';
Loading