mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: new 'simultaneous_uploads' site setting
This commit is contained in:
@@ -618,7 +618,6 @@ export default Ember.Component.extend({
|
|||||||
|
|
||||||
_bindUploadTarget() {
|
_bindUploadTarget() {
|
||||||
this._unbindUploadTarget(); // in case it's still bound, let's clean it up first
|
this._unbindUploadTarget(); // in case it's still bound, let's clean it up first
|
||||||
|
|
||||||
this._pasted = false;
|
this._pasted = false;
|
||||||
|
|
||||||
const $element = this.$();
|
const $element = this.$();
|
||||||
@@ -649,12 +648,23 @@ export default Ember.Component.extend({
|
|||||||
});
|
});
|
||||||
|
|
||||||
$element.on("fileuploadsubmit", (e, data) => {
|
$element.on("fileuploadsubmit", (e, data) => {
|
||||||
|
const max = this.siteSettings.simultaneous_uploads;
|
||||||
|
|
||||||
|
// Limit the number of simultaneous uploads
|
||||||
|
if (max > 0 && data.files.length > max) {
|
||||||
|
bootbox.alert(
|
||||||
|
I18n.t("post.errors.too_many_dragged_and_dropped_files", { max })
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Look for a matching file upload handler contributed from a plugin
|
// Look for a matching file upload handler contributed from a plugin
|
||||||
const matcher = handler => {
|
const matcher = handler => {
|
||||||
const ext = handler.extensions.join("|");
|
const ext = handler.extensions.join("|");
|
||||||
const regex = new RegExp(`\\.(${ext})$`, "i");
|
const regex = new RegExp(`\\.(${ext})$`, "i");
|
||||||
return regex.test(data.files[0].name);
|
return regex.test(data.files[0].name);
|
||||||
};
|
};
|
||||||
|
|
||||||
const matchingHandler = uploadHandlers.find(matcher);
|
const matchingHandler = uploadHandlers.find(matcher);
|
||||||
if (data.files.length === 1 && matchingHandler) {
|
if (data.files.length === 1 && matchingHandler) {
|
||||||
matchingHandler.method(data.files[0]);
|
matchingHandler.method(data.files[0]);
|
||||||
|
|||||||
@@ -34,7 +34,10 @@ export default Em.Mixin.create({
|
|||||||
const $upload = this.$();
|
const $upload = this.$();
|
||||||
const reset = () =>
|
const reset = () =>
|
||||||
this.setProperties({ uploading: false, uploadProgress: 0 });
|
this.setProperties({ uploading: false, uploadProgress: 0 });
|
||||||
const maxFiles = this.getWithDefault("maxFiles", 10);
|
const maxFiles = this.getWithDefault(
|
||||||
|
"maxFiles",
|
||||||
|
this.siteSettings.simultaneous_uploads
|
||||||
|
);
|
||||||
|
|
||||||
$upload.on("fileuploaddone", (e, data) => {
|
$upload.on("fileuploaddone", (e, data) => {
|
||||||
let upload = data.result;
|
let upload = data.result;
|
||||||
@@ -56,8 +59,12 @@ export default Em.Mixin.create({
|
|||||||
);
|
);
|
||||||
|
|
||||||
$upload.on("fileuploaddrop", (e, data) => {
|
$upload.on("fileuploaddrop", (e, data) => {
|
||||||
if (data.files.length > maxFiles) {
|
if (maxFiles > 0 && data.files.length > maxFiles) {
|
||||||
bootbox.alert(I18n.t("post.errors.too_many_dragged_and_dropped_files"));
|
bootbox.alert(
|
||||||
|
I18n.t("post.errors.too_many_dragged_and_dropped_files", {
|
||||||
|
max: maxFiles
|
||||||
|
})
|
||||||
|
);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -2093,7 +2093,7 @@ en:
|
|||||||
upload: "Sorry, there was an error uploading that file. Please try again."
|
upload: "Sorry, there was an error uploading that file. Please try again."
|
||||||
file_too_large: "Sorry, that file is too big (maximum size is {{max_size_kb}}kb). Why not upload your large file to a cloud sharing service, then share the link?"
|
file_too_large: "Sorry, that file is too big (maximum size is {{max_size_kb}}kb). Why not upload your large file to a cloud sharing service, then share the link?"
|
||||||
too_many_uploads: "Sorry, you can only upload one file at a time."
|
too_many_uploads: "Sorry, you can only upload one file at a time."
|
||||||
too_many_dragged_and_dropped_files: "Sorry, you can only upload 10 files at a time."
|
too_many_dragged_and_dropped_files: "Sorry, you can only upload {{max}} files at a time."
|
||||||
upload_not_authorized: "Sorry, the file you are trying to upload is not authorized (authorized extensions: {{authorized_extensions}})."
|
upload_not_authorized: "Sorry, the file you are trying to upload is not authorized (authorized extensions: {{authorized_extensions}})."
|
||||||
image_upload_not_allowed_for_new_user: "Sorry, new users can not upload images."
|
image_upload_not_allowed_for_new_user: "Sorry, new users can not upload images."
|
||||||
attachment_upload_not_allowed_for_new_user: "Sorry, new users can not upload attachments."
|
attachment_upload_not_allowed_for_new_user: "Sorry, new users can not upload attachments."
|
||||||
|
|||||||
@@ -1470,6 +1470,8 @@ en:
|
|||||||
|
|
||||||
min_ratio_to_crop: "Ratio used to crop tall images. Enter the result of width / height."
|
min_ratio_to_crop: "Ratio used to crop tall images. Enter the result of width / height."
|
||||||
|
|
||||||
|
simultaneous_uploads: "Maximum number of files that can be dragged & dropped in the composer"
|
||||||
|
|
||||||
enable_flash_video_onebox: "Enable embedding of swf and flv (Adobe Flash) links in oneboxes. WARNING: may introduce security risks."
|
enable_flash_video_onebox: "Enable embedding of swf and flv (Adobe Flash) links in oneboxes. WARNING: may introduce security risks."
|
||||||
|
|
||||||
default_invitee_trust_level: "Default trust level (0-4) for invited users."
|
default_invitee_trust_level: "Default trust level (0-4) for invited users."
|
||||||
|
|||||||
@@ -1031,6 +1031,11 @@ files:
|
|||||||
default: 0.45 # 90% of 18:9
|
default: 0.45 # 90% of 18:9
|
||||||
min: 0
|
min: 0
|
||||||
max: 1
|
max: 1
|
||||||
|
simultaneous_uploads:
|
||||||
|
client: true
|
||||||
|
default: 5
|
||||||
|
min: 0
|
||||||
|
max: 20
|
||||||
|
|
||||||
trust:
|
trust:
|
||||||
default_trust_level:
|
default_trust_level:
|
||||||
|
|||||||
Reference in New Issue
Block a user