From 20a36f0b8f59849bd728288de1d73537306d9823 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Fri, 23 Feb 2024 14:28:23 +0000 Subject: [PATCH] DEV: Include deprecation link in warning banner (#25839) --- .../services/deprecation-warning-handler.js | 25 +++++++++++++------ config/locales/client.en.yml | 4 ++- 2 files changed, 20 insertions(+), 9 deletions(-) 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 c9b7e084c17..07338190135 100644 --- a/app/assets/javascripts/discourse/app/services/deprecation-warning-handler.js +++ b/app/assets/javascripts/discourse/app/services/deprecation-warning-handler.js @@ -58,10 +58,10 @@ export default class DeprecationWarningHandler extends Service { return; } - this.maybeNotifyAdmin(opts.id, source); + this.maybeNotifyAdmin(opts, source); } - maybeNotifyAdmin(id, source) { + maybeNotifyAdmin(opts, source) { if (this.#adminWarned) { return; } @@ -74,17 +74,26 @@ export default class DeprecationWarningHandler extends Service { return; } - if (CRITICAL_DEPRECATIONS.some((pattern) => pattern.test(id))) { - this.notifyAdmin(id, source); + if (CRITICAL_DEPRECATIONS.some((pattern) => pattern.test(opts.id))) { + this.notifyAdmin(opts, source); } } - notifyAdmin(id, source) { + notifyAdmin({ id, url }, source) { this.#adminWarned = true; - let notice = I18n.t("critical_deprecation.notice", { - id: escapeExpression(id), - }); + let notice = I18n.t("critical_deprecation.notice") + " "; + + if (url) { + notice += I18n.t("critical_deprecation.linked_id", { + id: escapeExpression(id), + url: escapeExpression(url), + }); + } else { + notice += I18n.t("critical_deprecation.id", { + id: escapeExpression(id), + }); + } if (this.siteSettings.warn_critical_js_deprecations_message) { notice += " " + this.siteSettings.warn_critical_js_deprecations_message; diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 7cf04afea12..910e487ad4f 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -226,7 +226,9 @@ en: broken_plugin_alert: "Caused by plugin '%{name}'" critical_deprecation: - notice: "[Admin Notice] One of your themes or plugins needs updating for compatibility with upcoming Discourse core changes (id:%{id})." + notice: "[Admin Notice] One of your themes or plugins needs updating for compatibility with upcoming Discourse core changes." + id: "(id:%{id})" + linked_id: "(id:%{id})" theme_source: "Identified theme: '%{name}'." plugin_source: "Identified plugin: '%{name}'"