UX: Return a friendlier error when the CSV is invalid. Added a cancel button to return to the /badges view

This commit is contained in:
romanrizzi 2020-01-13 15:53:41 -03:00
parent e4a85e2a80
commit d3091edcea
3 changed files with 8 additions and 1 deletions

View File

@ -21,6 +21,10 @@
action=(action 'massAward')
disabled=saving
label="admin.badges.mass_award.perform"}}
{{#link-to 'adminBadges.index' class="btn btn-danger"}}
{{d-icon "times"}}
<span>{{i18n 'cancel'}}</span>
{{/link-to}}
</form>
{{else}}
<span class='badge-required'>{{I18n 'admin.badges.mass_award.no_badge_selected'}}</span>

View File

@ -64,7 +64,7 @@ class Admin::BadgesController < Admin::AdminController
head :ok
rescue CSV::MalformedCSVError
raise Discourse::InvalidParameters
render_json_error I18n.t('badges.mass_award.errors.invalid_csv'), status: 400
end
def badge_types

View File

@ -4128,6 +4128,9 @@ en:
This document is CC-BY-SA. It was last updated May 31, 2013.
badges:
mass_award:
errors:
invalid_csv: We couldn't read that CSV file. Please confirm it has one email per line.
editor:
name: Editor
description: First post edit