Repository navigation
DataViews: Update template parts view - #57952
Conversation
|
Size Change: -257 B (0%) Total Size: 1.7 MB
ℹ️ View Unchanged
|
c254161 to
1c2ddaa
Compare
| }, | ||
| }; | ||
| if ( item.type === TEMPLATE_PART_POST_TYPE ) { | ||
| linkProps.state = { |
There was a problem hiding this comment.
I haven't seen this in use, what is it for? I presume it's for setting the path in case the users click the browser's back button after they've gone to the editor by clicking the title. Is this correct? If so, why templates don't need this?
| isTemplateRemovable( template ) && template.is_custom, | ||
| isEligible: ( template ) => { | ||
| if ( | ||
| ! isTemplateRemovable( template ) || |
There was a problem hiding this comment.
I found this logic difficult to grok. What would you think of rewriting it by stating the conditions for each post type independently? Something along these lines could work:
if (
template.type === TEMPLATE_PART_POST_TYPE &&
isTemplateRemovable( template )
) {
return true;
}
if (
template.type === TEMPLATE_POST_TYPE &&
isTemplateRemovable( template) &&
template.is_custom
) {
return true;
}
return false;| } else { | ||
| successMessage = __( 'Templates deleted.' ); | ||
| successMessage = isTemplate | ||
| ? __( 'Templates deleted.' ) |
There was a problem hiding this comment.
I've mentioned this elsewhere, but I think we could do with using a generic language. For example, Items deleted..
The users already have the context of what they are – they know whether they are working with templates or template parts, don't need reminding. And this code would be a lot simpler.
I don't have a strong opposition to doing it this way, and it works fine. I just want to share an alternative that I find clearer for everyone.
There was a problem hiding this comment.
I agree with this and would need less code :). Le't handle this in a follow up though because others might chip in about the clarity of the messages and wouldn't want to block this PR for that.
e7c4350 to
ce2a55b
Compare
ce2a55b to
3cd08ff
Compare


What?
Part of: #55083
This PR updates the template parts list in site editor to use DataViews. Since templates and template parts have almost identical handling I've created a thin DataViews wrapper for both and most changes are checks about the type to use some different labels.
Testing Instructions
Screenshots or screencast
Screen.Recording.2024-01-18.at.12.09.35.PM.mov