Skip to content

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

DEV: Improve hbr topic list detection (#29892)

Jarek Radosz0641d3e4b37e
diff --git a/app/assets/javascripts/discourse-common/addon/lib/raw-templates.js b/app/assets/javascripts/discourse-common/addon/lib/raw-templates.js
index 641122556a4..b1d3fb78efc 100644
--- a/app/assets/javascripts/discourse-common/addon/lib/raw-templates.js
+++ b/app/assets/javascripts/discourse-common/addon/lib/raw-templates.js
@@ -48,11 +48,15 @@ export function addRawTemplate(name, template, opts = {}) {
!opts.hasModernReplacement
) {
const message = `[${name}] hbr topic-list template overrides and connectors are deprecated. Use the value transformer \`topic-list-columns\` and other new topic-list plugin APIs instead.`;
+
+ // NOTE: addRawTemplate is called too early for deprecation handlers to process this:
deprecated(message, {
since: "v3.4.0.beta3-dev",
id: "discourse.hbr-topic-list-overrides",
});
+ needsHbrTopicList(true);
+
let prefix;
if (opts.themeId) {
prefix = consolePrefix(null, {
diff --git a/app/assets/javascripts/discourse/app/components/topic-list-item.js b/app/assets/javascripts/discourse/app/components/topic-list-item.js
index f659f7ae284..7aef22dfbb8 100644
--- a/app/assets/javascripts/discourse/app/components/topic-list-item.js
+++ b/app/assets/javascripts/discourse/app/components/topic-list-item.js
@@ -13,7 +13,6 @@ import { observes, on } from "@ember-decorators/object";
import $ from "jquery";
import { topicTitleDecorators } from "discourse/components/topic-title";
import { wantsNewWindow } from "discourse/lib/intercept-click";
-import { consolePrefix } from "discourse/lib/source-identifier";
import DiscourseURL, { groupPath } from "discourse/lib/url";
import deprecated from "discourse-common/lib/deprecated";
import { RUNTIME_OPTIONS } from "discourse-common/lib/raw-handlebars-helpers";
@@ -53,27 +52,25 @@ export function navigateToTopic(topic, href) {
@attributeBindings("dataTopicId:data-topic-id", "role", "ariaLevel:aria-level")
export default class TopicListItem extends Component {
static reopen() {
- const message =
- "Modifying topic-list-item with `reopen` is deprecated. Use the value transformer `topic-list-columns` and other new topic-list plugin APIs instead.";
- deprecated(message, {
- since: "v3.4.0.beta3-dev",
- id: "discourse.hbr-topic-list-overrides",
- });
- // eslint-disable-next-line no-console
- console.debug(consolePrefix(), message);
+ deprecated(
+ "Modifying topic-list-item with `reopen` is deprecated. Use the value transformer `topic-list-columns` and other new topic-list plugin APIs instead.",
+ {
+ since: "v3.4.0.beta3-dev",
+ id: "discourse.hbr-topic-list-overrides",
+ }
+ );
return super.reopen(...arguments);
}
static reopenClass() {
- const message =
- "Modifying topic-list-item with `reopenClass` is deprecated. Use the value transformer `topic-list-columns` and other new topic-list plugin APIs instead.";
- deprecated(message, {
- since: "v3.4.0.beta3-dev",
- id: "discourse.hbr-topic-list-overrides",
- });
- // eslint-disable-next-line no-console
- console.debug(consolePrefix(), message);
+ deprecated(
+ "Modifying topic-list-item with `reopenClass` is deprecated. Use the value transformer `topic-list-columns` and other new topic-list plugin APIs instead.",
+ {
+ since: "v3.4.0.beta3-dev",
+ id: "discourse.hbr-topic-list-overrides",
+ }
+ );
return super.reopenClass(...arguments);
}
diff --git a/app/assets/javascripts/discourse/app/components/topic-list.js b/app/assets/javascripts/discourse/app/components/topic-list.js
index 031a2efd84d..4a4ee62697e 100644
--- a/app/assets/javascripts/discourse/app/components/topic-list.js
+++ b/app/assets/javascripts/discourse/app/components/topic-list.js
@@ -8,46 +8,34 @@ import {
tagName,
} from "@ember-decorators/component";
import { observes, on } from "@ember-decorators/object";
-import { consolePrefix } from "discourse/lib/source-identifier";
import LoadMore from "discourse/mixins/load-more";
-import deprecated, {
- registerDeprecationHandler,
-} from "discourse-common/lib/deprecated";
-import { needsHbrTopicList } from "discourse-common/lib/raw-templates";
+import deprecated from "discourse-common/lib/deprecated";
import discourseComputed from "discourse-common/utils/decorators";
-registerDeprecationHandler((message, opts) => {
- if (opts?.id === "discourse.hbr-topic-list-overrides") {
- needsHbrTopicList(true);
- }
-});
-
@tagName("table")
@classNames("topic-list")
@classNameBindings("bulkSelectEnabled:sticky-header")
export default class TopicList extends Component.extend(LoadMore) {
static reopen() {
- const message =
- "Modifying topic-list with `reopen` is deprecated. Use the value transformer `topic-list-columns` and other new topic-list plugin APIs instead.";
- deprecated(message, {
- since: "v3.4.0.beta3-dev",
- id: "discourse.hbr-topic-list-overrides",
- });
- // eslint-disable-next-line no-console
- console.debug(consolePrefix(), message);
+ deprecated(
+ "Modifying topic-list with `reopen` is deprecated. Use the value transformer `topic-list-columns` and other new topic-list plugin APIs instead.",
+ {
+ since: "v3.4.0.beta3-dev",
+ id: "discourse.hbr-topic-list-overrides",
+ }
+ );
return super.reopen(...arguments);
}
static reopenClass() {
- const message =
- "Modifying topic-list with `reopenClass` is deprecated. Use the value transformer `topic-list-columns` and other new topic-list plugin APIs instead.";
- deprecated(message, {
- since: "v3.4.0.beta3-dev",
- id: "discourse.hbr-topic-list-overrides",
- });
- // eslint-disable-next-line no-console
- console.debug(consolePrefix(), message);
+ deprecated(
+ "Modifying topic-list with `reopenClass` is deprecated. Use the value transformer `topic-list-columns` and other new topic-list plugin APIs instead.",
+ {
+ since: "v3.4.0.beta3-dev",
+ id: "discourse.hbr-topic-list-overrides",
+ }
+ );
return super.reopenClass(...arguments);
}
diff --git a/app/assets/javascripts/discourse/app/instance-initializers/hbr-topic-list-overrides.js b/app/assets/javascripts/discourse/app/instance-initializers/hbr-topic-list-overrides.js
new file mode 100644
index 00000000000..c5aa68f3a34
--- /dev/null
+++ b/app/assets/javascripts/discourse/app/instance-initializers/hbr-topic-list-overrides.js
@@ -0,0 +1,17 @@
+import { consolePrefix } from "discourse/lib/source-identifier";
+import { registerDeprecationHandler } from "discourse-common/lib/deprecated";
+import { needsHbrTopicList } from "discourse-common/lib/raw-templates";
+
+export default {
+ before: "inject-objects",
+
+ initialize() {
+ registerDeprecationHandler((message, opts) => {
+ if (opts?.id === "discourse.hbr-topic-list-overrides") {
+ needsHbrTopicList(true);
+ // eslint-disable-next-line no-console
+ console.debug(consolePrefix(), message);
+ }
+ });
+ },
+};
diff --git a/app/assets/javascripts/discourse/app/lib/plugin-api.gjs b/app/assets/javascripts/discourse/app/lib/plugin-api.gjs
index eb706834d40..c106af60607 100644
--- a/app/assets/javascripts/discourse/app/lib/plugin-api.gjs
+++ b/app/assets/javascripts/discourse/app/lib/plugin-api.gjs
@@ -297,14 +297,13 @@ class PluginApi {
resolverName === "component:topic-list" ||
resolverName === "component:topic-list-item"
) {
- const message =
- "Modifying topic-list and topic-list-item with `modifyClass` is deprecated. Use the value transformer `topic-list-columns` and other new topic-list plugin APIs instead.";
- deprecated(message, {
- since: "v3.4.0.beta3-dev",
- id: "discourse.hbr-topic-list-overrides",
- });
- // eslint-disable-next-line no-console
- console.debug(consolePrefix(), message);
+ deprecated(
+ "Modifying topic-list and topic-list-item with `modifyClass` is deprecated. Use the value transformer `topic-list-columns` and other new topic-list plugin APIs instead.",
+ {
+ since: "v3.4.0.beta3-dev",
+ id: "discourse.hbr-topic-list-overrides",
+ }
+ );
}
const klass = this._resolveClass(resolverName, opts);
@@ -348,14 +347,13 @@ class PluginApi {
resolverName === "component:topic-list" ||
resolverName === "component:topic-list-item"
) {
- const message =
- "Modifying topic-list and topic-list-item with `modifyClassStatic` is deprecated. Use the value transformer `topic-list-columns` and other new topic-list plugin APIs instead.";
- deprecated(message, {
- since: "v3.4.0.beta3-dev",
- id: "discourse.hbr-topic-list-overrides",
- });
- // eslint-disable-next-line no-console
- console.debug(consolePrefix(), message);
+ deprecated(
+ "Modifying topic-list and topic-list-item with `modifyClassStatic` is deprecated. Use the value transformer `topic-list-columns` and other new topic-list plugin APIs instead.",
+ {
+ since: "v3.4.0.beta3-dev",
+ id: "discourse.hbr-topic-list-overrides",
+ }
+ );
}
const klass = this._resolveClass(resolverName, opts);