DEV: Set glimmer-topic-list to 'auto' by default (#30582)

This will cause the glimmer topic-list to be enabled for sites with compatible customizations. Incompatible customizations will print a deprecation message to the console, along with a link to more information.

Also cleans up a handful of specs/behaviour which were revealed by switching the default.

More details at https://meta.discourse.org/t/343404
This commit is contained in:
David Taylor 2025-01-08 12:00:56 +00:00 committed by GitHub
parent 3f729b23bc
commit 6330e6ceae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 41 additions and 94 deletions

View File

@ -6,10 +6,6 @@ const DEPRECATION_WORKFLOW = [
handler: "silence",
matchId: "discourse.decorate-widget.hamburger-widget-links",
},
{
handler: "silence",
matchId: "discourse.hbr-topic-list-overrides",
},
];
export default DEPRECATION_WORKFLOW;

View File

@ -1,5 +1,5 @@
import require from "require";
import { consolePrefix } from "discourse/lib/source-identifier";
import { RAW_TOPIC_LIST_DEPRECATION_OPTIONS } from "discourse/lib/plugin-api";
import deprecated from "discourse-common/lib/deprecated";
import { getResolverOption } from "discourse-common/resolver";
@ -50,28 +50,9 @@ export function addRawTemplate(name, template, opts = {}) {
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",
});
deprecated(message, RAW_TOPIC_LIST_DEPRECATION_OPTIONS);
needsHbrTopicList(true);
let prefix;
if (opts.themeId) {
prefix = consolePrefix(null, {
type: "theme",
id: opts.themeId,
name: opts.themeName,
});
} else if (opts.pluginName) {
prefix = consolePrefix(null, {
type: "plugin",
name: opts.pluginName,
});
}
// eslint-disable-next-line no-console
console.debug(prefix, message);
}
// Core templates should never overwrite themes / plugins

View File

