DEV: Detect overrides of topic-list and topic-list-item templates (#30847)

New topic-list should not be auto-enabled in this case
This commit is contained in:
David Taylor 2025-01-17 16:23:18 +00:00 committed by GitHub
parent 5d76f2e343
commit cf0a4a7e11
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 18 additions and 7 deletions

View File

@ -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;