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:
Alan Guo Xiang Tan
2024-04-02 11:55:51 +08:00
committed by GitHub
parent e58110a9a0
commit 91f0c71720
7 changed files with 243 additions and 174 deletions

View File

@ -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)