UX: show a generic error on upload for XHR status 0 (#10521)

UX: show a generic error on upload for XHR status 0 (#10521)

This indication covers all cases of network errors, not just “cancelled by user”. The post upload component already has its own handling for user-cancelled uploads, but the generic upload component does not.

Tested by stopping my localhost server right before attempting to upload a file.

diff --git a/app/assets/javascripts/discourse/app/lib/uploads.js b/app/assets/javascripts/discourse/app/lib/uploads.js
index d71784b..a8bb5f3 100644
--- a/app/assets/javascripts/discourse/app/lib/uploads.js
+++ b/app/assets/javascripts/discourse/app/lib/uploads.js
@@ -269,8 +269,9 @@ export function getUploadMarkdown(upload) {
 export function displayErrorForUpload(data, siteSettings) {
   if (data.jqXHR) {
     switch (data.jqXHR.status) {
-      // cancelled by the user
+      // didn't get headers from server, or browser refuses to tell us
       case 0:
+        bootbox.alert(I18n.t("post.errors.upload"));
         return;
 
       // entity too large, usually returned from the web server
diff --git a/app/assets/javascripts/discourse/app/mixins/upload.js b/app/assets/javascripts/discourse/app/mixins/upload.js
index 968313a..4e51a2a 100644
--- a/app/assets/javascripts/discourse/app/mixins/upload.js
+++ b/app/assets/javascripts/discourse/app/mixins/upload.js
@@ -106,7 +106,7 @@ export default Mixin.create({
     });
 
     $upload.on("fileuploadfail", (e, data) => {
-      if (!data || data.errorThrown !== "abort") {
+      if (!data) {
         displayErrorForUpload(data, this.siteSettings);
       }
       reset();

GitHub sha: 93e136ae

This commit appears in #10521 which was approved by eviltrout. It was merged by riking.