From 196379c4f728b96eabe60929e3bfef7de1816ab7 Mon Sep 17 00:00:00 2001 From: Glen Davies Date: Wed, 28 Jun 2023 17:19:25 +1200 Subject: [PATCH] Add a notice idea to stop multiple success snackbars cluttering up the screen --- .../reusable-block-convert-button.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/reusable-blocks/src/components/reusable-blocks-menu-items/reusable-block-convert-button.js b/packages/reusable-blocks/src/components/reusable-blocks-menu-items/reusable-block-convert-button.js index e02cd4f428b67..7dabdc4975e45 100644 --- a/packages/reusable-blocks/src/components/reusable-blocks-menu-items/reusable-block-convert-button.js +++ b/packages/reusable-blocks/src/components/reusable-blocks-menu-items/reusable-block-convert-button.js @@ -18,7 +18,7 @@ import { } from '@wordpress/components'; import { symbol } from '@wordpress/icons'; import { useDispatch, useSelect } from '@wordpress/data'; -import { __ } from '@wordpress/i18n'; +import { __, sprintf } from '@wordpress/i18n'; import { store as noticesStore } from '@wordpress/notices'; import { store as coreStore } from '@wordpress/core-data'; @@ -97,15 +97,25 @@ export default function ReusableBlockConvertButton( { ); createSuccessNotice( syncType === 'fully' - ? __( 'Synced Pattern created.' ) - : __( 'Unsynced Pattern created.' ), + ? sprintf( + // translators: %s: the name the user has given to the pattern. + __( 'Synced Pattern created: %s' ), + reusableBlockTitle + ) + : sprintf( + // translators: %s: the name the user has given to the pattern. + __( 'Unsynced Pattern created: %s' ), + reusableBlockTitle + ), { type: 'snackbar', + id: 'convert-to-reusable-block-success', } ); } catch ( error ) { createErrorNotice( error.message, { type: 'snackbar', + id: 'convert-to-reusable-block-error', } ); } },