From 2c0574010aafff7be0cb5d11561e3fb51b129888 Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Tue, 24 Dec 2019 15:49:27 +0530 Subject: [PATCH] FIX: better error message when forum is in read-only mode --- app/assets/javascripts/discourse/lib/export-csv.js.es6 | 6 +++--- app/controllers/export_csv_controller.rb | 2 ++ config/locales/server.en.yml | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/discourse/lib/export-csv.js.es6 b/app/assets/javascripts/discourse/lib/export-csv.js.es6 index 9f604f6e45f..39b19771f36 100644 --- a/app/assets/javascripts/discourse/lib/export-csv.js.es6 +++ b/app/assets/javascripts/discourse/lib/export-csv.js.es6 @@ -1,4 +1,6 @@ import { ajax } from "discourse/lib/ajax"; +import { popupAjaxError } from "discourse/lib/ajax-error"; + function exportEntityByType(type, entity, args) { return ajax("/export_csv/export_entity.json", { method: "POST", @@ -11,9 +13,7 @@ export function exportUserArchive() { .then(function() { bootbox.alert(I18n.t("user.download_archive.success")); }) - .catch(function() { - bootbox.alert(I18n.t("user.download_archive.rate_limit_error")); - }); + .catch(popupAjaxError); } export function exportEntity(entity, args) { diff --git a/app/controllers/export_csv_controller.rb b/app/controllers/export_csv_controller.rb index 8c724947250..4b461fcc566 100644 --- a/app/controllers/export_csv_controller.rb +++ b/app/controllers/export_csv_controller.rb @@ -9,6 +9,8 @@ class ExportCsvController < ApplicationController Jobs.enqueue(:export_csv_file, entity: export_params[:entity], user_id: current_user.id, args: export_params[:args]) StaffActionLogger.new(current_user).log_entity_export(export_params[:entity]) render json: success_json + rescue Discourse::InvalidAccess + return render_json_error I18n.t("csv_export.rate_limit_error") end private diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 9cc4d0ace8a..a3122c73d97 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -575,7 +575,6 @@ en: attributes: word: too_many: "Too many words for that action" - uncategorized_category_name: "Uncategorized" @@ -3760,6 +3759,7 @@ en: csv_export: boolean_yes: "Yes" boolean_no: "No" + rate_limit_error: "Posts can be downloaded once per day, please try again tomorrow." static_topic_first_reply: | Edit the first post in this topic to change the contents of the %{page_name} page.