From f0e3a8cb412212c8f49914c6818ccda9659d3a21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20Kup=C5=9B?= Date: Fri, 2 Jun 2017 10:37:49 +0200 Subject: [PATCH] Added optional notification title when upload fails. --- lang/contexts.json | 3 ++- src/imageuploadengine.js | 6 +++++- tests/imageuploadengine.js | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lang/contexts.json b/lang/contexts.json index 0ac946a..a90827c 100644 --- a/lang/contexts.json +++ b/lang/contexts.json @@ -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." } diff --git a/src/imageuploadengine.js b/src/imageuploadengine.js index 86f23d8..fc671f2 100644 --- a/src/imageuploadengine.js +++ b/src/imageuploadengine.js @@ -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 ); @@ -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(); diff --git a/tests/imageuploadengine.js b/tests/imageuploadengine.js index 9474c59..8214139 100644 --- a/tests/imageuploadengine.js +++ b/tests/imageuploadengine.js @@ -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();