mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 01:31:35 +08:00
UX: Improve validation error message when saving theme objects setting (#26455)
Why this change? Before this change, the validation error message shown to the user when saving a theme objects setting is very cryptic. This commit changes the validation error messages to be displayed on top of the editor instead. Note that I don't think this way of displaying is the ideal state we want to get to but given the time we have this will do for now.
This commit is contained in:

committed by
GitHub

parent
e58110a9a0
commit
91f0c71720
@ -338,7 +338,13 @@ class Admin::ThemesController < Admin::AdminController
|
||||
new_value = params[:value] || nil
|
||||
|
||||
previous_value = @theme.cached_settings[setting_name]
|
||||
@theme.update_setting(setting_name, new_value)
|
||||
|
||||
begin
|
||||
@theme.update_setting(setting_name, new_value)
|
||||
rescue Discourse::InvalidParameters => e
|
||||
return render_json_error e.message
|
||||
end
|
||||
|
||||
@theme.save
|
||||
|
||||
log_theme_setting_change(setting_name, previous_value, new_value)
|
||||
|
Reference in New Issue
Block a user