Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Added optional notification title when upload fails. #31

Merged
merged 1 commit into from
Jun 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lang/contexts.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"Insert image": "Label for the insert image toolbar button."
"Insert image": "Label for the insert image toolbar button.",
"Upload failed": "Title of the notification displayed when upload fails."
}
6 changes: 5 additions & 1 deletion src/imageuploadengine.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export default class ImageUploadEngine extends Plugin {
*/
load( loader, batch, imageElement ) {
const editor = this.editor;
const t = editor.locale.t;
const doc = editor.document;
const fileRepository = editor.plugins.get( FileRepository );
const notification = editor.plugins.get( Notification );
Expand Down Expand Up @@ -127,7 +128,10 @@ export default class ImageUploadEngine extends Plugin {
.catch( msg => {
// Might be 'aborted'.
if ( loader.status == 'error' ) {
notification.showWarning( msg, { namespace: 'upload' } );
notification.showWarning( msg, {
title: t( 'Upload failed' ),
namespace: 'upload'
} );
}

clean();
Expand Down
1 change: 1 addition & 0 deletions tests/imageuploadengine.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ describe( 'ImageUploadEngine', () => {

notification.on( 'show:warning', ( evt, data ) => {
expect( data.message ).to.equal( 'Reading error.' );
expect( data.title ).to.equal( 'Upload failed' );
evt.stop();

done();
Expand Down