use obj.prop syntax rather than obj[prop] syntax

This commit is contained in:
Régis Hanol 2017-06-14 17:08:42 +02:00
parent f77e6c8fc6
commit 31b8477d8b
1 changed files with 7 additions and 7 deletions

View File

@ -172,7 +172,7 @@ export function validateUploadedFiles(files, opts) {
} }
opts = opts || {}; opts = opts || {};
opts["type"] = uploadTypeFromFileName(upload.name); opts.type = uploadTypeFromFileName(upload.name);
return validateUploadedFile(upload, opts); return validateUploadedFile(upload, opts);
} }
@ -185,18 +185,18 @@ export function validateUploadedFile(file, opts) {
if (!name) { return false; } if (!name) { return false; }
// check that the uploaded file is authorized // check that the uploaded file is authorized
if (opts["allowStaffToUploadAnyFileInPm"] && opts["isPrivateMessage"]) { if (opts.allowStaffToUploadAnyFileInPm && opts.isPrivateMessage) {
if (Discourse.User.current("staff")) { if (Discourse.User.current("staff")) {
return true; return true;
} }
} }
if (opts["imagesOnly"]) { if (opts.imagesOnly) {
if (!isAnImage(name) && !isAuthorizedImage(name)) { if (!isAnImage(name) && !isAuthorizedImage(name)) {
bootbox.alert(I18n.t('post.errors.upload_not_authorized', { authorized_extensions: authorizedImagesExtensions() })); bootbox.alert(I18n.t('post.errors.upload_not_authorized', { authorized_extensions: authorizedImagesExtensions() }));
return false; return false;
} }
} else if (opts["csvOnly"]) { } else if (opts.csvOnly) {
if (!(/\.csv$/i).test(name)) { if (!(/\.csv$/i).test(name)) {
bootbox.alert(I18n.t('user.invited.bulk_invite.error')); bootbox.alert(I18n.t('user.invited.bulk_invite.error'));
return false; return false;
@ -208,10 +208,10 @@ export function validateUploadedFile(file, opts) {
} }
} }
if (!opts["bypassNewUserRestriction"]) { if (!opts.bypassNewUserRestriction) {
// ensures that new users can upload a file // ensures that new users can upload a file
if (!Discourse.User.current().isAllowedToUploadAFile(opts["type"])) { if (!Discourse.User.current().isAllowedToUploadAFile(opts.type)) {
bootbox.alert(I18n.t(`post.errors.${opts["type"]}_upload_not_allowed_for_new_user`)); bootbox.alert(I18n.t(`post.errors.${opts.type}_upload_not_allowed_for_new_user`));
return false; return false;
} }
} }