From cf5174da693e02b6aa07f31f4a994a0f8c984a53 Mon Sep 17 00:00:00 2001 From: Ted Johansson <ted@discourse.org> Date: Mon, 15 Jul 2024 16:12:44 +0800 Subject: [PATCH] FIX: Fix broken out of date themes admin notice (#27916) The OutOfDateThemes problem check is using an old method of setting the message, by overriding #message. It should instead use #translation_keys. (By chance I noticed the same thing applies to UnreachableThemes. --- app/models/problem_check.rb | 15 +++++-------- .../problem_check/out_of_date_themes.rb | 22 +++++++++++-------- .../problem_check/unreachable_themes.rb | 22 +++++++++++-------- config/locales/server.en.yml | 4 ++-- 4 files changed, 33 insertions(+), 30 deletions(-) diff --git a/app/models/problem_check.rb b/app/models/problem_check.rb index 43c4c6765aa..e8b07342b3b 100644 --- a/app/models/problem_check.rb +++ b/app/models/problem_check.rb @@ -169,12 +169,11 @@ class ProblemCheck def problem(override_key: nil, override_data: {}) [ Problem.new( - message || - I18n.t( - override_key || translation_key, - base_path: Discourse.base_path, - **override_data.merge(translation_data).symbolize_keys, - ), + I18n.t( + override_key || translation_key, + base_path: Discourse.base_path, + **override_data.merge(translation_data).symbolize_keys, + ), priority: self.config.priority, identifier:, ), @@ -185,10 +184,6 @@ class ProblemCheck [] end - def message - nil - end - def translation_key "dashboard.problem.#{identifier}" end diff --git a/app/services/problem_check/out_of_date_themes.rb b/app/services/problem_check/out_of_date_themes.rb index f298f88df96..0a5aacd4c1c 100644 --- a/app/services/problem_check/out_of_date_themes.rb +++ b/app/services/problem_check/out_of_date_themes.rb @@ -11,19 +11,23 @@ class ProblemCheck::OutOfDateThemes < ProblemCheck private + def translation_data + { themes_list: } + end + def out_of_date_themes @out_of_date_themes ||= RemoteTheme.out_of_date_themes end - def message - "#{I18n.t("dashboard.problem.out_of_date_themes")}<ul>#{themes_list}</ul>" - end - def themes_list - out_of_date_themes - .map do |name, id| - "<li><a href=\"#{Discourse.base_path}/admin/customize/themes/#{id}\">#{CGI.escapeHTML(name)}</a></li>" - end - .join("\n") + <<~HTML.squish + <ul>#{ + out_of_date_themes + .map do |name, id| + "<li><a href=\"#{Discourse.base_path}/admin/customize/themes/#{id}\">#{CGI.escapeHTML(name)}</a></li>" + end + .join("\n") + }</ul> + HTML end end diff --git a/app/services/problem_check/unreachable_themes.rb b/app/services/problem_check/unreachable_themes.rb index 708700bdf9a..8ebd3f3b4b9 100644 --- a/app/services/problem_check/unreachable_themes.rb +++ b/app/services/problem_check/unreachable_themes.rb @@ -11,19 +11,23 @@ class ProblemCheck::UnreachableThemes < ProblemCheck private + def translation_data + { themes_list: } + end + def unreachable_themes @unreachable_themes ||= RemoteTheme.unreachable_themes end - def message - "#{I18n.t("dashboard.problem.unreachable_themes")}<ul>#{themes_list}</ul>" - end - def themes_list - unreachable_themes - .map do |name, id| - "<li><a href=\"/admin/customize/themes/#{id}\">#{CGI.escapeHTML(name)}</a></li>" - end - .join("\n") + <<~HTML.squish + <ul>#{ + unreachable_themes + .map do |name, id| + "<li><a href=\"/admin/customize/themes/#{id}\">#{CGI.escapeHTML(name)}</a></li>" + end + .join("\n") + }</ul> + HTML end end diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 4d5031a8f45..5de98d755b9 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -1668,8 +1668,8 @@ en: poll_pop3_timeout: "Connection to the POP3 server is timing out. Incoming email could not be retrieved. Please check your <a href='%{base_path}/admin/site_settings/category/email'>POP3 settings</a> and service provider." poll_pop3_auth_error: "Connection to the POP3 server is failing with an authentication error. Please check your <a href='%{base_path}/admin/site_settings/category/email'>POP3 settings</a>." force_https: "Your website is using SSL. But `<a href='%{base_path}/admin/site_settings/category/all_results?filter=force_https'>force_https</a>` is not yet enabled in your site settings." - out_of_date_themes: "Updates are available for the following themes:" - unreachable_themes: "We were unable to check for updates on the following themes:" + out_of_date_themes: "Updates are available for the following themes:%{themes_list}" + unreachable_themes: "We were unable to check for updates on the following themes:%{themes_list}" watched_words: "The regular expression for %{action} watched words is invalid. Please check your <a href='%{base_path}/admin/customize/watched_words'>Watched Word settings</a>, or disable the 'watched words regular expressions' site setting." google_analytics_version: "Your Discourse is currently using Google Analytics 3, which will no longer be supported after July 2023. <a href='https://meta.discourse.org/t/260498'>Upgrade to Google Analytics 4</a> now to continue receiving valuable insights and analytics for your website's performance." category_style_deprecated: "Your Discourse is currently using a deprecated category style which will be removed before the final beta release of Discourse 3.2. Please refer to <a href='https://meta.discourse.org/t/282441'>Moving to a Single Category Style Site Setting</a> for instructions on how to keep your selected category style."