mirror of
https://github.com/discourse/discourse.git
synced 2025-01-16 06:42:41 +08:00
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:
parent
3f729b23bc
commit
6330e6ceae
|
@ -6,10 +6,6 @@ const DEPRECATION_WORKFLOW = [
|
||||||
handler: "silence",
|
handler: "silence",
|
||||||
matchId: "discourse.decorate-widget.hamburger-widget-links",
|
matchId: "discourse.decorate-widget.hamburger-widget-links",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
handler: "silence",
|
|
||||||
matchId: "discourse.hbr-topic-list-overrides",
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
export default DEPRECATION_WORKFLOW;
|
export default DEPRECATION_WORKFLOW;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import require from "require";
|
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 deprecated from "discourse-common/lib/deprecated";
|
||||||
import { getResolverOption } from "discourse-common/resolver";
|
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.`;
|
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:
|
// NOTE: addRawTemplate is called too early for deprecation handlers to process this:
|
||||||
deprecated(message, {
|
deprecated(message, RAW_TOPIC_LIST_DEPRECATION_OPTIONS);
|
||||||
since: "v3.4.0.beta3-dev",
|
|
||||||
id: "discourse.hbr-topic-list-overrides",
|
|
||||||
});
|
|
||||||
|
|
||||||
needsHbrTopicList(true);
|
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
|
// Core templates should never overwrite themes / plugins
|
||||||
|
|
|
@ -12,6 +12,7 @@ import {
|
||||||
import { observes, on } from "@ember-decorators/object";
|
import { observes, on } from "@ember-decorators/object";
|
||||||
import $ from "jquery";
|
import $ from "jquery";
|
||||||
import { wantsNewWindow } from "discourse/lib/intercept-click";
|
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 { applyValueTransformer } from "discourse/lib/transformer";
|
||||||
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";
|
||||||
|
@ -54,10 +55,7 @@ export default class TopicListItem extends Component {
|
||||||
static reopen() {
|
static reopen() {
|
||||||
deprecated(
|
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.",
|
||||||
{
|
RAW_TOPIC_LIST_DEPRECATION_OPTIONS
|
||||||
since: "v3.4.0.beta3-dev",
|
|
||||||
id: "discourse.hbr-topic-list-overrides",
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return super.reopen(...arguments);
|
return super.reopen(...arguments);
|
||||||
|
@ -66,10 +64,7 @@ export default class TopicListItem extends Component {
|
||||||
static reopenClass() {
|
static reopenClass() {
|
||||||
deprecated(
|
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.",
|
||||||
{
|
RAW_TOPIC_LIST_DEPRECATION_OPTIONS
|
||||||
since: "v3.4.0.beta3-dev",
|
|
||||||
id: "discourse.hbr-topic-list-overrides",
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return super.reopenClass(...arguments);
|
return super.reopenClass(...arguments);
|
||||||
|
|
|
@ -8,6 +8,7 @@ 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 { RAW_TOPIC_LIST_DEPRECATION_OPTIONS } from "discourse/lib/plugin-api";
|
||||||
import LoadMore from "discourse/mixins/load-more";
|
import LoadMore from "discourse/mixins/load-more";
|
||||||
import deprecated from "discourse-common/lib/deprecated";
|
import deprecated from "discourse-common/lib/deprecated";
|
||||||
import discourseComputed from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
|
@ -19,10 +20,7 @@ export default class TopicList extends Component.extend(LoadMore) {
|
||||||
static reopen() {
|
static reopen() {
|
||||||
deprecated(
|
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.",
|
||||||
{
|
RAW_TOPIC_LIST_DEPRECATION_OPTIONS
|
||||||
since: "v3.4.0.beta3-dev",
|
|
||||||
id: "discourse.hbr-topic-list-overrides",
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return super.reopen(...arguments);
|
return super.reopen(...arguments);
|
||||||
|
@ -31,10 +29,7 @@ export default class TopicList extends Component.extend(LoadMore) {
|
||||||
static reopenClass() {
|
static reopenClass() {
|
||||||
deprecated(
|
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.",
|
||||||
{
|
RAW_TOPIC_LIST_DEPRECATION_OPTIONS
|
||||||
since: "v3.4.0.beta3-dev",
|
|
||||||
id: "discourse.hbr-topic-list-overrides",
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return super.reopenClass(...arguments);
|
return super.reopenClass(...arguments);
|
||||||
|
|
|
@ -35,7 +35,8 @@ export default class Item extends Component {
|
||||||
next(() => this.historyStore.delete("lastTopicIdViewed"));
|
next(() => this.historyStore.delete("lastTopicIdViewed"));
|
||||||
|
|
||||||
if (this.shouldFocusLastVisited) {
|
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")) {
|
} else if (this.args.topic.get("highlight")) {
|
||||||
// highlight new topics that have been loaded from the server or the one we just created
|
// 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) {
|
click(e) {
|
||||||
if (
|
if (
|
||||||
e.target.classList.contains("raw-topic-link") ||
|
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)) {
|
if (wantsNewWindow(e)) {
|
||||||
return;
|
return;
|
||||||
|
@ -163,7 +165,11 @@ export default class Item extends Component {
|
||||||
|
|
||||||
@action
|
@action
|
||||||
keyDown(e) {
|
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();
|
e.preventDefault();
|
||||||
this.navigateToTopic(this.args.topic, e.target.href);
|
this.navigateToTopic(this.args.topic, e.target.href);
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,9 @@ export default class TopicList extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
get bulkSelectEnabled() {
|
get bulkSelectEnabled() {
|
||||||
return this.args.bulkSelectHelper?.bulkSelectEnabled;
|
return (
|
||||||
|
this.args.bulkSelectHelper?.bulkSelectEnabled && this.args.canBulkSelect
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
get canDoBulkActions() {
|
get canDoBulkActions() {
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import { consolePrefix } from "discourse/lib/source-identifier";
|
|
||||||
import { registerDeprecationHandler } from "discourse-common/lib/deprecated";
|
import { registerDeprecationHandler } from "discourse-common/lib/deprecated";
|
||||||
import { needsHbrTopicList } from "discourse-common/lib/raw-templates";
|
import { needsHbrTopicList } from "discourse-common/lib/raw-templates";
|
||||||
|
|
||||||
|
@ -9,8 +8,6 @@ export default {
|
||||||
registerDeprecationHandler((message, opts) => {
|
registerDeprecationHandler((message, opts) => {
|
||||||
if (opts?.id === "discourse.hbr-topic-list-overrides") {
|
if (opts?.id === "discourse.hbr-topic-list-overrides") {
|
||||||
needsHbrTopicList(true);
|
needsHbrTopicList(true);
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.debug(consolePrefix(), message);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -176,6 +176,12 @@ const POST_MENU_DEPRECATION_OPTIONS = {
|
||||||
url: "https://meta.discourse.org/t/341014",
|
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();
|
const appliedModificationIds = new WeakMap();
|
||||||
|
|
||||||
// This helper prevents us from applying the same `modifyClass` over and over in test mode.
|
// This helper prevents us from applying the same `modifyClass` over and over in test mode.
|
||||||
|
@ -306,10 +312,7 @@ class PluginApi {
|
||||||
) {
|
) {
|
||||||
deprecated(
|
deprecated(
|
||||||
`Modifying '${resolverName}' with 'modifyClass' is deprecated. Use the value transformer 'topic-list-columns' and other new topic-list plugin APIs instead.`,
|
`Modifying '${resolverName}' with 'modifyClass' is deprecated. Use the value transformer 'topic-list-columns' and other new topic-list plugin APIs instead.`,
|
||||||
{
|
RAW_TOPIC_LIST_DEPRECATION_OPTIONS
|
||||||
since: "v3.4.0.beta3-dev",
|
|
||||||
id: "discourse.hbr-topic-list-overrides",
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -357,10 +360,7 @@ class PluginApi {
|
||||||
) {
|
) {
|
||||||
deprecated(
|
deprecated(
|
||||||
`Modifying '${resolverName}' with 'modifyClass' is deprecated. Use the value transformer 'topic-list-columns' and other new topic-list plugin APIs instead.`,
|
`Modifying '${resolverName}' with 'modifyClass' is deprecated. Use the value transformer 'topic-list-columns' and other new topic-list plugin APIs instead.`,
|
||||||
{
|
RAW_TOPIC_LIST_DEPRECATION_OPTIONS
|
||||||
since: "v3.4.0.beta3-dev",
|
|
||||||
id: "discourse.hbr-topic-list-overrides",
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import EmberObject from "@ember/object";
|
import EmberObject from "@ember/object";
|
||||||
|
import { RAW_TOPIC_LIST_DEPRECATION_OPTIONS } from "discourse/lib/plugin-api";
|
||||||
import deprecated from "discourse-common/lib/deprecated";
|
import deprecated from "discourse-common/lib/deprecated";
|
||||||
import discourseComputed from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
import { i18n } from "discourse-i18n";
|
import { i18n } from "discourse-i18n";
|
||||||
|
@ -7,10 +8,7 @@ export default class TopicStatus extends EmberObject {
|
||||||
static reopen() {
|
static reopen() {
|
||||||
deprecated(
|
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.",
|
"Modifying raw-view:topic-status with `reopen` is deprecated. Use the value transformer `topic-list-columns` and other new topic-list plugin APIs instead.",
|
||||||
{
|
RAW_TOPIC_LIST_DEPRECATION_OPTIONS
|
||||||
since: "v3.4.0.beta3-dev",
|
|
||||||
id: "discourse.hbr-topic-list-overrides",
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return super.reopen(...arguments);
|
return super.reopen(...arguments);
|
||||||
|
@ -19,10 +17,7 @@ export default class TopicStatus extends EmberObject {
|
||||||
static reopenClass() {
|
static reopenClass() {
|
||||||
deprecated(
|
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.",
|
"Modifying raw-view:topic-status with `reopenClass` is deprecated. Use the value transformer `topic-list-columns` and other new topic-list plugin APIs instead.",
|
||||||
{
|
RAW_TOPIC_LIST_DEPRECATION_OPTIONS
|
||||||
since: "v3.4.0.beta3-dev",
|
|
||||||
id: "discourse.hbr-topic-list-overrides",
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return super.reopenClass(...arguments);
|
return super.reopenClass(...arguments);
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { visit } from "@ember/test-helpers";
|
||||||
import { compile } from "handlebars";
|
import { compile } from "handlebars";
|
||||||
import { test } from "qunit";
|
import { test } from "qunit";
|
||||||
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
||||||
|
import { withSilencedDeprecations } from "discourse-common/lib/deprecated";
|
||||||
import {
|
import {
|
||||||
addRawTemplate,
|
addRawTemplate,
|
||||||
removeRawTemplate,
|
removeRawTemplate,
|
||||||
|
@ -12,10 +13,12 @@ const CONNECTOR =
|
||||||
|
|
||||||
acceptance("Raw Plugin Outlet", function (needs) {
|
acceptance("Raw Plugin Outlet", function (needs) {
|
||||||
needs.hooks.beforeEach(function () {
|
needs.hooks.beforeEach(function () {
|
||||||
addRawTemplate(
|
withSilencedDeprecations("discourse.hbr-topic-list-overrides", () => {
|
||||||
CONNECTOR,
|
addRawTemplate(
|
||||||
compile(`<span class='topic-lala'>{{context.topic.id}}</span>`)
|
CONNECTOR,
|
||||||
);
|
compile(`<span class='topic-lala'>{{context.topic.id}}</span>`)
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
needs.hooks.afterEach(function () {
|
needs.hooks.afterEach(function () {
|
||||||
|
|
|
@ -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");
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -3480,7 +3480,7 @@ experimental:
|
||||||
- disabled
|
- disabled
|
||||||
- auto
|
- auto
|
||||||
- enabled
|
- enabled
|
||||||
default: disabled
|
default: auto
|
||||||
glimmer_post_menu_mode:
|
glimmer_post_menu_mode:
|
||||||
client: true
|
client: true
|
||||||
type: enum
|
type: enum
|
||||||
|
|
|
@ -75,8 +75,7 @@ module PageObjects
|
||||||
end
|
end
|
||||||
|
|
||||||
def visit_topic_first_reply_via_keyboard(topic)
|
def visit_topic_first_reply_via_keyboard(topic)
|
||||||
find("#{topic_list_item_class(topic)} button.posts-map").native.send_keys(:return)
|
find("#{topic_list_item_class(topic)} a.badge-posts").native.send_keys(:return)
|
||||||
find("#topic-entrance button.jump-top").native.send_keys(:return)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def topic_list_item_class(topic)
|
def topic_list_item_class(topic)
|
||||||
|
@ -94,7 +93,7 @@ module PageObjects
|
||||||
private
|
private
|
||||||
|
|
||||||
def topic_list_item_closed(topic)
|
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
|
end
|
||||||
|
|
||||||
def topic_list_item_unread_badge(topic)
|
def topic_list_item_unread_badge(topic)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user