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.
This commit is contained in:
Ted Johansson 2024-07-15 16:12:44 +08:00 committed by GitHub
parent 9bed472a77
commit cf5174da69
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 33 additions and 30 deletions

View File

@ -169,12 +169,11 @@ class ProblemCheck
def problem(override_key: nil, override_data: {}) def problem(override_key: nil, override_data: {})
[ [
Problem.new( Problem.new(
message || I18n.t(
I18n.t( override_key || translation_key,
override_key || translation_key, base_path: Discourse.base_path,
base_path: Discourse.base_path, **override_data.merge(translation_data).symbolize_keys,
**override_data.merge(translation_data).symbolize_keys, ),
),
priority: self.config.priority, priority: self.config.priority,
identifier:, identifier:,
), ),
@ -185,10 +184,6 @@ class ProblemCheck
[] []
end end
def message
nil
end
def translation_key def translation_key
"dashboard.problem.#{identifier}" "dashboard.problem.#{identifier}"
end end

View File

@ -11,19 +11,23 @@ class ProblemCheck::OutOfDateThemes < ProblemCheck
private private
def translation_data
{ themes_list: }
end
def out_of_date_themes def out_of_date_themes
@out_of_date_themes ||= RemoteTheme.out_of_date_themes @out_of_date_themes ||= RemoteTheme.out_of_date_themes
end end
def message
"#{I18n.t("dashboard.problem.out_of_date_themes")}<ul>#{themes_list}</ul>"
end
def themes_list def themes_list
out_of_date_themes <<~HTML.squish
.map do |name, id| <ul>#{
"<li><a href=\"#{Discourse.base_path}/admin/customize/themes/#{id}\">#{CGI.escapeHTML(name)}</a></li>" out_of_date_themes
end .map do |name, id|
.join("\n") "<li><a href=\"#{Discourse.base_path}/admin/customize/themes/#{id}\">#{CGI.escapeHTML(name)}</a></li>"
end
.join("\n")
}</ul>
HTML
end end
end end

View File

@ -11,19 +11,23 @@ class ProblemCheck::UnreachableThemes < ProblemCheck
private private
def translation_data
{ themes_list: }
end
def unreachable_themes def unreachable_themes
@unreachable_themes ||= RemoteTheme.unreachable_themes @unreachable_themes ||= RemoteTheme.unreachable_themes
end end
def message
"#{I18n.t("dashboard.problem.unreachable_themes")}<ul>#{themes_list}</ul>"
end
def themes_list def themes_list
unreachable_themes <<~HTML.squish
.map do |name, id| <ul>#{
"<li><a href=\"/admin/customize/themes/#{id}\">#{CGI.escapeHTML(name)}</a></li>" unreachable_themes
end .map do |name, id|
.join("\n") "<li><a href=\"/admin/customize/themes/#{id}\">#{CGI.escapeHTML(name)}</a></li>"
end
.join("\n")
}</ul>
HTML
end end
end end

View File

@ -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_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>." 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." 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:" 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:" 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." 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." 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." 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."