ImportHandler: UI for showing maxFileSize error on import

This commit is an integration to f4418149cb.
This commit is contained in:
John McLear 2020-04-14 10:02:21 +00:00
parent 53d8e32ecb
commit c6cb253f76
3 changed files with 11 additions and 2 deletions

View file

@ -143,5 +143,6 @@
"pad.impexp.uploadFailed": "The upload failed, please try again", "pad.impexp.uploadFailed": "The upload failed, please try again",
"pad.impexp.importfailed": "Import failed", "pad.impexp.importfailed": "Import failed",
"pad.impexp.copypaste": "Please copy paste", "pad.impexp.copypaste": "Please copy paste",
"pad.impexp.exportdisabled": "Exporting as {{type}} format is disabled. Please contact your system administrator for details." "pad.impexp.exportdisabled": "Exporting as {{type}} format is disabled. Please contact your system administrator for details.",
"pad.impexp.maxFileSize": "File too big. Contact your site administrator to increase the allowed file size for import"
} }

View file

@ -82,6 +82,12 @@ async function doImport(req, res, padId)
if (err) { if (err) {
console.warn("Uploading Error: " + err.stack); console.warn("Uploading Error: " + err.stack);
} }
// I hate doing indexOf here but I can't see anything to use...
if (err.stack.indexOf("maxFileSize") !== -1) {
reject("maxFileSize");
}
reject("uploadFailed"); reject("uploadFailed");
} }
if(!files.file){ // might not be a graceful fix but it works if(!files.file){ // might not be a graceful fix but it works
@ -261,7 +267,7 @@ exports.doImport = function (req, res, padId)
let status = "ok"; let status = "ok";
doImport(req, res, padId).catch(err => { doImport(req, res, padId).catch(err => {
// check for known errors and replace the status // check for known errors and replace the status
if (err == "uploadFailed" || err == "convertFailed" || err == "padHasData") { if (err == "uploadFailed" || err == "convertFailed" || err == "padHasData" || err == "maxFileSize") {
status = err; status = err;
} else { } else {
throw err; throw err;

View file

@ -111,6 +111,8 @@ var padimpexp = (function()
msg = html10n.get("pad.impexp.uploadFailed"); msg = html10n.get("pad.impexp.uploadFailed");
} else if(status === "padHasData"){ } else if(status === "padHasData"){
msg = html10n.get("pad.impexp.padHasData"); msg = html10n.get("pad.impexp.padHasData");
} else if(status === "maxFileSize"){
msg = html10n.get("pad.impexp.maxFileSize");
} }
function showError(fade) function showError(fade)