Skip to content
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

Patterns: Open detail view when duplicating pattern #53214

Merged
merged 4 commits into from
Aug 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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 =
Expand Down
Loading