compose_banners: Hide upload progress banner on error.

This commit is contained in:
Karl Stolley 2023-10-06 15:02:43 -05:00 committed by Tim Abbott
parent d887fb57e7
commit eea59e2edc
2 changed files with 9 additions and 0 deletions

View File

@ -406,6 +406,8 @@ export function setup_upload(config) {
uppy.on("upload-error", (file, _error, response) => { uppy.on("upload-error", (file, _error, response) => {
const message = response ? response.body.msg : undefined; const message = response ? response.body.msg : undefined;
// Hide the upload status banner on error so only the error banner shows
hide_upload_banner(uppy, config, file.id);
show_error_message(config, message, file.id); show_error_message(config, message, file.id);
compose_ui.replace_syntax(get_translated_status(file), "", get_item("textarea", config)); compose_ui.replace_syntax(get_translated_status(file), "", get_item("textarea", config));
compose_ui.autosize_textarea(get_item("textarea", config)); compose_ui.autosize_textarea(get_item("textarea", config));

View File

@ -612,6 +612,12 @@ test("uppy_events", ({override_rewire, mock_template}) => {
}; };
on_info_visible_callback(); on_info_visible_callback();
let hide_upload_banner_called = false;
override_rewire(upload, "hide_upload_banner", (_uppy, config) => {
hide_upload_banner_called = true;
assert.equal(config.mode, "compose");
});
const on_upload_error_callback = callbacks["upload-error"]; const on_upload_error_callback = callbacks["upload-error"];
$("#compose_banners .upload_banner .upload_msg").text(""); $("#compose_banners .upload_banner .upload_msg").text("");
compose_ui_replace_syntax_called = false; compose_ui_replace_syntax_called = false;
@ -628,6 +634,7 @@ test("uppy_events", ({override_rewire, mock_template}) => {
assert.ok(compose_ui_replace_syntax_called); assert.ok(compose_ui_replace_syntax_called);
$("#compose_banners .upload_banner .upload_msg").text(""); $("#compose_banners .upload_banner .upload_msg").text("");
assert.ok(hide_upload_banner_called);
$("#compose-textarea").val("user modified text"); $("#compose-textarea").val("user modified text");
on_upload_error_callback(file, null); on_upload_error_callback(file, null);
assert.ok(compose_ui_replace_syntax_called); assert.ok(compose_ui_replace_syntax_called);