REFACTOR: Remove `Discourse.SiteSettings` from upload.js

This commit is contained in:
Robin Ward 2020-07-24 13:39:16 -04:00
parent 6fb8a92ca2
commit 5077cf52fd
3 changed files with 4 additions and 4 deletions

View File

@ -766,7 +766,7 @@ export default Component.extend({
this._xhr = null; this._xhr = null;
if (!userCancelled) { if (!userCancelled) {
displayErrorForUpload(data); displayErrorForUpload(data, this.siteSettings);
} }
}); });

View File

@ -266,7 +266,7 @@ export function getUploadMarkdown(upload) {
} }
} }
export function displayErrorForUpload(data) { export function displayErrorForUpload(data, siteSettings) {
if (data.jqXHR) { if (data.jqXHR) {
switch (data.jqXHR.status) { switch (data.jqXHR.status) {
// cancelled by the user // cancelled by the user
@ -276,7 +276,7 @@ export function displayErrorForUpload(data) {
// entity too large, usually returned from the web server // entity too large, usually returned from the web server
case 413: case 413:
const type = uploadTypeFromFileName(data.files[0].name); const type = uploadTypeFromFileName(data.files[0].name);
const max_size_kb = Discourse.SiteSettings[`max_${type}_size_kb`]; const max_size_kb = siteSettings[`max_${type}_size_kb`];
bootbox.alert(I18n.t("post.errors.file_too_large", { max_size_kb })); bootbox.alert(I18n.t("post.errors.file_too_large", { max_size_kb }));
return; return;

View File

@ -107,7 +107,7 @@ export default Mixin.create({
$upload.on("fileuploadfail", (e, data) => { $upload.on("fileuploadfail", (e, data) => {
if (!data || data.errorThrown !== "abort") { if (!data || data.errorThrown !== "abort") {
displayErrorForUpload(data); displayErrorForUpload(data, this.siteSettings);
} }
reset(); reset();
}); });