From f4d8a330c32a9b216ee11b63350a56673d160c36 Mon Sep 17 00:00:00 2001 From: Saurabh Patel Date: Sat, 22 Dec 2018 02:06:17 +0530 Subject: [PATCH] Merge pull request #6761 from mrfinch/saurabh/show-popup FIX:show popup before bulk invite --- .../discourse/components/csv-uploader.js.es6 | 19 ++++++++++++++++++- .../discourse/mixins/upload.js.es6 | 4 +++- config/locales/client.en.yml | 2 ++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/components/csv-uploader.js.es6 b/app/assets/javascripts/discourse/components/csv-uploader.js.es6 index 93c8e137364..d5c6124fc1a 100644 --- a/app/assets/javascripts/discourse/components/csv-uploader.js.es6 +++ b/app/assets/javascripts/discourse/components/csv-uploader.js.es6 @@ -25,5 +25,22 @@ export default Em.Component.extend(UploadMixin, { uploadDone() { bootbox.alert(I18n.t("user.invited.bulk_invite.success")); - } + }, + + uploadOptions() { + return { autoUpload: false }; + }, + + _init: function() { + const $upload = this.$(); + + $upload.on("fileuploadadd", (e, data) => { + bootbox.confirm( + I18n.t("user.invited.bulk_invite.confirmation_message"), + I18n.t("cancel"), + I18n.t("go_ahead"), + result => (result ? data.submit() : data.abort()) + ); + }); + }.on("didInsertElement") }); diff --git a/app/assets/javascripts/discourse/mixins/upload.js.es6 b/app/assets/javascripts/discourse/mixins/upload.js.es6 index 4d89f1ab912..9bb4f0ec6a9 100644 --- a/app/assets/javascripts/discourse/mixins/upload.js.es6 +++ b/app/assets/javascripts/discourse/mixins/upload.js.es6 @@ -96,7 +96,9 @@ export default Em.Mixin.create({ }); $upload.on("fileuploadfail", (e, data) => { - displayErrorForUpload(data); + if (!data || (data && data.errorThrown !== "abort")) { + displayErrorForUpload(data); + } reset(); }); }.on("didInsertElement"), diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 0a8f99e5f22..423b032aa74 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -213,6 +213,7 @@ en: submit: "Submit" generic_error: "Sorry, an error has occurred." generic_error_with_reason: "An error occurred: %{error}" + go_ahead: "Go ahead" sign_up: "Sign Up" log_in: "Log In" age: "Age" @@ -996,6 +997,7 @@ en: text: "Bulk Invite from File" success: "File uploaded successfully, you will be notified via message when the process is complete." error: "Sorry, file should be CSV format." + confirmation_message: "You’re about to email invites to everyone in the uploaded file." password: title: "Password"