From 78ba07be2e0b97097d54fef291094662ced403e2 Mon Sep 17 00:00:00 2001 From: Jorge Costa Date: Tue, 16 Apr 2024 16:14:32 +0100 Subject: [PATCH] Update: Move pattern actions to the editor package. --- .../src/components/page-patterns/index.js | 33 ++++++++++++++----- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/packages/edit-site/src/components/page-patterns/index.js b/packages/edit-site/src/components/page-patterns/index.js index 6db723167e5f21..a643e45c429ad1 100644 --- a/packages/edit-site/src/components/page-patterns/index.js +++ b/packages/edit-site/src/components/page-patterns/index.js @@ -433,15 +433,30 @@ export default function DataviewsPatterns() { const history = useHistory(); const onActionPerformed = useCallback( ( actionId, items ) => { - if ( actionId === 'edit-post' ) { - const post = items[ 0 ]; - history.push( { - postId: post.id, - postType: post.type, - categoryId, - categoryType: type, - canvas: 'edit', - } ); + switch ( actionId ) { + case 'edit-post': + { + const post = items[ 0 ]; + history.push( { + postId: post.id, + postType: post.type, + categoryId, + categoryType: type, + canvas: 'edit', + } ); + } + break; + case 'duplicate-pattern': + { + const pattern = items[ 0 ]; + history.push( { + categoryType: PATTERN_TYPES.theme, + categoryId, + postType: PATTERN_TYPES.user, + postId: pattern.id, + } ); + } + break; } }, [ categoryId, history, type ]