Skip to content

A platform for community discussion. Free, open, simple.

DEV: Improve deprecation warning banner (#33648)

David Taylor63961531c430
diff --git a/app/assets/javascripts/discourse/app/services/deprecation-warning-handler.js b/app/assets/javascripts/discourse/app/services/deprecation-warning-handler.js
index 150e70a285b..5c22ce74401 100644
--- a/app/assets/javascripts/discourse/app/services/deprecation-warning-handler.js
+++ b/app/assets/javascripts/discourse/app/services/deprecation-warning-handler.js
@@ -120,16 +120,29 @@ export default class DeprecationWarningHandler extends Service {
this.#adminWarned = true;
- let notice = i18n("critical_deprecation.notice") + " ";
-
- if (url) {
- notice += i18n("critical_deprecation.linked_id", {
- id: escapeExpression(id),
- url: escapeExpression(url),
+ let sourceString;
+ if (source?.type === "theme") {
+ sourceString = i18n("critical_deprecation.theme_source", {
+ name: escapeExpression(source.name),
+ path: source.path,
+ });
+ } else if (source?.type === "plugin") {
+ sourceString = i18n("critical_deprecation.plugin_source", {
+ name: escapeExpression(source.name),
});
} else {
- notice += i18n("critical_deprecation.id", {
- id: escapeExpression(id),
+ sourceString = i18n("critical_deprecation.unknown_source");
+ }
+
+ let notice =
+ i18n("critical_deprecation.notice", {
+ source: sourceString,
+ id,
+ }) + " ";
+
+ if (url) {
+ notice += i18n("critical_deprecation.learn_more_link", {
+ url,
});
}
@@ -137,21 +150,6 @@ export default class DeprecationWarningHandler extends Service {
notice += " " + this.siteSettings.warn_critical_js_deprecations_message;
}
- if (source?.type === "theme") {
- notice +=
- " " +
- i18n("critical_deprecation.theme_source", {
- name: escapeExpression(source.name),
- path: source.path,
- });
- } else if (source?.type === "plugin") {
- notice +=
- " " +
- i18n("critical_deprecation.plugin_source", {
- name: escapeExpression(source.name),
- });
- }
-
addGlobalNotice(notice, "critical-deprecation", {
dismissable: true,
dismissDuration: moment.duration(1, "day"),
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 52f74180c82..52e7c9bba30 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -240,11 +240,11 @@ en:
broken_transformer_alert: "There was an error. Your site may not work properly."
critical_deprecation:
- notice: "<b>[Admin Notice]</b> One of your themes or plugins needs updating for compatibility with upcoming Discourse core changes."
- id: "(id:<em>%{id}</em>)"
- linked_id: "(id:<a href='%{url}' target='_blank'><em>%{id}</em></a>)"
- theme_source: "Identified theme: <a target='_blank' href='%{path}'>'%{name}'</a>."
- plugin_source: "Identified plugin: '%{name}'"
+ notice: "<b>[Admin Notice]</b> %{source} contains code which needs updating. (id:%{id})"
+ learn_more_link: "(<a href='%{url}' target='_blank'><em>learn more</em></a>)"
+ theme_source: "Theme <a target='_blank' href='%{path}'>'%{name}'</a>"
+ plugin_source: "Plugin '%{name}'"
+ unknown_source: "One of your themes or plugins"
s3:
regions:
diff --git a/spec/system/ember_deprecation_spec.rb b/spec/system/ember_deprecation_spec.rb
index 03f73bed28c..cdfd70f0254 100644
--- a/spec/system/ember_deprecation_spec.rb
+++ b/spec/system/ember_deprecation_spec.rb
@@ -43,9 +43,7 @@ describe "JS Deprecation Handling", type: :system do
JS
message = find("#global-notice-critical-deprecation")
- expect(message).to have_text(
- "One of your themes or plugins needs updating for compatibility with upcoming Discourse core changes",
- )
+ expect(message).to have_text("One of your themes or plugins contains code which needs updating")
expect(message).to have_text(SiteSetting.warn_critical_js_deprecations_message)
end