file uploads: Remove status text for failed server uploads.

Remove the 'Uploading file...' message from the compose box when
file upload fails due to a server side error.
This commit is contained in:
Divyanshu Agrawal 2020-03-07 17:24:07 +05:30 committed by Tim Abbott
parent 6d7e91b6c7
commit 4215386ae3
2 changed files with 18 additions and 2 deletions

View File

@ -578,6 +578,7 @@ run_test('uppy_events', () => {
const on_upload_error_callback = callbacks["upload-error"];
show_error_message_called = false;
compose_ui_replace_syntax_called = false;
upload.show_error_message = (config, message) => {
show_error_message_called = true;
assert.equal(config.mode, "compose");
@ -589,17 +590,30 @@ run_test('uppy_events', () => {
},
};
uppy_cancel_all_called = false;
on_upload_error_callback(null, null, response);
on_upload_error_callback(file, null, response);
assert(uppy_cancel_all_called);
assert(show_error_message_called);
assert(compose_ui_replace_syntax_called);
compose_ui_replace_syntax_called = false;
upload.show_error_message = (config, message) => {
show_error_message_called = true;
assert.equal(config.mode, "compose");
assert.equal(message, null);
};
uppy_cancel_all_called = false;
on_upload_error_callback(null, null);
on_upload_error_callback(file, null, null);
assert(uppy_cancel_all_called);
assert(show_error_message_called);
assert(compose_ui_replace_syntax_called);
show_error_message_called = false;
$('#comepose-textarea').val('user modified text');
uppy_cancel_all_called = false;
on_upload_error_callback(file, null);
assert(uppy_cancel_all_called);
assert(show_error_message_called);
assert(compose_ui_replace_syntax_called);
assert.equal($('#comepose-textarea').val(), 'user modified text');
});

View File

@ -259,6 +259,8 @@ exports.setup_upload = function (config) {
const message = response ? response.body.msg : null;
uppy.cancelAll();
exports.show_error_message(config, message);
compose_ui.replace_syntax("[Uploading " + file.name + "…]()", "", exports.get_item("textarea", config));
compose_ui.autosize_textarea();
});
uppy.on('restriction-failed', (file) => {