Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an error state to the image block to allow upload errors to display #10224

Merged
merged 8 commits into from
Dec 10, 2018
8 changes: 5 additions & 3 deletions packages/block-library/src/image/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class ImageEdit extends Component {
}

componentDidMount() {
const { attributes, setAttributes } = this.props;
const { attributes, setAttributes, noticeOperations } = this.props;
const { id, url = '' } = attributes;

if ( isTemporaryImage( id, url ) ) {
Expand All @@ -127,6 +127,10 @@ class ImageEdit extends Component {
setAttributes( pickRelevantMediaFiles( image ) );
},
allowedTypes: ALLOWED_MEDIA_TYPES,
onError: ( message ) => {
noticeOperations.createErrorNotice( message );
this.setState( { isEditing: true } );
},
} );
}
}
Expand Down Expand Up @@ -165,11 +169,9 @@ class ImageEdit extends Component {
} );
return;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I liked the whitespace! 😢

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, it was unintentional but didn't see it till it was already committed, I can patch to add it back?

Copy link
Contributor

@talldan talldan Dec 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, ok! It's not the end of the world, but might be good to add it back if it was unintentional. There were a few others removed as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a problem it should be all set now - thanks for pointing it out

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@talldan Replacing that whitespace triggered Travis CI and it failed for some unrelated reason 🤦‍♂️
Is that something you can restart, or should I ask somewhere else?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @brentswisher - there were some minor issues after the 5.0 release with the CI jobs. Everything now seems to be passing so will merge this 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks!

this.setState( {
isEditing: false,
} );

this.props.setAttributes( {
...pickRelevantMediaFiles( media ),
width: undefined,
Expand Down
1 change: 0 additions & 1 deletion packages/editor/src/components/block-drop-zone/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ class BlockDropZone extends Component {
getBlockTransforms( 'from' ),
( transform ) => transform.type === 'files' && transform.isMatch( files )
);

if ( transformation ) {
const insertIndex = this.getInsertIndex( position );
const blocks = transformation.transform( files, this.props.updateBlockAttributes );
Expand Down