@ -12,6 +12,7 @@ import {
import { observes, on } from "@ember-decorators/object";
import $ from "jquery";
import { wantsNewWindow } from "discourse/lib/intercept-click";
import { RAW_TOPIC_LIST_DEPRECATION_OPTIONS } from "discourse/lib/plugin-api";
import { applyValueTransformer } from "discourse/lib/transformer";
import DiscourseURL, { groupPath } from "discourse/lib/url";
import deprecated from "discourse-common/lib/deprecated";
@ -54,10 +55,7 @@ export default class TopicListItem extends Component {
static reopen() {
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",
}
RAW_TOPIC_LIST_DEPRECATION_OPTIONS
);
return super.reopen(...arguments);
@ -66,10 +64,7 @@ export default class TopicListItem extends Component {
static reopenClass() {
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",
}
RAW_TOPIC_LIST_DEPRECATION_OPTIONS
);
return super.reopenClass(...arguments);

View File

@ -8,6 +8,7 @@ import {
tagName,
} from "@ember-decorators/component";
import { observes, on } from "@ember-decorators/object";
import { RAW_TOPIC_LIST_DEPRECATION_OPTIONS } from "discourse/lib/plugin-api";
import LoadMore from "discourse/mixins/load-more";
import deprecated from "discourse-common/lib/deprecated";
import discourseComputed from "discourse-common/utils/decorators";
@ -19,10 +20,7 @@ export default class TopicList extends Component.extend(LoadMore) {
static reopen() {
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",
}
RAW_TOPIC_LIST_DEPRECATION_OPTIONS
);
return super.reopen(...arguments);
@ -31,10 +29,7 @@ export default class TopicList extends Component.extend(LoadMore) {
static reopenClass() {
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",
}
RAW_TOPIC_LIST_DEPRECATION_OPTIONS
);
return super.reopenClass(...arguments);

View File

@ -35,7 +35,8 @@ export default class Item extends Component {
next(() => this.historyStore.delete("lastTopicIdViewed"));
if (this.shouldFocusLastVisited) {
element.querySelector(".main-link .title")?.focus();
// Using next() so it always runs after clean-dom
next(() => element.querySelector(".main-link .title")?.focus());
}
} else if (this.args.topic.get("highlight")) {
// highlight new topics that have been loaded from the server or the one we just created
@ -133,7 +134,8 @@ export default class Item extends Component {
click(e) {
if (
e.target.classList.contains("raw-topic-link") ||
e.target.classList.contains("post-activity")
e.target.classList.contains("post-activity") ||
e.target.classList.contains("badge-posts")
) {
if (wantsNewWindow(e)) {
return;
@ -163,7 +165,11 @@ export default class Item extends Component {
@action
keyDown(e) {
if (e.key === "Enter" && e.target.classList.contains("post-activity")) {
if (
e.key === "Enter" &&
(e.target.classList.contains("post-activity") ||
e.target.classList.contains("badge-posts"))
) {
e.preventDefault();
this.navigateToTopic(this.args.topic, e.target.href);
}

View File

@ -110,7 +110,9 @@ export default class TopicList extends Component {
}
get bulkSelectEnabled() {
return this.args.bulkSelectHelper?.bulkSelectEnabled;
return (
this.args.bulkSelectHelper?.bulkSelectEnabled && this.args.canBulkSelect
);
}
get canDoBulkActions() {

View File

@ -1,4 +1,3 @@
import { consolePrefix } from "discourse/lib/source-identifier";
import { registerDeprecationHandler } from "discourse-common/lib/deprecated";
import { needsHbrTopicList } from "discourse-common/lib/raw-templates";
@ -9,8 +8,6 @@ export default {
registerDeprecationHandler((message, opts) => {
if (opts?.id === "discourse.hbr-topic-list-overrides") {
needsHbrTopicList(true);
// eslint-disable-next-line no-console
console.debug(consolePrefix(), message);
}
});
},

View File

@ -176,6 +176,12 @@ const POST_MENU_DEPRECATION_OPTIONS = {
url: "https://meta.discourse.org/t/341014",
};
export const RAW_TOPIC_LIST_DEPRECATION_OPTIONS = {
since: "v3.4.0.beta4-dev",
id: "discourse.hbr-topic-list-overrides",
url: "https://meta.discourse.org/t/343404",
};
const appliedModificationIds = new WeakMap();
// This helper prevents us from applying the same `modifyClass` over and over in test mode.
@ -306,10 +312,7 @@ class PluginApi {
) {
deprecated(
`Modifying '${resolverName}' 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",
}
RAW_TOPIC_LIST_DEPRECATION_OPTIONS
);
}
@ -357,10 +360,7 @@ class PluginApi {
) {
deprecated(
`Modifying '${resolverName}' 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",
}
RAW_TOPIC_LIST_DEPRECATION_OPTIONS
);
}

View File

@ -1,4 +1,5 @@
import EmberObject from "@ember/object";
import { RAW_TOPIC_LIST_DEPRECATION_OPTIONS } from "discourse/lib/plugin-api";
import deprecated from "discourse-common/lib/deprecated";
import discourseComputed from "discourse-common/utils/decorators";
import { i18n } from "discourse-i18n";
@ -7,10 +8,7 @@ export default class TopicStatus extends EmberObject {
static reopen() {
deprecated(
"Modifying raw-view:topic-status 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",
}
RAW_TOPIC_LIST_DEPRECATION_OPTIONS
);
return super.reopen(...arguments);
@ -19,10 +17,7 @@ export default class TopicStatus extends EmberObject {
static reopenClass() {
deprecated(
"Modifying raw-view:topic-status 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",
}
RAW_TOPIC_LIST_DEPRECATION_OPTIONS
);
return super.reopenClass(...arguments);

View File

@ -2,6 +2,7 @@ import { visit } from "@ember/test-helpers";
import { compile } from "handlebars";
import { test } from "qunit";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import { withSilencedDeprecations } from "discourse-common/lib/deprecated";
import {
addRawTemplate,
removeRawTemplate,
@ -12,10 +13,12 @@ const CONNECTOR =
acceptance("Raw Plugin Outlet", function (needs) {
needs.hooks.beforeEach(function () {
addRawTemplate(
CONNECTOR,
compile(`<span class='topic-lala'>{{context.topic.id}}</span>`)
);
withSilencedDeprecations("discourse.hbr-topic-list-overrides", () => {
addRawTemplate(
CONNECTOR,
compile(`<span class='topic-lala'>{{context.topic.id}}</span>`)
);
});
});
needs.hooks.afterEach(function () {

View File

@ -1,22 +0,0 @@
import { click, triggerKeyEvent, visit } from "@ember/test-helpers";
import { test } from "qunit";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("Topic Entrance Modal", function () {
test("can be closed with the esc key", async function (assert) {
await visit("/");
await click(".topic-list-item button.posts-map");
assert
.dom("#topic-entrance")
.doesNotHaveClass("hidden", "topic entrance modal appears");
assert
.dom("#topic-entrance .jump-top")
.isFocused("the jump top button has focus when the modal is shown");
await triggerKeyEvent("#topic-entrance", "keydown", "Escape");
assert
.dom("#topic-entrance")
.hasClass("hidden", "topic entrance modal disappears after pressing esc");
});
});

View File

@ -3480,7 +3480,7 @@ experimental:
- disabled
- auto
- enabled
default: disabled
default: auto
glimmer_post_menu_mode:
client: true
type: enum

View File

@ -75,8 +75,7 @@ module PageObjects
end
def visit_topic_first_reply_via_keyboard(topic)
find("#{topic_list_item_class(topic)} button.posts-map").native.send_keys(:return)
find("#topic-entrance button.jump-top").native.send_keys(:return)
find("#{topic_list_item_class(topic)} a.badge-posts").native.send_keys(:return)
end
def topic_list_item_class(topic)
@ -94,7 +93,7 @@ module PageObjects
private
def topic_list_item_closed(topic)
"#{topic_list_item_class(topic)} .topic-statuses .topic-status svg.locked"
"#{topic_list_item_class(topic)} .topic-statuses .topic-status svg.d-icon-lock"
end
def topic_list_item_unread_badge(topic)