Conversation
|
Size Change: +20 B (0%) Total Size: 1.44 MB
ℹ️ View Unchanged
|
|
Thanks for the review, @aaronrobertshaw! |
|
@t-hamano it might be easier (for testing) if we fix the snackbar notice in this PR as well. What do you think? There are a couple of potential options:
Option 1 - Example diffdiff --git a/packages/edit-site/src/store/actions.js b/packages/edit-site/src/store/actions.js
index 8da362ca01..e65eacfc73 100644
--- a/packages/edit-site/src/store/actions.js
+++ b/packages/edit-site/src/store/actions.js
@@ -141,11 +141,18 @@ export const removeTemplate =
throw lastError;
}
+ // Depending on how the entity was retrieved it's title might be
+ // an object or simple string.
+ const templateTitle =
+ typeof template.title === 'string'
+ ? template.title
+ : template.title.rendered;
+
registry.dispatch( noticesStore ).createSuccessNotice(
sprintf(
/* translators: The template/part's name. */
__( '"%s" deleted.' ),
- decodeEntities( template.title.rendered )
+ decodeEntities( templateTitle )
),
{ type: 'snackbar', id: 'site-editor-template-deleted-success' }
);
Option 2 - Example diffdiff --git a/packages/edit-site/src/components/template-actions/index.js b/packages/edit-site/src/components/template-actions/index.js
index 0b54d6ef3e..81e1cc970e 100644
--- a/packages/edit-site/src/components/template-actions/index.js
+++ b/packages/edit-site/src/components/template-actions/index.js
@@ -88,7 +88,11 @@ export default function TemplateActions( {
isDestructive
isTertiary
onClick={ () => {
- removeTemplate( template );
+ removeTemplate( {
+ title: template.title.rendered,
+ id: template.id,
+ type: template.type,
+ } );
onRemove?.();
onClose();
} }
diff --git a/packages/edit-site/src/store/actions.js b/packages/edit-site/src/store/actions.js
index 8da362ca01..8b397cb265 100644
--- a/packages/edit-site/src/store/actions.js
+++ b/packages/edit-site/src/store/actions.js
@@ -120,12 +120,12 @@ export const addTemplate =
* @param {Object} template The template object.
*/
export const removeTemplate =
- ( template ) =>
+ ( { title, type, id } ) =>
async ( { registry } ) => {
try {
await registry
.dispatch( coreStore )
- .deleteEntityRecord( 'postType', template.type, template.id, {
+ .deleteEntityRecord( 'postType', type, id, {
force: true,
} );
@@ -133,8 +133,8 @@ export const removeTemplate =
.select( coreStore )
.getLastEntityDeleteError(
'postType',
- template.type,
- template.id
+ type,
+ id
);
if ( lastError ) {
@@ -145,7 +145,7 @@ export const removeTemplate =
sprintf(
/* translators: The template/part's name. */
__( '"%s" deleted.' ),
- decodeEntities( template.title.rendered )
+ decodeEntities( title )
),
{ type: 'snackbar', id: 'site-editor-template-deleted-success' }
);
I don't have strong feelings towards either option, so am open to better ideas. If I had to pick, I'm leaning toward the simpler option 1 so as to not alter the signature for |
|
Thanks for the advice, @aaronrobertshaw!
I also prefer the first option. I think the reason the title property type is different is because the template to be deleted is retrieved by either I believe both delete from Llist and delete from Command Palette are working as expected. 069f03bf5fd5b2330b48aaae57a3612c.mp4 |
| const templateTitle = | ||
| typeof template.title === 'string' | ||
| ? template.title | ||
| : template.title?.rendered; |
There was a problem hiding this comment.
I put ? just in case. This implementation is also done in the following locations:
gutenberg/packages/editor/src/store/selectors.js
Line 1611 in 3fd16c0
|
Flaky tests detected in 5b30f82. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5412686374
|
aaronrobertshaw
left a comment
There was a problem hiding this comment.
Thank you for iterating on this @t-hamano 🙇
✅ Deleting templates from Templates page works and correct snackbar notice displayed
✅ Deleting templates from command palette works as expected
✅ Deleting from Template Parts page works and correct snackbar notice displayed
✅ Deleting template parts from command palette works
|
Thanks for the review, @aaronrobertshaw! I would like to add what I have done additionally in this PR to the commit message and merge it in. |
…e part is deleted (#52034) * Command Center: Fix incorrect navigation when deleting template part * removeTemplate: consider title type
|
I just cherry-picked this PR to the update/wp6-3-beta3 branch to get it included in the next release: d739511 |
* Footnotes: inscrease selector specificity for anchor (#52179) * Patterns: Include template parts for custom areas in Uncategorized category (#52159) * Fix custom patterns console error (#51947) * Fix error with react list key with new custom patterns list in inserter * Update placeholder key * Add comment to explain the different keys * Patterns: Fix missing custom patterns in patterns explorer (#51889) * Add custom patterns to pattern explorer * show custom patterns in the patterns explorer dialog * remove changes from 51877 * Fix up use of async lists * remove a bit of code duplication by adding a new hook * add 51877 fix back to make testing easier * Just assign the key value in one place * Refactor the custom patterns to use the usePatternsState hook * Fix use of async list * Translate strings and remove unneeded fields from pattern object * Try integrating unsynced patterns directly into pattern selectors (#51955) * Include reusable blocks with an undefined sync status in inserter items * Update docs * Remove change to hover dependencies --------- Co-authored-by: Daniel Richards <daniel.richards@automattic.com> * i18n: Add context to the word "Filters" (#52198) * Update home template icon (#52075) * Centralise all permissions lookup in Link UI and enable (#52166) * BlockRemovalWarningModal: Fix incorrect '_n' usage (#52164) * Fix fetching Nav fallback ID flushing Navigation entity cache (#52069) * Only flush the `getEntityRecords` cache if the fallback isn’t already in state * Save the edited entity record to a const and then invert it to determine whether we should invalidate the recordds --------- Co-authored-by: scruffian <ben@scruffian.com> * Block Editor: Unify texts for Create pattern modal (#52151) * Fix history back after entering edit mode from Patterns (#52112) * Add template part icons to the library grid items (#51963) * Patterns: Fix sidebar tab label (#51953) * Patterns: Fix setting of sync status for fully synced patterns (#51952) * Library: Reinstate manage all template parts page (#51961) * Command Palette: fix incorrect path and snackbar message when template part is deleted (#52034) * Command Center: Fix incorrect navigation when deleting template part * removeTemplate: consider title type * Drop-indicator: remove white border. (#52122) * Make Navigation fallback selector private (#51413) * Move selector to become private * adds basic lock functionality * remove useless lock-unlock file * map private selectors to resolvers * Unlock the other usage * only create one fallback per session * Fix core-data duplicate private opt-in * Data: bind resolvers to selectors individually, support private selectors --------- Co-authored-by: Andrei Draganescu <andrei.draganescu@automattic.com> Co-authored-by: scruffian <ben@scruffian.com> Co-authored-by: Jarda Snajdr <jsnajdr@gmail.com> * Focus Mode: Use the symbol icon if a pattern is being edited (#52031) * Footnotes: register meta field for pages (#52024) * Fix unintentional toggling on of distraction free (#52090) * replace toggle with set preference - because I don't read code properly it seems * remove notification * Revert "Updating social link attributes (#51997)" (#52019) This reverts commit c711e2a. * Update home template name (#52048) * Removes unused call (#51988) * Remove ability for user to toggle sync status after pattern creation (#51998) * Fix disable DFM when opening styles command (#52165) * Update custom patterns label to 'My patterns' (#51949) * rename custom patterns to my patterns * Add my patterns label to inserter and show at the top --------- Co-authored-by: Daniel Richards <daniel.richards@automattic.com> * Library: Add sync status to pattern details screen (#51954) * Patterns: Rename Library to Patterns (#52102) * [Library] Add lock icon for theme patterns (#51990) * Add lock icon for theme patterns * Change to class names * Add aria-description * Change wording * Patterns: Use "detached" copy consistently (#51993) * Editor initrial appender: Zero out margins in constrained layouts. (#52026) * Update pattern creation modal in library (#51946) * Fix missing snackbars in Library (#52021) * Make the entire preview clickable in order to enter "edit" mode in focus mode (#51973) * Page Content Focus: Add welcome guides (#52014) * Page Content Focus: Add welcome guides * Don't show when editor guide is active * Just use regular accent/theme color in all guides * slight copy change page guide * Update components changelog * Disable new guides in E2E tests * Use s.w.org videos --------- Co-authored-by: Saxon Fletcher <saxonafletcher@gmail.com> --------- Co-authored-by: Ella <4710635+ellatrix@users.noreply.github.com> Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> Co-authored-by: Glen Davies <glendaviesnz@users.noreply.github.com> Co-authored-by: Daniel Richards <daniel.richards@automattic.com> Co-authored-by: Aki Hamano <54422211+t-hamano@users.noreply.github.com> Co-authored-by: James Koster <james@jameskoster.co.uk> Co-authored-by: Dave Smith <getdavemail@gmail.com> Co-authored-by: George Mamadashvili <georgemamadashvili@gmail.com> Co-authored-by: scruffian <ben@scruffian.com> Co-authored-by: Kai Hao <kevin830726@gmail.com> Co-authored-by: Carolina Nymark <myazalea@hotmail.com> Co-authored-by: Joen A <1204802+jasmussen@users.noreply.github.com> Co-authored-by: Andrei Draganescu <andrei.draganescu@automattic.com> Co-authored-by: Jarda Snajdr <jsnajdr@gmail.com> Co-authored-by: Andrei Draganescu <me@andreidraganescu.info> Co-authored-by: Ramon <ramonjd@users.noreply.github.com> Co-authored-by: Nik Tsekouras <ntsekouras@outlook.com> Co-authored-by: Saxon Fletcher <saxonafletcher@gmail.com> Co-authored-by: Rich Tabor <hi@richtabor.com> Co-authored-by: Robert Anderson <robert@noisysocks.com>
Fixes: #52023
What?
This PR moves you to the Template Parts List page when you delete a template part via Command Palette.
Why?
When you delete a template part from the Command Palette, the destination
pathiswp_template_part. However, with the introduction of Library page in the latest Gutenberg, the following page do not exist.How?
I have changed the path so that when a template part is deleted, it goes to the Template Parts List page (
wp_template_part/all).Another idea might be the Library page.
Testing Instructions
Note: The snackbar shows
"undefined" deleted, but this issue has already been reported on #51969.Screenshots or screencast
trunk
trunk.mp4
This PR
pr.mp4