Skip to content

Commit

Permalink
Restore snackbar notices after duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronrobertshaw committed Aug 2, 2023
1 parent aa9e9b2 commit f100f78
Showing 1 changed file with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ export default function DuplicateMenuItem( {
onClose,
} ) {
const { saveEntityRecord } = useDispatch( coreStore );
const { createErrorNotice } = useDispatch( noticesStore );
const { createErrorNotice, createSuccessNotice } =
useDispatch( noticesStore );

const history = useHistory();
const existingTemplateParts = useExistingTemplateParts();
Expand All @@ -74,6 +75,18 @@ export default function DuplicateMenuItem( {
{ throwOnError: true }
);

createSuccessNotice(
sprintf(
// translators: %s: The new template part's title e.g. 'Call to action (copy)'.
__( '"%s" created.' ),
title
),
{
type: 'snackbar',
id: 'edit-site-patterns-success',
}
);

history.push( {
postType: TEMPLATE_PARTS,
postId: result?.id,
Expand Down Expand Up @@ -121,6 +134,18 @@ export default function DuplicateMenuItem( {
{ throwOnError: true }
);

createSuccessNotice(
sprintf(
// translators: %s: The new pattern's title e.g. 'Call to action (copy)'.
__( '"%s" added to my patterns.' ),
title
),
{
type: 'snackbar',
id: 'edit-site-patterns-success',
}
);

history.push( {
categoryType: USER_PATTERNS,
categoryId: USER_PATTERN_CATEGORY,
Expand Down

0 comments on commit f100f78

Please sign in to comment.