From c678bd17f3072b0d752ebb1fb9aa09c6711f0505 Mon Sep 17 00:00:00 2001 From: Ella van Durpe Date: Tue, 9 Jun 2020 17:07:35 +0300 Subject: [PATCH] Image editing: use snackbar notifications --- .../src/rich-image/rich-image/index.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/block-library/src/rich-image/rich-image/index.js b/packages/block-library/src/rich-image/rich-image/index.js index 2ca585e6cb36e7..b393dc8443435d 100644 --- a/packages/block-library/src/rich-image/rich-image/index.js +++ b/packages/block-library/src/rich-image/rich-image/index.js @@ -35,6 +35,7 @@ import { MenuItem, } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; +import { useDispatch } from '@wordpress/data'; /** * Internal dependencies @@ -158,10 +159,9 @@ function RichImage( props ) { isSelected, attributes: { id, url }, originalBlock: OriginalBlock, - noticeUI, setAttributes, - noticeOperations, } = props; + const { createErrorNotice } = useDispatch( 'core/notices' ); const [ isCropping, setIsCropping ] = useState( false ); const [ inProgress, setIsProgress ] = useState( null ); const [ imageSize, setImageSize ] = useState( { @@ -183,7 +183,6 @@ function RichImage( props ) { function adjustImage( action, attrs ) { setIsProgress( action ); - noticeOperations.removeAllNotices(); richImageRequest( id, action, attrs ) .then( ( response ) => { @@ -198,10 +197,14 @@ function RichImage( props ) { } } ) .catch( () => { - noticeOperations.createErrorNotice( + createErrorNotice( __( 'Unable to perform the image modification. Please check your media storage.' - ) + ), + { + id: 'image-editing-error', + type: 'snackbar', + } ); setIsProgress( null ); setIsCropping( false ); @@ -224,7 +227,6 @@ function RichImage( props ) { return ( <> - { noticeUI }
{ inProgress && (