From 77708cbd6fd07b7d6d82412ba140f485e6fe8aec Mon Sep 17 00:00:00 2001 From: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> Date: Fri, 11 Aug 2023 12:23:46 +1000 Subject: [PATCH] Patterns: Open detail view when duplicating pattern (#53214) --- .../page-patterns/duplicate-menu-item.js | 57 ++++++------------- 1 file changed, 18 insertions(+), 39 deletions(-) diff --git a/packages/edit-site/src/components/page-patterns/duplicate-menu-item.js b/packages/edit-site/src/components/page-patterns/duplicate-menu-item.js index d2c14d15f341b..994ed168cd186 100644 --- a/packages/edit-site/src/components/page-patterns/duplicate-menu-item.js +++ b/packages/edit-site/src/components/page-patterns/duplicate-menu-item.js @@ -78,27 +78,22 @@ export default function DuplicateMenuItem( { createSuccessNotice( sprintf( // translators: %s: The new template part's title e.g. 'Call to action (copy)'. - __( '"%s" created.' ), - title + __( '"%s" duplicated.' ), + item.title ), { type: 'snackbar', id: 'edit-site-patterns-success', - actions: [ - { - label: __( 'Edit' ), - onClick: () => - history.push( { - postType: TEMPLATE_PARTS, - postId: result?.id, - categoryType: TEMPLATE_PARTS, - categoryId, - } ), - }, - ], } ); + history.push( { + postType: TEMPLATE_PARTS, + postId: result?.id, + categoryType: TEMPLATE_PARTS, + categoryId, + } ); + onClose(); } catch ( error ) { const errorMessage = @@ -139,41 +134,25 @@ export default function DuplicateMenuItem( { { throwOnError: true } ); - const actionLabel = isThemePattern - ? __( 'View my patterns' ) - : __( 'Edit' ); - - const newLocation = isThemePattern - ? { - categoryType: USER_PATTERNS, - categoryId: USER_PATTERN_CATEGORY, - path: '/patterns', - } - : { - categoryType: USER_PATTERNS, - categoryId: USER_PATTERN_CATEGORY, - postType: USER_PATTERNS, - postId: result?.id, - }; - createSuccessNotice( sprintf( // translators: %s: The new pattern's title e.g. 'Call to action (copy)'. - __( '"%s" added to my patterns.' ), - title + __( '"%s" duplicated.' ), + item.title ), { type: 'snackbar', id: 'edit-site-patterns-success', - actions: [ - { - label: actionLabel, - onClick: () => history.push( newLocation ), - }, - ], } ); + history.push( { + categoryType: USER_PATTERNS, + categoryId: USER_PATTERN_CATEGORY, + postType: USER_PATTERNS, + postId: result?.id, + } ); + onClose(); } catch ( error ) { const errorMessage =