Browse Source

Added optional notification title when upload fails.

Szymon Kupś 8 years ago
parent
commit
49b3c6f223

+ 2 - 1
packages/ckeditor5-upload/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."
 }

+ 5 - 1
packages/ckeditor5-upload/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();

+ 1 - 0
packages/ckeditor5-upload/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();