mirror of
https://github.com/discourse/discourse.git
synced 2025-01-16 04:52:43 +08:00
DEV: Drop deprecated decorateTopicTitle
API (#30626)
This commit is contained in:
parent
21c8376679
commit
61450b0947
|
@ -11,7 +11,6 @@ import {
|
||||||
} from "@ember-decorators/component";
|
} from "@ember-decorators/component";
|
||||||
import { observes, on } from "@ember-decorators/object";
|
import { observes, on } from "@ember-decorators/object";
|
||||||
import $ from "jquery";
|
import $ from "jquery";
|
||||||
import { topicTitleDecorators } from "discourse/components/topic-title";
|
|
||||||
import { wantsNewWindow } from "discourse/lib/intercept-click";
|
import { wantsNewWindow } from "discourse/lib/intercept-click";
|
||||||
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";
|
||||||
|
@ -128,17 +127,6 @@ export default class TopicListItem extends Component {
|
||||||
if (this.includeUnreadIndicator) {
|
if (this.includeUnreadIndicator) {
|
||||||
this.messageBus.subscribe(this.unreadIndicatorChannel, this.onMessage);
|
this.messageBus.subscribe(this.unreadIndicatorChannel, this.onMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
schedule("afterRender", () => {
|
|
||||||
if (this.element && !this.isDestroying && !this.isDestroyed) {
|
|
||||||
const rawTopicLink = this.element.querySelector(".raw-topic-link");
|
|
||||||
|
|
||||||
rawTopicLink &&
|
|
||||||
topicTitleDecorators.forEach((cb) =>
|
|
||||||
cb(this.topic, rawTopicLink, "topic-list-item-title")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
willDestroyElement() {
|
willDestroyElement() {
|
||||||
|
|
|
@ -2,7 +2,6 @@ import Component from "@glimmer/component";
|
||||||
import { array, concat, hash } from "@ember/helper";
|
import { array, concat, hash } from "@ember/helper";
|
||||||
import { on } from "@ember/modifier";
|
import { on } from "@ember/modifier";
|
||||||
import { action } from "@ember/object";
|
import { action } from "@ember/object";
|
||||||
import didInsert from "@ember/render-modifiers/modifiers/did-insert";
|
|
||||||
import { next } from "@ember/runloop";
|
import { next } from "@ember/runloop";
|
||||||
import { service } from "@ember/service";
|
import { service } from "@ember/service";
|
||||||
import { modifier } from "ember-modifier";
|
import { modifier } from "ember-modifier";
|
||||||
|
@ -12,7 +11,6 @@ import PostCountOrBadges from "discourse/components/topic-list/post-count-or-bad
|
||||||
import TopicExcerpt from "discourse/components/topic-list/topic-excerpt";
|
import TopicExcerpt from "discourse/components/topic-list/topic-excerpt";
|
||||||
import TopicLink from "discourse/components/topic-list/topic-link";
|
import TopicLink from "discourse/components/topic-list/topic-link";
|
||||||
import TopicStatus from "discourse/components/topic-status";
|
import TopicStatus from "discourse/components/topic-status";
|
||||||
import { topicTitleDecorators } from "discourse/components/topic-title";
|
|
||||||
import avatar from "discourse/helpers/avatar";
|
import avatar from "discourse/helpers/avatar";
|
||||||
import categoryLink from "discourse/helpers/category-link";
|
import categoryLink from "discourse/helpers/category-link";
|
||||||
import concatClass from "discourse/helpers/concat-class";
|
import concatClass from "discourse/helpers/concat-class";
|
||||||
|
@ -104,17 +102,6 @@ export default class Item extends Component {
|
||||||
event.target.closest(".topic-list-item").classList.remove("selected");
|
event.target.closest(".topic-list-item").classList.remove("selected");
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
|
||||||
applyTitleDecorators(element) {
|
|
||||||
const rawTopicLink = element.querySelector(".raw-topic-link");
|
|
||||||
|
|
||||||
if (rawTopicLink) {
|
|
||||||
topicTitleDecorators?.forEach((cb) =>
|
|
||||||
cb(this.args.topic, rawTopicLink, "topic-list-item-title")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@action
|
@action
|
||||||
onBulkSelectToggle(e) {
|
onBulkSelectToggle(e) {
|
||||||
if (e.target.checked) {
|
if (e.target.checked) {
|
||||||
|
@ -193,7 +180,6 @@ export default class Item extends Component {
|
||||||
<template>
|
<template>
|
||||||
<tr
|
<tr
|
||||||
{{! template-lint-disable no-invalid-interactive }}
|
{{! template-lint-disable no-invalid-interactive }}
|
||||||
{{didInsert this.applyTitleDecorators}}
|
|
||||||
{{this.highlightIfNeeded}}
|
{{this.highlightIfNeeded}}
|
||||||
{{on "keydown" this.keyDown}}
|
{{on "keydown" this.keyDown}}
|
||||||
{{on "click" this.click}}
|
{{on "click" this.click}}
|
||||||
|
|
|
@ -2,37 +2,15 @@ import Component from "@glimmer/component";
|
||||||
import { hash } from "@ember/helper";
|
import { hash } from "@ember/helper";
|
||||||
import { on } from "@ember/modifier";
|
import { on } from "@ember/modifier";
|
||||||
import { action } from "@ember/object";
|
import { action } from "@ember/object";
|
||||||
import didInsert from "@ember/render-modifiers/modifiers/did-insert";
|
|
||||||
import willDestroy from "@ember/render-modifiers/modifiers/will-destroy";
|
import willDestroy from "@ember/render-modifiers/modifiers/will-destroy";
|
||||||
import { service } from "@ember/service";
|
import { service } from "@ember/service";
|
||||||
import PluginOutlet from "discourse/components/plugin-outlet";
|
import PluginOutlet from "discourse/components/plugin-outlet";
|
||||||
import { isiPad } from "discourse/lib/utilities";
|
import { isiPad } from "discourse/lib/utilities";
|
||||||
import observeIntersection from "discourse/modifiers/observe-intersection";
|
import observeIntersection from "discourse/modifiers/observe-intersection";
|
||||||
|
|
||||||
export let topicTitleDecorators = [];
|
|
||||||
|
|
||||||
export function addTopicTitleDecorator(decorator) {
|
|
||||||
topicTitleDecorators.push(decorator);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function resetTopicTitleDecorators() {
|
|
||||||
topicTitleDecorators.length = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default class TopicTitle extends Component {
|
export default class TopicTitle extends Component {
|
||||||
@service header;
|
@service header;
|
||||||
|
|
||||||
@action
|
|
||||||
applyDecorators(element) {
|
|
||||||
const fancyTitle = element.querySelector(".fancy-title");
|
|
||||||
|
|
||||||
if (fancyTitle) {
|
|
||||||
topicTitleDecorators.forEach((cb) =>
|
|
||||||
cb(this.args.model, fancyTitle, "topic-title")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@action
|
@action
|
||||||
keyDown(e) {
|
keyDown(e) {
|
||||||
if (e.key === "Escape") {
|
if (e.key === "Escape") {
|
||||||
|
@ -66,7 +44,6 @@ export default class TopicTitle extends Component {
|
||||||
<template>
|
<template>
|
||||||
{{! template-lint-disable no-invalid-interactive }}
|
{{! template-lint-disable no-invalid-interactive }}
|
||||||
<div
|
<div
|
||||||
{{didInsert this.applyDecorators}}
|
|
||||||
{{on "keydown" this.keyDown}}
|
{{on "keydown" this.keyDown}}
|
||||||
{{observeIntersection this.handleIntersectionChange}}
|
{{observeIntersection this.handleIntersectionChange}}
|
||||||
{{willDestroy this.handleTitleDestroy}}
|
{{willDestroy this.handleTitleDestroy}}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
// docs/CHANGELOG-JAVASCRIPT-PLUGIN-API.md whenever you change the version
|
// docs/CHANGELOG-JAVASCRIPT-PLUGIN-API.md whenever you change the version
|
||||||
// using the format described at https://keepachangelog.com/en/1.0.0/.
|
// using the format described at https://keepachangelog.com/en/1.0.0/.
|
||||||
|
|
||||||
export const PLUGIN_API_VERSION = "1.39.2";
|
export const PLUGIN_API_VERSION = "2.0.0";
|
||||||
|
|
||||||
import $ from "jquery";
|
import $ from "jquery";
|
||||||
import { h } from "virtual-dom";
|
import { h } from "virtual-dom";
|
||||||
|
@ -41,7 +41,6 @@ import { addOnKeyUpCallback } from "discourse/components/search-menu/search-term
|
||||||
import { REFRESH_COUNTS_APP_EVENT_NAME as REFRESH_USER_SIDEBAR_CATEGORIES_SECTION_COUNTS_APP_EVENT_NAME } from "discourse/components/sidebar/user/categories-section";
|
import { REFRESH_COUNTS_APP_EVENT_NAME as REFRESH_USER_SIDEBAR_CATEGORIES_SECTION_COUNTS_APP_EVENT_NAME } from "discourse/components/sidebar/user/categories-section";
|
||||||
import { addTopicParticipantClassesCallback } from "discourse/components/topic-map/topic-participant";
|
import { addTopicParticipantClassesCallback } from "discourse/components/topic-map/topic-participant";
|
||||||
import { setDesktopScrollAreaHeight } from "discourse/components/topic-timeline/container";
|
import { setDesktopScrollAreaHeight } from "discourse/components/topic-timeline/container";
|
||||||
import { addTopicTitleDecorator } from "discourse/components/topic-title";
|
|
||||||
import { setNotificationsLimit as setUserMenuNotificationsLimit } from "discourse/components/user-menu/notifications-list";
|
import { setNotificationsLimit as setUserMenuNotificationsLimit } from "discourse/components/user-menu/notifications-list";
|
||||||
import { addUserMenuProfileTabItem } from "discourse/components/user-menu/profile-tab-content";
|
import { addUserMenuProfileTabItem } from "discourse/components/user-menu/profile-tab-content";
|
||||||
import { addDiscoveryQueryParam } from "discourse/controllers/discovery/list";
|
import { addDiscoveryQueryParam } from "discourse/controllers/discovery/list";
|
||||||
|
@ -2066,33 +2065,6 @@ class PluginApi {
|
||||||
setDesktopScrollAreaHeight(height);
|
setDesktopScrollAreaHeight(height);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Allows altering the topic title in the topic list, and in the topic view
|
|
||||||
*
|
|
||||||
* topicTitleType can be `topic-title` or `topic-list-item-title`
|
|
||||||
*
|
|
||||||
* For example, to replace the topic title:
|
|
||||||
*
|
|
||||||
* ```
|
|
||||||
* api.decorateTopicTitle((topicModel, node, topicTitleType) => {
|
|
||||||
* node.innerText = "my new topic title";
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* @deprecated because modifying an Ember-rendered DOM tree can lead to very unexpected errors. Use plugin outlet connectors instead
|
|
||||||
**/
|
|
||||||
decorateTopicTitle(callback) {
|
|
||||||
deprecated(
|
|
||||||
"decorateTopicTitle is deprecated because modifying an Ember-rendered DOM tree can lead to very unexpected errors. Use plugin outlet connectors instead",
|
|
||||||
{
|
|
||||||
id: "discourse.decorate-topic-title",
|
|
||||||
since: "3.2",
|
|
||||||
dropFrom: "3.3",
|
|
||||||
}
|
|
||||||
);
|
|
||||||
addTopicTitleDecorator(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows a different limit to be set for fetching recent notifications for the user menu
|
* Allows a different limit to be set for fetching recent notifications for the user menu
|
||||||
*
|
*
|
||||||
|
|
|
@ -6,7 +6,6 @@ import {
|
||||||
visit,
|
visit,
|
||||||
} from "@ember/test-helpers";
|
} from "@ember/test-helpers";
|
||||||
import { test } from "qunit";
|
import { test } from "qunit";
|
||||||
import { withPluginApi } from "discourse/lib/plugin-api";
|
|
||||||
import CategoryFixtures from "discourse/tests/fixtures/category-fixtures";
|
import CategoryFixtures from "discourse/tests/fixtures/category-fixtures";
|
||||||
import topicFixtures from "discourse/tests/fixtures/topic";
|
import topicFixtures from "discourse/tests/fixtures/topic";
|
||||||
import {
|
import {
|
||||||
|
@ -16,7 +15,6 @@ import {
|
||||||
selectText,
|
selectText,
|
||||||
} from "discourse/tests/helpers/qunit-helpers";
|
} from "discourse/tests/helpers/qunit-helpers";
|
||||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||||
import { withSilencedDeprecations } from "discourse-common/lib/deprecated";
|
|
||||||
import { cloneJSON } from "discourse-common/lib/object";
|
import { cloneJSON } from "discourse-common/lib/object";
|
||||||
import { i18n } from "discourse-i18n";
|
import { i18n } from "discourse-i18n";
|
||||||
|
|
||||||
|
@ -452,34 +450,6 @@ acceptance("Topic featured links", function (needs) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
acceptance("Topic with title decorated", function (needs) {
|
|
||||||
needs.user();
|
|
||||||
needs.hooks.beforeEach(() => {
|
|
||||||
withPluginApi("0.8.40", (api) => {
|
|
||||||
withSilencedDeprecations("discourse.decorate-topic-title", () => {
|
|
||||||
api.decorateTopicTitle((topic, node, topicTitleType) => {
|
|
||||||
node.innerText = `${node.innerText}-${topic.id}-${topicTitleType}`;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Decorate topic title", async function (assert) {
|
|
||||||
await visit("/t/internationalization-localization/280");
|
|
||||||
|
|
||||||
assert
|
|
||||||
.dom(".fancy-title")
|
|
||||||
.hasText(/-280-topic-title$/, "decorates topic title");
|
|
||||||
|
|
||||||
assert
|
|
||||||
.dom(".raw-topic-link:nth-child(1)")
|
|
||||||
.hasText(
|
|
||||||
/-27331-topic-list-item-title$/,
|
|
||||||
"decorates topic list item title"
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
acceptance("Topic pinning/unpinning as an admin", function (needs) {
|
acceptance("Topic pinning/unpinning as an admin", function (needs) {
|
||||||
needs.user({ admin: true });
|
needs.user({ admin: true });
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@ import { resetDecorators as resetPluginOutletDecorators } from "discourse/compon
|
||||||
import { resetItemSelectCallbacks } from "discourse/components/search-menu/results/assistant-item";
|
import { resetItemSelectCallbacks } from "discourse/components/search-menu/results/assistant-item";
|
||||||
import { resetQuickSearchRandomTips } from "discourse/components/search-menu/results/random-quick-tip";
|
import { resetQuickSearchRandomTips } from "discourse/components/search-menu/results/random-quick-tip";
|
||||||
import { resetOnKeyUpCallbacks } from "discourse/components/search-menu/search-term";
|
import { resetOnKeyUpCallbacks } from "discourse/components/search-menu/search-term";
|
||||||
import { resetTopicTitleDecorators } from "discourse/components/topic-title";
|
|
||||||
import { resetUserMenuProfileTabItems } from "discourse/components/user-menu/profile-tab-content";
|
import { resetUserMenuProfileTabItems } from "discourse/components/user-menu/profile-tab-content";
|
||||||
import { resetCustomPostMessageCallbacks } from "discourse/controllers/topic";
|
import { resetCustomPostMessageCallbacks } from "discourse/controllers/topic";
|
||||||
import { clearHTMLCache } from "discourse/helpers/custom-html";
|
import { clearHTMLCache } from "discourse/helpers/custom-html";
|
||||||
|
@ -208,7 +207,6 @@ export function testCleanup(container, app) {
|
||||||
resetDecorators();
|
resetDecorators();
|
||||||
resetPostCookedDecorators();
|
resetPostCookedDecorators();
|
||||||
resetPluginOutletDecorators();
|
resetPluginOutletDecorators();
|
||||||
resetTopicTitleDecorators();
|
|
||||||
resetUsernameDecorators();
|
resetUsernameDecorators();
|
||||||
resetOneboxCache();
|
resetOneboxCache();
|
||||||
resetCustomPostMessageCallbacks();
|
resetCustomPostMessageCallbacks();
|
||||||
|
|
|
@ -7,6 +7,10 @@ in this file.
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [2.0.0] - 2025-01-07
|
||||||
|
|
||||||
|
- Removed `decorateTopicTitle`. This has been deprecated for more than a year, and we are not aware of any remaining uses in the ecosystem.
|
||||||
|
|
||||||
## [1.39.2] - 2024-12-19
|
## [1.39.2] - 2024-12-19
|
||||||
|
|
||||||
- Removed the deprecation of `includePostAttributes` for now.
|
- Removed the deprecation of `includePostAttributes` for now.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user