-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Consolidate and fix delete
and edit
post actions
#61912
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: -494 B (-0.03%) Total Size: 1.74 MB
ℹ️ View Unchanged
|
Flaky tests detected in 2278e5f. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9211373676
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I've tested, everything is working as expected.
One slight concern is that the "Move to Trash" has been changed to "Delete" in posts and pages. Some users may be confused as to whether the new "Delete" text, which previously read "Move to Trash," means "Move to Trash" or "Delete Permanently".
By the way, a "Delete Permanently" action may be added in the future, right?
There is one already, but the only way to access that action is through the pages list in |
I agree, this may be confusing. Deleting a post doesn't actually delete it, but moves it to the trash where it may be recovered; I do think that's an important distinction. For items that cannot be recovered, "Delete" is fine, but for items that can be, I think using "Move to Trash" is expected. |
It seems there is no correlation between the ability to trash posts and how the post type is registered, so I'll keep two separate actions for now. One for template, patterns and template parts, and one for all other posts. |
f2b1139
to
ddc727c
Compare
@@ -202,7 +313,7 @@ const trashPostAction = { | |||
disabled={ isBusy } | |||
__experimentalIsFocusable | |||
> | |||
{ __( 'Delete' ) } | |||
{ __( 'Trash' ) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worked well on my tests 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing well for me as well ✅
Co-authored-by: ntsekouras <[email protected]> Co-authored-by: youknowriad <[email protected]> Co-authored-by: t-hamano <[email protected]> Co-authored-by: jorgefilipecosta <[email protected]> Co-authored-by: Mamaduka <[email protected]> Co-authored-by: richtabor <[email protected]>
Co-authored-by: ntsekouras <[email protected]> Co-authored-by: youknowriad <[email protected]> Co-authored-by: t-hamano <[email protected]> Co-authored-by: jorgefilipecosta <[email protected]> Co-authored-by: Mamaduka <[email protected]> Co-authored-by: richtabor <[email protected]>
TEMPLATE_ORIGINS.custom | ||
) && | ||
! template.has_theme_file && | ||
! template.templatePart?.has_theme_file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why the template part object is actually template.templatePart and not just template?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In patterns list page we map the templates parts to a different object than the one returned from the endpoint. This is why we need to check two props.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we avoid mapping and just return the right objects?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I encountered the same issue when fixing a bug for the "Reset" action - #62951. The fact that action might receive differently shaped objects when viewing a single or list of entities can be confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fixing that in #62927
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we avoid mapping and just return the right objects?
Probably.. I hadn't implemented that and will check your PR @youknowriad
What?
Part of: #61787
Similar to: #61857
This PR does two things:
edit
action in site editor to be shown only in user patterns.delete
post action and keep onedelete
action for templates, template parts and patterns, and onemove to trash
action for the rest post types.Notes
I've updated the messages when removing a template, template part, pattern to have the generic
item
label, to simplify the logic there. For single item deletions nothing changes because we use the name of the item. It changes though for multiple items and for example theAn error occurred while deleting the templates.
is nowAn error occurred while deleting the items.
Testing Instructions
patterns, pages and templates
. In patterns it should be shown only for user created patterns and all template parts