Skip to content

Commit

Permalink
Add a notice idea to stop multiple success snackbars cluttering up th…
Browse files Browse the repository at this point in the history
…e screen
  • Loading branch information
glendaviesnz committed Jun 29, 2023
1 parent 47b60e5 commit 196379c
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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',
} );
}
},
Expand Down

0 comments on commit 196379c

Please sign in to comment.