A platform for community discussion. Free, open, simple.
DEV: Detect overrides of topic-list and topic-list-item templates (#30847)
David Taylorcf0a4a7e1194
diff --git a/app/assets/javascripts/discourse/app/instance-initializers/component-templates.js b/app/assets/javascripts/discourse/app/instance-initializers/component-templates.jsindex 34982dd40d3..7eb5c54c90e 100644--- a/app/assets/javascripts/discourse/app/instance-initializers/component-templates.js+++ b/app/assets/javascripts/discourse/app/instance-initializers/component-templates.js@@ -3,6 +3,7 @@ import ClassicComponent from "@ember/component";import deprecated from "discourse/lib/deprecated";import DiscourseTemplateMap from "discourse/lib/discourse-template-map";import { isTesting } from "discourse/lib/environment";+import { RAW_TOPIC_LIST_DEPRECATION_OPTIONS } from "discourse/lib/plugin-api";let THROW_GJS_ERROR = isTesting();@@ -15,6 +16,8 @@ export function overrideThrowGjsError(value) {// This patch is not ideal, but Ember does not allow us to change a component template after initial association// https://github.com/glimmerjs/glimmer-vm/blob/03a4b55c03/packages/%40glimmer/manager/lib/public/template.ts#L14-L20+const LEGACY_TOPIC_LIST_OVERRIDES = ["topic-list", "topic-list-item"];+export default {after: ["populate-template-map", "mobile"],@@ -68,13 +71,21 @@ export default {console.error(message);}} else if (originalTemplate) {- deprecated(- `[${finalOverrideModuleName}] Overriding component templates is deprecated, and will soon be disabled. Use plugin outlets, CSS, or other customization APIs instead.`,- {- id: "discourse.component-template-overrides",- url: "https://meta.discourse.org/t/247487",- }- );+ if (LEGACY_TOPIC_LIST_OVERRIDES.includes(componentName)) {+ // Special handling for these, with a different deprecation id, so the auto-feature-flag works correctly+ deprecated(+ `Overriding '${componentName}' template is deprecated. Use the value transformer 'topic-list-columns' and other new topic-list plugin APIs instead.`,+ RAW_TOPIC_LIST_DEPRECATION_OPTIONS+ );+ } else {+ deprecated(+ `[${finalOverrideModuleName}] Overriding component templates is deprecated, and will soon be disabled. Use plugin outlets, CSS, or other customization APIs instead.`,+ {+ id: "discourse.component-template-overrides",+ url: "https://meta.discourse.org/t/247487",+ }+ );+ }const overrideTemplate = require(finalOverrideModuleName).default;