Skip to content

Commit

Permalink
File: Display upload error notices using snackbars (#43893)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka authored Sep 6, 2022
1 parent f510544 commit 659377e
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions packages/block-library/src/file/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import classnames from 'classnames';
import { getBlobByURL, isBlobURL, revokeBlobURL } from '@wordpress/blob';
import {
__unstableGetAnimateClassName as getAnimateClassName,
withNotices,
ResizableBox,
ToolbarButton,
} from '@wordpress/components';
Expand Down Expand Up @@ -60,14 +59,7 @@ function ClipboardToolbarButton( { text, disabled } ) {
);
}

function FileEdit( {
attributes,
isSelected,
setAttributes,
noticeUI,
noticeOperations,
clientId,
} ) {
function FileEdit( { attributes, isSelected, setAttributes, clientId } ) {
const {
id,
fileId,
Expand All @@ -91,6 +83,7 @@ function FileEdit( {
[ id ]
);

const { createErrorNotice } = useDispatch( noticesStore );
const { toggleSelection, __unstableMarkNextChangeAsNotPersistent } =
useDispatch( blockEditorStore );

Expand Down Expand Up @@ -137,8 +130,7 @@ function FileEdit( {

function onUploadError( message ) {
setAttributes( { href: undefined } );
noticeOperations.removeAllNotices();
noticeOperations.createErrorNotice( message );
createErrorNotice( message, { type: 'snackbar' } );
}

function changeLinkDestinationOption( newHref ) {
Expand Down Expand Up @@ -207,7 +199,6 @@ function FileEdit( {
),
} }
onSelect={ onSelectFile }
notices={ noticeUI }
onError={ onUploadError }
accept="*"
/>
Expand Down Expand Up @@ -321,4 +312,4 @@ function FileEdit( {
);
}

export default withNotices( FileEdit );
export default FileEdit;

0 comments on commit 659377e

Please sign in to comment.