DEV: Improve hbr topic list detection (#29892)
1. `addRawTemplate` is called too early for deprecation handlers to process its deprecation call, so toggle the hbr flag directly 2. move the deprecation handler to an initializer so that other (non-template) calls are always handled 3. move the debug logging to the handler
This commit is contained in:
parent
b9838d6066
commit
0641d3e4b3
|
@ -48,11 +48,15 @@ export function addRawTemplate(name, template, opts = {}) {
|
||||||
!opts.hasModernReplacement
|
!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.`;
|
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, {
|
deprecated(message, {
|
||||||
since: "v3.4.0.beta3-dev",
|
since: "v3.4.0.beta3-dev",
|
||||||
id: "discourse.hbr-topic-list-overrides",
|
id: "discourse.hbr-topic-list-overrides",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
needsHbrTopicList(true);
|
||||||
|
|
||||||
let prefix;
|
let prefix;
|
||||||
if (opts.themeId) {
|
if (opts.themeId) {
|
||||||
prefix = consolePrefix(null, {
|
prefix = consolePrefix(null, {
|
||||||
|
|
|
@ -13,7 +13,6 @@ import { observes, on } from "@ember-decorators/object";
|
||||||
import $ from "jquery";
|
import $ from "jquery";
|
||||||
import { topicTitleDecorators } from "discourse/components/topic-title";
|
import { topicTitleDecorators } from "discourse/components/topic-title";
|
||||||
import { wantsNewWindow } from "discourse/lib/intercept-click";
|
import { wantsNewWindow } from "discourse/lib/intercept-click";
|
||||||
import { consolePrefix } from "discourse/lib/source-identifier";
|
|
||||||
import DiscourseURL, { groupPath } from "discourse/lib/url";
|
import DiscourseURL, { groupPath } from "discourse/lib/url";
|
||||||
import deprecated from "discourse-common/lib/deprecated";
|
import deprecated from "discourse-common/lib/deprecated";
|
||||||
import { RUNTIME_OPTIONS } from "discourse-common/lib/raw-handlebars-helpers";
|
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")
|
@attributeBindings("dataTopicId:data-topic-id", "role", "ariaLevel:aria-level")
|
||||||
export default class TopicListItem extends Component {
|
export default class TopicListItem extends Component {
|
||||||
static reopen() {
|
static reopen() {
|
||||||
const 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.";
|
"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",
|
since: "v3.4.0.beta3-dev",
|
||||||
id: "discourse.hbr-topic-list-overrides",
|
id: "discourse.hbr-topic-list-overrides",
|
||||||
});
|
}
|
||||||
// eslint-disable-next-line no-console
|
);
|
||||||
console.debug(consolePrefix(), message);
|
|
||||||
|
|
||||||
return super.reopen(...arguments);
|
return super.reopen(...arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
static reopenClass() {
|
static reopenClass() {
|
||||||
const 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.";
|
"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",
|
since: "v3.4.0.beta3-dev",
|
||||||
id: "discourse.hbr-topic-list-overrides",
|
id: "discourse.hbr-topic-list-overrides",
|
||||||
});
|
}
|
||||||
// eslint-disable-next-line no-console
|
);
|
||||||
console.debug(consolePrefix(), message);
|
|
||||||
|
|
||||||
return super.reopenClass(...arguments);
|
return super.reopenClass(...arguments);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,46 +8,34 @@ import {
|
||||||
tagName,
|
tagName,
|
||||||
} from "@ember-decorators/component";
|
} from "@ember-decorators/component";
|
||||||
import { observes, on } from "@ember-decorators/object";
|
import { observes, on } from "@ember-decorators/object";
|
||||||
import { consolePrefix } from "discourse/lib/source-identifier";
|
|
||||||
import LoadMore from "discourse/mixins/load-more";
|
import LoadMore from "discourse/mixins/load-more";
|
||||||
import deprecated, {
|
import deprecated from "discourse-common/lib/deprecated";
|
||||||
registerDeprecationHandler,
|
|
||||||
} from "discourse-common/lib/deprecated";
|
|
||||||
import { needsHbrTopicList } from "discourse-common/lib/raw-templates";
|
|
||||||
import discourseComputed from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
|
|
||||||
registerDeprecationHandler((message, opts) => {
|
|
||||||
if (opts?.id === "discourse.hbr-topic-list-overrides") {
|
|
||||||
needsHbrTopicList(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
@tagName("table")
|
@tagName("table")
|
||||||
@classNames("topic-list")
|
@classNames("topic-list")
|
||||||
@classNameBindings("bulkSelectEnabled:sticky-header")
|
@classNameBindings("bulkSelectEnabled:sticky-header")
|
||||||
export default class TopicList extends Component.extend(LoadMore) {
|
export default class TopicList extends Component.extend(LoadMore) {
|
||||||
static reopen() {
|
static reopen() {
|
||||||
const message =
|
deprecated(
|
||||||
"Modifying topic-list with `reopen` is deprecated. Use the value transformer `topic-list-columns` and other new topic-list plugin APIs instead.";
|
"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",
|
since: "v3.4.0.beta3-dev",
|
||||||
id: "discourse.hbr-topic-list-overrides",
|
id: "discourse.hbr-topic-list-overrides",
|
||||||
});
|
}
|
||||||
// eslint-disable-next-line no-console
|
);
|
||||||
console.debug(consolePrefix(), message);
|
|
||||||
|
|
||||||
return super.reopen(...arguments);
|
return super.reopen(...arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
static reopenClass() {
|
static reopenClass() {
|
||||||
const message =
|
deprecated(
|
||||||
"Modifying topic-list with `reopenClass` is deprecated. Use the value transformer `topic-list-columns` and other new topic-list plugin APIs instead.";
|
"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",
|
since: "v3.4.0.beta3-dev",
|
||||||
id: "discourse.hbr-topic-list-overrides",
|
id: "discourse.hbr-topic-list-overrides",
|
||||||
});
|
}
|
||||||
// eslint-disable-next-line no-console
|
);
|
||||||
console.debug(consolePrefix(), message);
|
|
||||||
|
|
||||||
return super.reopenClass(...arguments);
|
return super.reopenClass(...arguments);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
|
@ -297,14 +297,13 @@ class PluginApi {
|
||||||
resolverName === "component:topic-list" ||
|
resolverName === "component:topic-list" ||
|
||||||
resolverName === "component:topic-list-item"
|
resolverName === "component:topic-list-item"
|
||||||
) {
|
) {
|
||||||
const 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.";
|
"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",
|
since: "v3.4.0.beta3-dev",
|
||||||
id: "discourse.hbr-topic-list-overrides",
|
id: "discourse.hbr-topic-list-overrides",
|
||||||
});
|
}
|
||||||
// eslint-disable-next-line no-console
|
);
|
||||||
console.debug(consolePrefix(), message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const klass = this._resolveClass(resolverName, opts);
|
const klass = this._resolveClass(resolverName, opts);
|
||||||
|
@ -348,14 +347,13 @@ class PluginApi {
|
||||||
resolverName === "component:topic-list" ||
|
resolverName === "component:topic-list" ||
|
||||||
resolverName === "component:topic-list-item"
|
resolverName === "component:topic-list-item"
|
||||||
) {
|
) {
|
||||||
const 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.";
|
"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",
|
since: "v3.4.0.beta3-dev",
|
||||||
id: "discourse.hbr-topic-list-overrides",
|
id: "discourse.hbr-topic-list-overrides",
|
||||||
});
|
}
|
||||||
// eslint-disable-next-line no-console
|
);
|
||||||
console.debug(consolePrefix(), message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const klass = this._resolveClass(resolverName, opts);
|
const klass = this._resolveClass(resolverName, opts);
|
||||||
|
|
Loading…
Reference in New Issue