mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
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.
This commit is contained in:
@@ -269,8 +269,9 @@ export function getUploadMarkdown(upload) {
|
|||||||
export function displayErrorForUpload(data, siteSettings) {
|
export function displayErrorForUpload(data, siteSettings) {
|
||||||
if (data.jqXHR) {
|
if (data.jqXHR) {
|
||||||
switch (data.jqXHR.status) {
|
switch (data.jqXHR.status) {
|
||||||
// cancelled by the user
|
// didn't get headers from server, or browser refuses to tell us
|
||||||
case 0:
|
case 0:
|
||||||
|
bootbox.alert(I18n.t("post.errors.upload"));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// entity too large, usually returned from the web server
|
// entity too large, usually returned from the web server
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ export default Mixin.create({
|
|||||||
});
|
});
|
||||||
|
|
||||||
$upload.on("fileuploadfail", (e, data) => {
|
$upload.on("fileuploadfail", (e, data) => {
|
||||||
if (!data || data.errorThrown !== "abort") {
|
if (!data) {
|
||||||
displayErrorForUpload(data, this.siteSettings);
|
displayErrorForUpload(data, this.siteSettings);
|
||||||
}
|
}
|
||||||
reset();
|
reset();
|
||||||
|
|||||||
Reference in New Issue
Block a user