Skip to content

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

DEV: Drop legacy topic-list and raw-handlebars compilation system (#32081)

David Taylorf0057c7353b8
diff --git a/app/assets/javascripts/admin/addon/helpers/check-icon.js b/app/assets/javascripts/admin/addon/helpers/check-icon.js
index 0bbee5787b3..71e1dafde67 100644
--- a/app/assets/javascripts/admin/addon/helpers/check-icon.js
+++ b/app/assets/javascripts/admin/addon/helpers/check-icon.js
@@ -1,9 +1,6 @@
import { htmlSafe } from "@ember/template";
-import { registerRawHelper } from "discourse/lib/helpers";
import { renderIcon } from "discourse/lib/icon-library";
-registerRawHelper("check-icon", checkIcon);
-
export default function checkIcon(value) {
let icon = value ? "check" : "xmark";
return htmlSafe(renderIcon("string", icon));
diff --git a/app/assets/javascripts/discourse-hbr/.npmrc b/app/assets/javascripts/discourse-hbr/.npmrc
deleted file mode 100644
index c42da845b44..00000000000
--- a/app/assets/javascripts/discourse-hbr/.npmrc
+++ /dev/null
@@ -1 +0,0 @@
-engine-strict = true
diff --git a/app/assets/javascripts/discourse-hbr/package.json b/app/assets/javascripts/discourse-hbr/package.json
deleted file mode 100644
index 75dbe4e1d9e..00000000000
--- a/app/assets/javascripts/discourse-hbr/package.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "name": "discourse-hbr",
- "version": "1.0.0",
- "description": "Support for Discourse's raw Handlebars templates (hbr)",
- "author": "Discourse",
- "license": "GPL-2.0-only",
- "dependencies": {
- "handlebars": "^4.7.8",
- "broccoli-filter": "^1.3.0"
- },
- "engines": {
- "node": ">= 18",
- "npm": "please-use-pnpm",
- "yarn": "please-use-pnpm",
- "pnpm": "^9"
- },
- "exports": {
- "./raw-handlebars-compiler": "./raw-handlebars-compiler.js"
- }
-}
diff --git a/app/assets/javascripts/discourse-hbr/raw-handlebars-compiler.js b/app/assets/javascripts/discourse-hbr/raw-handlebars-compiler.js
deleted file mode 100644
index c26cc1ab001..00000000000
--- a/app/assets/javascripts/discourse-hbr/raw-handlebars-compiler.js
+++ /dev/null
@@ -1,174 +0,0 @@
-"use strict";
-
-const Filter = require("broccoli-filter");
-const Handlebars = require("handlebars");
-
-const RawHandlebars = Handlebars.create();
-
-function buildPath(blk, args) {
- let result = {
- type: "PathExpression",
- data: false,
- depth: blk.path.depth,
- loc: blk.path.loc,
- };
-
- // Server side precompile doesn't have jquery.extend
- Object.keys(args).forEach(function (a) {
- result[a] = args[a];
- });
-
- return result;
-}
-
-function replaceGet(ast) {
- let visitor = new Handlebars.Visitor();
- visitor.mutating = true;
-
- visitor.MustacheStatement = function (mustache) {
- if (!(mustache.params.length || mustache.hash)) {
- mustache.params[0] = mustache.path;
- mustache.path = buildPath(mustache, {
- parts: ["get"],
- original: "get",
- strict: true,
- falsy: true,
- });
- }
- return Handlebars.Visitor.prototype.MustacheStatement.call(this, mustache);
- };
-
- // rewrite `each x as |y|` as each y in x`
- // This allows us to use the same syntax in all templates
- visitor.BlockStatement = function (block) {
- if (block.path.original === "each" && block.params.length === 1) {
- let paramName = block.program.blockParams[0];
- block.params = [
- buildPath(block, { original: paramName }),
- { type: "CommentStatement", value: "in" },
- block.params[0],
- ];
- delete block.program.blockParams;
- }
-
- return Handlebars.Visitor.prototype.BlockStatement.call(this, block);
- };
-
- visitor.accept(ast);
-}
-
-RawHandlebars.Compiler = function () {};
-RawHandlebars.Compiler.prototype = Object.create(Handlebars.Compiler.prototype);
-RawHandlebars.Compiler.prototype.compiler = RawHandlebars.Compiler;
-
-RawHandlebars.JavaScriptCompiler = function () {};
-
-RawHandlebars.JavaScriptCompiler.prototype = Object.create(
- Handlebars.JavaScriptCompiler.prototype
-);
-RawHandlebars.JavaScriptCompiler.prototype.compiler =
- RawHandlebars.JavaScriptCompiler;
-RawHandlebars.JavaScriptCompiler.prototype.namespace = "RawHandlebars";
-
-RawHandlebars.precompile = function (value, asObject) {
- let ast = Handlebars.parse(value);
- replaceGet(ast);
-
- let options = {
- knownHelpers: {
- get: true,
- },
- data: true,
- stringParams: true,
- };
-
- asObject = asObject === undefined ? true : asObject;
-
- let environment = new RawHandlebars.Compiler().compile(ast, options);
- return new RawHandlebars.JavaScriptCompiler().compile(
- environment,
- options,
- undefined,
- asObject
- );
-};
-
-RawHandlebars.compile = function (string) {
- let ast = Handlebars.parse(string);
- replaceGet(ast);
-
- // this forces us to rewrite helpers
- let options = { data: true, stringParams: true };
- let environment = new RawHandlebars.Compiler().compile(ast, options);
- let templateSpec = new RawHandlebars.JavaScriptCompiler().compile(
- environment,
- options,
- undefined,
- true
- );
-
- let t = RawHandlebars.template(templateSpec);
- t.isMethod = false;
-
- return t;
-};
-function TemplateCompiler(inputTree, options) {
- if (!(this instanceof TemplateCompiler)) {
- return new TemplateCompiler(inputTree, options);
- }
-
- Filter.call(this, inputTree, options); // this._super()
-
- this.options = options || {};
- this.inputTree = inputTree;
-}
-
-TemplateCompiler.prototype = Object.create(Filter.prototype);
-TemplateCompiler.prototype.constructor = TemplateCompiler;
-TemplateCompiler.prototype.extensions = ["hbr"];
-TemplateCompiler.prototype.targetExtension = "js";
-
-TemplateCompiler.prototype.registerPlugins = function registerPlugins() {};
-
-TemplateCompiler.prototype.initializeFeatures =
- function initializeFeatures() {};
-
-TemplateCompiler.prototype.processString = function (string, relativePath) {
- let filename;
-
- const pluginName = relativePath.match(/^discourse\/plugins\/([^\/]+)\//)?.[1];
-
- if (pluginName) {
- filename = relativePath
- .replace(`discourse/plugins/${pluginName}/`, "")
- .replace(/^(discourse\/)?raw-templates\//, "javascripts/");
- } else {
- filename = relativePath.replace(/^raw-templates\//, "");
- }
-
- filename = filename.replace(/\.hbr$/, "");
- const hasModernReplacement = string.includes(
- "{{!-- has-modern-replacement --}}"
- );
-
- return `
- import { template as compiler } from "discourse/lib/raw-handlebars";
- import { addRawTemplate } from "discourse/lib/raw-templates";
-
- let template = compiler(${this.precompile(string, false)});
-
- addRawTemplate("${filename}", template, {
- core: ${!pluginName},
- pluginName: ${JSON.stringify(pluginName)},
- hasModernReplacement: ${hasModernReplacement},
- });
-
- export default template;
- `;
-};
-
-TemplateCompiler.prototype.precompile = function (value, asObject) {
- return RawHandlebars.precompile(value, asObject);
-};
-
-module.exports = TemplateCompiler;
diff --git a/app/assets/javascripts/discourse-plugins/index.js b/app/assets/javascripts/discourse-plugins/index.js
index bb3f2baba34..624a9ab0c8c 100644
--- a/app/assets/javascripts/discourse-plugins/index.js
+++ b/app/assets/javascripts/discourse-plugins/index.js
@@ -6,7 +6,6 @@ const Funnel = require("broccoli-funnel");
const mergeTrees = require("broccoli-merge-trees");
const fs = require("fs");
const concat = require("broccoli-concat");
-const RawHandlebarsCompiler = require("discourse-hbr/raw-handlebars-compiler");
const DiscoursePluginColocatedTemplateProcessor = require("./colocated-template-compiler");
const EmberApp = require("ember-cli/lib/broccoli/ember-app");
@@ -15,19 +14,6 @@ function fixLegacyExtensions(tree) {
getDestinationPath: function (relativePath) {
if (relativePath.endsWith(".es6")) {
return relativePath.slice(0, -4);
- } else if (relativePath.endsWith(".raw.hbs")) {
- relativePath = relativePath.replace(".raw.hbs", ".hbr");
- }
-
- if (relativePath.endsWith(".hbr")) {
- if (relativePath.includes("/templates/")) {
- relativePath = relativePath.replace("/templates/", "/raw-templates/");
- } else if (relativePath.includes("/connectors/")) {
- relativePath = relativePath.replace(
- "/connectors/",
- "/raw-templates/connectors/"
- );
- }
}
return relativePath;
@@ -201,8 +187,6 @@ module.exports = {
tree = unColocateConnectors(tree);
tree = namespaceModules(tree, pluginName);
- tree = RawHandlebarsCompiler(tree);
-
const colocateBase = `discourse/plugins/${pluginName}`;
tree = new DiscoursePluginColocatedTemplateProcessor(
tree,
diff --git a/app/assets/javascripts/discourse-plugins/package.json b/app/assets/javascripts/discourse-plugins/package.json
index 3001df18b3f..2d0a66dfe37 100644
--- a/app/assets/javascripts/discourse-plugins/package.json
+++ b/app/assets/javascripts/discourse-plugins/package.json
@@ -10,7 +10,6 @@
"dependencies": {
"@babel/core": "^7.26.10",
"deprecation-silencer": "workspace:1.0.0",
- "discourse-hbr": "workspace:1.0.0",
"discourse-widget-hbs": "workspace:1.0.0",
"ember-cli-babel": "^8.2.0",
"ember-cli-htmlbars": "^6.3.0",
diff --git a/app/assets/javascripts/discourse-widget-hbs/package.json b/app/assets/javascripts/discourse-widget-hbs/package.json
index 0007bb8a065..50e3bfa1aa5 100644
--- a/app/assets/javascripts/discourse-widget-hbs/package.json
+++ b/app/assets/javascripts/discourse-widget-hbs/package.json
@@ -17,8 +17,7 @@
"@babel/core": "^7.26.10",
"ember-auto-import": "^2.10.0",
"ember-cli-babel": "^8.2.0",
- "ember-cli-htmlbars": "^6.3.0",
- "handlebars": "^4.7.8"
+ "ember-cli-htmlbars": "^6.3.0"
},
"devDependencies": {
"@ember/optional-features": "^2.2.0",
diff --git a/app/assets/javascripts/discourse/app/components/basic-topic-list.gjs b/app/assets/javascripts/discourse/app/components/basic-topic-list.gjs
index 673619091f3..3a99a67ca08 100644
--- a/app/assets/javascripts/discourse/app/components/basic-topic-list.gjs
+++ b/app/assets/javascripts/discourse/app/components/basic-topic-list.gjs
@@ -4,7 +4,6 @@ import { service } from "@ember/service";
import { observes } from "@ember-decorators/object";
import $ from "jquery";
import ConditionalLoadingSpinner from "discourse/components/conditional-loading-spinner";
-import TopicList from "discourse/components/topic-list";
import List from "discourse/components/topic-list/list";
import discourseComputed, { bind } from "discourse/lib/decorators";
import { i18n } from "discourse-i18n";
@@ -122,35 +121,19 @@ export default class BasicTopicList extends Component {
<template>
<ConditionalLoadingSpinner @condition={{this.loading}}>
{{#if this.topics}}
- {{#if this.site.useGlimmerTopicList}}
- <List
- @showPosters={{this.showPosters}}
- @hideCategory={{this.hideCategory}}
- @topics={{this.topics}}
- @expandExcerpts={{this.expandExcerpts}}
- @bulkSelectHelper={{this.bulkSelectHelper}}
- @canBulkSelect={{this.canBulkSelect}}
- @tagsForUser={{this.tagsForUser}}
- @changeSort={{this.changeSort}}
- @order={{this.order}}
- @ascending={{this.ascending}}
- @focusLastVisitedTopic={{this.focusLastVisitedTopic}}
- />
- {{else}}
- <TopicList
- @showPosters={{this.showPosters}}
- @hideCategory={{this.hideCategory}}
- @topics={{this.topics}}
- @expandExcerpts={{this.expandExcerpts}}
- @bulkSelectHelper={{this.bulkSelectHelper}}
- @canBulkSelect={{this.canBulkSelect}}
- @tagsForUser={{this.tagsForUser}}
- @changeSort={{this.changeSort}}
- @order={{this.order}}
- @ascending={{this.ascending}}
- @focusLastVisitedTopic={{this.focusLastVisitedTopic}}
- />
- {{/if}}
+ <List
+ @showPosters={{this.showPosters}}
+ @hideCategory={{this.hideCategory}}
+ @topics={{this.topics}}
+ @expandExcerpts={{this.expandExcerpts}}
+ @bulkSelectHelper={{this.bulkSelectHelper}}
+ @canBulkSelect={{this.canBulkSelect}}
+ @tagsForUser={{this.tagsForUser}}
+ @changeSort={{this.changeSort}}
+ @order={{this.order}}
+ @ascending={{this.ascending}}
+ @focusLastVisitedTopic={{this.focusLastVisitedTopic}}
+ />
{{else}}
{{#unless this.loadingMore}}
<div class="alert alert-info">
diff --git a/app/assets/javascripts/discourse/app/components/categories-topic-list.gjs b/app/assets/javascripts/discourse/app/components/categories-topic-list.gjs
index 3f8169b0dfc..1cddf61d6f8 100644
--- a/app/assets/javascripts/discourse/app/components/categories-topic-list.gjs
+++ b/app/assets/javascripts/discourse/app/components/categories-topic-list.gjs
@@ -19,11 +19,7 @@ export default class CategoriesTopicList extends Component {
{{#if this.topics}}
{{#each this.topics as |t|}}
- {{#if this.site.useGlimmerTopicList}}
- <LatestTopicListItem @topic={{t}} />
- {{else}}
- <LatestTopicListItem @topic={{t}} />
- {{/if}}
+ <LatestTopicListItem @topic={{t}} />
{{/each}}
<div class="more-topics">
diff --git a/app/assets/javascripts/discourse/app/components/discovery/topics.gjs b/app/assets/javascripts/discourse/app/components/discovery/topics.gjs
index da68ff16965..d8e70f7f5f2 100644
--- a/app/assets/javascripts/discourse/app/components/discovery/topics.gjs
+++ b/app/assets/javascripts/discourse/app/components/discovery/topics.gjs
@@ -14,7 +14,6 @@ import NewListHeaderControlsWrapper from "discourse/components/new-list-header-c
import PluginOutlet from "discourse/components/plugin-outlet";
import TopPeriodButtons from "discourse/components/top-period-buttons";
import TopicDismissButtons from "discourse/components/topic-dismiss-buttons";
-import TopicList from "discourse/components/topic-list";
import List from "discourse/components/topic-list/list";
import basePath from "discourse/helpers/base-path";
import hideApplicationFooter from "discourse/helpers/hide-application-footer";
@@ -209,27 +208,15 @@ export default class DiscoveryTopics extends Component {
{{/if}}
{{#if @model.sharedDrafts}}
- {{#if this.site.useGlimmerTopicList}}
- <List
- @listTitle="shared_drafts.title"
- @top={{this.top}}
- @hideCategory="true"
- @category={{@category}}
- @topics={{@model.sharedDrafts}}
- @discoveryList={{true}}
- class="shared-drafts"
- />
- {{else}}
- <TopicList
- @listTitle="shared_drafts.title"
- @top={{this.top}}
- @hideCategory="true"
- @category={{@category}}
- @topics={{@model.sharedDrafts}}
- @discoveryList={{true}}
- class="shared-drafts"
- />
- {{/if}}
+ <List
+ @listTitle="shared_drafts.title"
+ @top={{this.top}}
+ @hideCategory="true"
+ @category={{@category}}
+ @topics={{@model.sharedDrafts}}
+ @discoveryList={{true}}
+ class="shared-drafts"
+ />
{{/if}}
<DiscoveryTopicsList
@@ -290,57 +277,30 @@ export default class DiscoveryTopics extends Component {
</span>
{{#if this.hasTopics}}
- {{#if this.site.useGlimmerTopicList}}
- <List
- @highlightLastVisited={{true}}
- @top={{this.top}}
- @hot={{this.hot}}
- @showTopicPostBadges={{this.showTopicPostBadges}}
- @showPosters={{true}}
- @canBulkSelect={{@canBulkSelect}}
- @bulkSelectHelper={{@bulkSelectHelper}}
- @changeSort={{@changeSort}}
- @hideCategory={{@model.hideCategory}}
- @order={{this.order}}
- @ascending={{this.ascending}}
- @expandGloballyPinned={{this.expandGloballyPinned}}
- @expandAllPinned={{this.expandAllPinned}}
- @category={{@category}}
- @topics={{@model.topics}}
- @discoveryList={{true}}
- @focusLastVisitedTopic={{true}}
- @showTopicsAndRepliesToggle={{this.showTopicsAndRepliesToggle}}
- @newListSubset={{@model.params.subset}}
- @changeNewListSubset={{@changeNewListSubset}}
- @newRepliesCount={{this.newRepliesCount}}
- @newTopicsCount={{this.newTopicsCount}}
- />
- {{else}}
- <TopicList
- @highlightLastVisited={{true}}
- @top={{this.top}}
- @hot={{this.hot}}
- @showTopicPostBadges={{this.showTopicPostBadges}}
- @showPosters={{true}}
- @canBulkSelect={{@canBulkSelect}}
- @bulkSelectHelper={{@bulkSelectHelper}}
- @changeSort={{@changeSort}}
- @hideCategory={{@model.hideCategory}}
- @order={{this.order}}
- @ascending={{this.ascending}}
- @expandGloballyPinned={{this.expandGloballyPinned}}
- @expandAllPinned={{this.expandAllPinned}}
- @category={{@category}}
- @topics={{@model.topics}}
- @discoveryList={{true}}
- @focusLastVisitedTopic={{true}}
- @showTopicsAndRepliesToggle={{this.showTopicsAndRepliesToggle}}
- @newListSubset={{@model.params.subset}}
- @changeNewListSubset={{@changeNewListSubset}}
- @newRepliesCount={{this.newRepliesCount}}
- @newTopicsCount={{this.newTopicsCount}}
- />
- {{/if}}
+ <List
+ @highlightLastVisited={{true}}
+ @top={{this.top}}
+ @hot={{this.hot}}
+ @showTopicPostBadges={{this.showTopicPostBadges}}
+ @showPosters={{true}}
+ @canBulkSelect={{@canBulkSelect}}
+ @bulkSelectHelper={{@bulkSelectHelper}}
+ @changeSort={{@changeSort}}
+ @hideCategory={{@model.hideCategory}}
+ @order={{this.order}}
+ @ascending={{this.ascending}}
+ @expandGloballyPinned={{this.expandGloballyPinned}}
+ @expandAllPinned={{this.expandAllPinned}}
+ @category={{@category}}
+ @topics={{@model.topics}}
+ @discoveryList={{true}}
+ @focusLastVisitedTopic={{true}}
+ @showTopicsAndRepliesToggle={{this.showTopicsAndRepliesToggle}}
+ @newListSubset={{@model.params.subset}}
+ @changeNewListSubset={{@changeNewListSubset}}
+ @newRepliesCount={{this.newRepliesCount}}
+ @newTopicsCount={{this.newTopicsCount}}
+ />
{{/if}}
<span class="after-topic-list-plugin-outlet-wrapper">
diff --git a/app/assets/javascripts/discourse/app/components/latest-topic-list-item.gjs b/app/assets/javascripts/discourse/app/components/latest-topic-list-item.gjs
deleted file mode 100644
index 5e94aa7a46c..00000000000
--- a/app/assets/javascripts/discourse/app/components/latest-topic-list-item.gjs
+++ /dev/null
@@ -1,127 +0,0 @@
-import Component from "@ember/component";
-import { hash } from "@ember/helper";
-import {
- attributeBindings,
- classNameBindings,
-} from "@ember-decorators/component";
-import PluginOutlet from "discourse/components/plugin-outlet";
-import ItemRepliesCell from "discourse/components/topic-list/item/replies-cell";
-import {
- navigateToTopic,
- showEntrance,
-} from "discourse/components/topic-list-item";
-import TopicPostBadges from "discourse/components/topic-post-badges";
-import TopicStatus from "discourse/components/topic-status";
-import UserAvatarFlair from "discourse/components/user-avatar-flair";
-import UserLink from "discourse/components/user-link";
-import avatar from "discourse/helpers/avatar";
-import categoryLink from "discourse/helpers/category-link";
-import discourseTags from "discourse/helpers/discourse-tags";
-import formatDate from "discourse/helpers/format-date";
-import topicFeaturedLink from "discourse/helpers/topic-featured-link";
-import topicLink from "discourse/helpers/topic-link";
-import discourseComputed from "discourse/lib/decorators";
-import { i18n } from "discourse-i18n";
-
-@attributeBindings("topic.id:data-topic-id")
-@classNameBindings(":latest-topic-list-item", "unboundClassNames")
-export default class LatestTopicListItem extends Component {
- showEntrance = showEntrance;
- navigateToTopic = navigateToTopic;
-
- click(e) {
- // for events undefined has a different meaning than false
- if (this.showEntrance(e) === false) {
- return false;
- }
-
- return this.unhandledRowClick(e, this.topic);
- }
-
- // Can be overwritten by plugins to handle clicks on other parts of the row
- unhandledRowClick() {}
-
- @discourseComputed("topic")
- unboundClassNames(topic) {
- let classes = [];
-
- if (topic.get("category")) {
- classes.push("category-" + topic.get("category.fullSlug"));
- }
-
- if (topic.get("tags")) {
- topic.get("tags").forEach((tagName) => classes.push("tag-" + tagName));
- }
-
- ["liked", "archived", "bookmarked", "pinned", "closed", "visited"].forEach(
- (name) => {
- if (topic.get(name)) {
- classes.push(name);
- }
- }
- );
-
- return classes.join(" ");
- }
-
- <template>
- <PluginOutlet
- @name="above-latest-topic-list-item"
- @connectorTagName="div"
- @outletArgs={{hash topic=this.topic}}
- />
- <div class="topic-poster">
- <UserLink
- @user={{this.topic.lastPosterUser}}
- aria-label={{if
- this.topic.lastPosterUser.username
- (i18n
- "latest_poster_link" username=this.topic.lastPosterUser.username
- )
- }}
- >
- {{avatar this.topic.lastPosterUser imageSize="large"}}
- </UserLink>
- <UserAvatarFlair @user={{this.topic.lastPosterUser}} />
- </div>
- <div class="main-link">
- <div class="top-row">
- <TopicStatus @topic={{this.topic}} />
- {{topicLink this.topic}}
- {{~#if this.topic.featured_link}}
- &nbsp;{{topicFeaturedLink this.topic}}
- {{/if}}{{! intentionally inline
- to avoid whitespace}}<TopicPostBadges
- @unreadPosts={{this.topic.unread_posts}}
- @unseen={{this.topic.unseen}}
- @url={{this.topic.lastUnreadUrl}}
- />
- </div>
- <div class="bottom-row">
- {{categoryLink this.topic.category}}{{discourseTags
- this.topic
- mode="list"
- }}{{! intentionally inline to avoid whitespace}}
- <PluginOutlet
- @name="below-latest-topic-list-item-bottom-row"
- @connectorTagName="span"
- @outletArgs={{hash topic=this.topic}}
- />
- </div>
- </div>
- <div class="topic-stats">
- <PluginOutlet
- @name="above-latest-topic-list-item-post-count"
- @connectorTagName="div"
- @outletArgs={{hash topic=this.topic}}
- />
- <ItemRepliesCell @topic={{this.topic}} @tagName="div" />
- <div class="topic-last-activity">
- <a
- href={{this.topic.lastPostUrl}}
- title={{this.topic.bumpedAtTitle}}
- >{{formatDate this.topic.bumpedAt format="tiny" noTitle="true"}}</a>
- </div>
- </div>
- </template>
-}
diff --git a/app/assets/javascripts/discourse/app/components/mobile-category-topic.gjs b/app/assets/javascripts/discourse/app/components/mobile-category-topic.gjs
index 0d80dfaff74..7721d32eed0 100644
--- a/app/assets/javascripts/discourse/app/components/mobile-category-topic.gjs
+++ b/app/assets/javascripts/discourse/app/components/mobile-category-topic.gjs
@@ -1,13 +1,32 @@
import Component from "@ember/component";
import { classNameBindings, tagName } from "@ember-decorators/component";
+import $ from "jquery";
import PostCountOrBadges from "discourse/components/topic-list/post-count-or-badges";
-import { showEntrance } from "discourse/components/topic-list-item";
import TopicStatus from "discourse/components/topic-status";
import coldAgeClass from "discourse/helpers/cold-age-class";
import formatAge from "discourse/helpers/format-age";
import rawDate from "discourse/helpers/raw-date";
import topicLink from "discourse/helpers/topic-link";
+export function showEntrance(e) {
+ let target = $(e.target);
+
+ if (target.hasClass("posts-map") || target.parents(".posts-map").length > 0) {
+ if (target.prop("tagName") !== "A") {
+ target = target.find("a");
+ if (target.length === 0) {
+ target = target.end();
+ }
+ }
+
+ this.appEvents.trigger("topic-entrance:show", {
+ topic: this.topic,
+ position: target.offset(),
+ });
+ return false;
+ }
+}
+
@tagName("tr")
@classNameBindings(":category-topic-link", "topic.archived", "topic.visited")
export default class MobileCategoryTopic extends Component {
diff --git a/app/assets/javascripts/discourse/app/components/new-list-header-controls-wrapper.gjs b/app/assets/javascripts/discourse/app/components/new-list-header-controls-wrapper.gjs
index 862c7069c82..ec108433b54 100644
--- a/app/assets/javascripts/discourse/app/components/new-list-header-controls-wrapper.gjs
+++ b/app/assets/javascripts/discourse/app/components/new-list-header-controls-wrapper.gjs
@@ -1,9 +1,7 @@
import Component from "@glimmer/component";
-import { on } from "@ember/modifier";
import { action } from "@ember/object";
import { service } from "@ember/service";
import NewListHeaderControls from "discourse/components/topic-list/new-list-header-controls";
-import raw from "discourse/helpers/raw";
export default class NewListHeaderControlsWrapper extends Component {
@service site;
@@ -21,30 +19,14 @@ export default class NewListHeaderControlsWrapper extends Component {
}
<template>
- {{#if this.site.useGlimmerTopicList}}
- <div class="topic-replies-toggle-wrapper">
- <NewListHeaderControls
- @current={{@current}}
- @newRepliesCount={{@newRepliesCount}}
- @newTopicsCount={{@newTopicsCount}}
- @noStaticLabel={{true}}
- @changeNewListSubset={{@changeNewListSubset}}
- />
- </div>
- {{else}}
- <div
- {{! template-lint-disable no-invalid-interactive }}
- {{on "click" this.click}}
- class="topic-replies-toggle-wrapper"
- >
- {{raw
- "list/new-list-header-controls"
- current=@current
- newRepliesCount=@newRepliesCount
- newTopicsCount=@newTopicsCount
- noStaticLabel=true
- }}
- </div>
- {{/if}}
+ <div class="topic-replies-toggle-wrapper">
+ <NewListHeaderControls
+ @current={{@current}}
+ @newRepliesCount={{@newRepliesCount}}
+ @newTopicsCount={{@newTopicsCount}}
+ @noStaticLabel={{true}}
+ @changeNewListSubset={{@changeNewListSubset}}
+ />
+ </div>
</template>
}
diff --git a/app/assets/javascripts/discourse/app/components/parent-category-row.gjs b/app/assets/javascripts/discourse/app/components/parent-category-row.gjs
index 57239208522..a1fde5d37ce 100644
--- a/app/assets/javascripts/discourse/app/components/parent-category-row.gjs
+++ b/app/assets/javascripts/discourse/app/components/parent-category-row.gjs
@@ -222,11 +222,7 @@ export default class ParentCategoryRow extends CategoryListItem {
{{#if this.showTopics}}
<td class="latest">
{{#each this.category.featuredTopics as |t|}}
- {{#if this.site.useGlimmerTopicList}}
- <FeaturedTopic @topic={{t}} />
- {{else}}
- <FeaturedTopic @topic={{t}} />
- {{/if}}
+ <FeaturedTopic @topic={{t}} />
{{/each}}
</td>
<PluginOutlet
diff --git a/app/assets/javascripts/discourse/app/components/topic-list-item.gjs b/app/assets/javascripts/discourse/app/components/topic-list-item.gjs
deleted file mode 100644
index 02242b08847..00000000000
--- a/app/assets/javascripts/discourse/app/components/topic-list-item.gjs
+++ /dev/null
@@ -1,418 +0,0 @@
-import Component from "@ember/component";
-import { hash } from "@ember/helper";
-import { alias } from "@ember/object/computed";
-import { getOwner } from "@ember/owner";
-import { schedule } from "@ember/runloop";
-import { service } from "@ember/service";
-import { htmlSafe } from "@ember/template";
-import {
- attributeBindings,
- classNameBindings,
- tagName,
-} from "@ember-decorators/component";
-import { observes, on } from "@ember-decorators/object";
-import $ from "jquery";
-import PluginOutlet from "discourse/components/plugin-outlet";
-import discourseComputed, { bind } from "discourse/lib/decorators";
-import deprecated from "discourse/lib/deprecated";
-import { wantsNewWindow } from "discourse/lib/intercept-click";
-import { RAW_TOPIC_LIST_DEPRECATION_OPTIONS } from "discourse/lib/plugin-api";
-import { RUNTIME_OPTIONS } from "discourse/lib/raw-handlebars-helpers";
-import { findRawTemplate } from "discourse/lib/raw-templates";
-import { applyValueTransformer } from "discourse/lib/transformer";
-import DiscourseURL, { groupPath } from "discourse/lib/url";
-import { i18n } from "discourse-i18n";
-
-export function showEntrance(e) {
- let target = $(e.target);
-
- if (target.hasClass("posts-map") || target.parents(".posts-map").length > 0) {
- if (target.prop("tagName") !== "A") {
- target = target.find("a");
- if (target.length === 0) {
- target = target.end();
- }
- }
-
- this.appEvents.trigger("topic-entrance:show", {
- topic: this.topic,
- position: target.offset(),
- });
- return false;
- }
-}
-
-export function navigateToTopic(topic, href) {
- const historyStore = getOwner(this).lookup("service:history-store");
- historyStore.set("lastTopicIdViewed", topic.id);
-
- DiscourseURL.routeTo(href || topic.get("url"));
- return false;
-}
-
-@tagName("tr")
-@classNameBindings(":topic-list-item", "unboundClassNames", "topic.visited")
-@attributeBindings("dataTopicId:data-topic-id", "role", "ariaLevel:aria-level")
-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.",
- RAW_TOPIC_LIST_DEPRECATION_OPTIONS
- );
-
- return super.reopen(...arguments);
- }
-
- 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.",
- RAW_TOPIC_LIST_DEPRECATION_OPTIONS
- );
-
- return super.reopenClass(...arguments);
- }
-
- @service router;
- @service historyStore;
-
- @alias("topic.id") dataTopicId;
-
- didReceiveAttrs() {
- super.didReceiveAttrs(...arguments);
- this.renderTopicListItem();
- }
-
- // Already-rendered topic is marked as highlighted
- // Ideally this should be a modifier... but we can't do that
- // until this component has its tagName removed.
- @observes("topic.highlight")
- topicHighlightChanged() {
- if (this.topic.highlight) {
- this._highlightIfNeeded();
- }
- }
-
- @observes("topic.pinned", "expandGloballyPinned", "expandAllPinned")
- renderTopicListItem() {
- const template = findRawTemplate("list/topic-list-item");
- if (template) {
- this.set(
- "topicListItemContents",
- htmlSafe(template(this, RUNTIME_OPTIONS))
- );
- schedule("afterRender", () => {
- if (this.isDestroyed || this.isDestroying) {
- return;
- }
- if (this.selected && this.selected.includes(this.topic)) {
- this.element.querySelector("input.bulk-select").checked = true;
- }
- if (this._shouldFocusLastVisited()) {
- const title = this._titleElement();
- if (title) {
- title.addEventListener("focus", this._onTitleFocus);
- title.addEventListener("blur", this._onTitleBlur);
- }
- }
- });
- }
- }
-
- didInsertElement() {
- super.didInsertElement(...arguments);
-
- if (this.includeUnreadIndicator) {
- this.messageBus.subscribe(this.unreadIndicatorChannel, this.onMessage);
- }
- }
-
- willDestroyElement() {
- super.willDestroyElement(...arguments);
-
- this.messageBus.unsubscribe(this.unreadIndicatorChannel, this.onMessage);
-
- if (this._shouldFocusLastVisited()) {
- const title = this._titleElement();
- if (title) {
- title.removeEventListener("focus", this._onTitleFocus);
- title.removeEventListener("blur", this._onTitleBlur);
- }
- }
- }
-
- @bind
- onMessage(data) {
- const nodeClassList = document.querySelector(
- `.indicator-topic-${data.topic_id}`
- ).classList;
-
- nodeClassList.toggle("read", !data.show_indicator);
- }
-
- @discourseComputed("topic.participant_groups")
- participantGroups(groupNames) {
- if (!groupNames) {
- return [];
- }
-
- return groupNames.map((name) => {
- return { name, url: groupPath(name) };
- });
- }
-
- @discourseComputed("topic.id")
- unreadIndicatorChannel(topicId) {
- return `/private-messages/unread-indicator/${topicId}`;
- }
-
- @discourseComputed("topic.unread_by_group_member")
- unreadClass(unreadByGroupMember) {
- return unreadByGroupMember ? "" : "read";
- }
-
- @discourseComputed("topic.unread_by_group_member")
- includeUnreadIndicator(unreadByGroupMember) {
- return typeof unreadByGroupMember !== "undefined";
- }
-
- @discourseComputed
- newDotText() {
- return this.currentUser && this.currentUser.trust_level > 0
- ? ""
- : i18n("filters.new.lower_title");
- }
-
- @discourseComputed("topic", "lastVisitedTopic")
- unboundClassNames(topic, lastVisitedTopic) {
- let classes = [];
-
- if (topic.get("category")) {
- classes.push("category-" + topic.get("category.fullSlug"));
- }
-
- if (topic.get("tags")) {
- topic.get("tags").forEach((tag) => classes.push("tag-" + tag));
- }
-
- if (topic.get("hasExcerpt")) {
- classes.push("has-excerpt");
- }
-
- if (topic.get("unseen")) {
- classes.push("unseen-topic");
- }
-
- if (topic.unread_posts) {
- classes.push("unread-posts");
- }
-
- ["liked", "archived", "bookmarked", "pinned", "closed"].forEach((name) => {
- if (topic.get(name)) {
- classes.push(name);
- }
- });
-
- if (topic === lastVisitedTopic) {
- classes.push("last-visit");
- }
-
- return classes.join(" ");
- }
-
- hasLikes() {
- return this.get("topic.like_count") > 0;
- }
-
- hasOpLikes() {
- return this.get("topic.op_like_count") > 0;
- }
-
- @discourseComputed
- expandPinned() {
- return applyValueTransformer(
- "topic-list-item-expand-pinned",
- this._expandPinned,
- {
- topic: this.topic,
- mobileView: this.site.mobileView,
- }
- );
- }
-
- get _expandPinned() {
- const pinned = this.get("topic.pinned");
- if (!pinned) {
- return false;
- }
-
- if (this.site.mobileView) {
- if (!this.siteSettings.show_pinned_excerpt_mobile) {
- return false;
- }
- } else {
- if (!this.siteSettings.show_pinned_excerpt_desktop) {
- return false;
- }
- }
-
- if (this.expandGloballyPinned && this.get("topic.pinned_globally")) {
- return true;
- }
-
- if (this.expandAllPinned) {
- return true;
- }
-
- return false;
- }
-
- showEntrance() {
- return showEntrance.call(this, ...arguments);
- }
-
- click(e) {
- const result = this.showEntrance(e);
- if (result === false) {
- return result;
- }
-
- const topic = this.topic;
- const target = e.target;
- const classList = target.classList;
- if (classList.contains("bulk-select")) {
- const selected = this.selected;
-
- if (target.checked) {
- selected.addObject(topic);
-
- if (this.lastChecked && e.shiftKey) {
- const bulkSelects = Array.from(
- document.querySelectorAll("input.bulk-select")
- ),
- from = bulkSelects.indexOf(target),
- to = bulkSelects.findIndex((el) => el.id === this.lastChecked.id),
- start = Math.min(from, to),
- end = Math.max(from, to);
-
- bulkSelects
- .slice(start, end)
- .filter((el) => el.checked !== true)
- .forEach((checkbox) => {
- checkbox.click();
- });
- }
-
- this.set("lastChecked", target);
- } else {
- selected.removeObject(topic);
- this.set("lastChecked", null);
- }
- }
-
- if (
- classList.contains("raw-topic-link") ||
- classList.contains("post-activity")
- ) {
- if (wantsNewWindow(e)) {
- return true;
- }
- e.preventDefault();
- return this.navigateToTopic(topic, target.getAttribute("href"));
- }
-
- // make full row click target on mobile, due to size constraints
- if (
- this.site.mobileView &&
- e.target.matches(
- ".topic-list-data, .main-link, .right, .topic-item-stats, .topic-item-stats__category-tags, .discourse-tags"
- )
- ) {
- if (wantsNewWindow(e)) {
- return true;
- }
- e.preventDefault();
- return this.navigateToTopic(topic, topic.lastUnreadUrl);
- }
-
- return this.unhandledRowClick(e, topic);
- }
-
- unhandledRowClick() {}
-
- keyDown(e) {
- if (e.key === "Enter" && e.target.classList.contains("post-activity")) {
- e.preventDefault();
- return this.navigateToTopic(this.topic, e.target.getAttribute("href"));
- }
- }
-
- navigateToTopic() {
- return navigateToTopic.call(this, ...arguments);
- }
-
- highlight(opts = { isLastViewedTopic: false }) {
- schedule("afterRender", () => {
- if (!this.element || this.isDestroying || this.isDestroyed) {
- return;
- }
-
- this.element.classList.add("highlighted");
- this.element.setAttribute(
- "data-is-last-viewed-topic",
- opts.isLastViewedTopic
- );
- this.element.addEventListener("animationend", () => {
- this.element.classList.remove("highlighted");
- });
- if (opts.isLastViewedTopic && this._shouldFocusLastVisited()) {
- this._titleElement()?.focus();
- }
- });
- }
-
- @on("didInsertElement")
- _highlightIfNeeded() {
- // highlight the last topic viewed
- const lastViewedTopicId = this.historyStore.get("lastTopicIdViewed");
- const isLastViewedTopic = lastViewedTopicId === this.topic.id;
-
- if (isLastViewedTopic) {
- this.historyStore.delete("lastTopicIdViewed");
- this.highlight({ isLastViewedTopic: true });
- } else if (this.get("topic.highlight")) {
- // highlight new topics that have been loaded from the server or the one we just created
- this.set("topic.highlight", false);
- this.highlight();
- }
- }
-
- @bind
- _onTitleFocus() {
- if (this.element && !this.isDestroying && !this.isDestroyed) {
- this.element.classList.add("selected");
- }
- }
-
- @bind
- _onTitleBlur() {
- if (this.element && !this.isDestroying && !this.isDestroyed) {
- this.element.classList.remove("selected");
- }
- }
-
- _shouldFocusLastVisited() {
- return this.site.desktopView && this.focusLastVisitedTopic;
- }
-
- _titleElement() {
- return this.element.querySelector(".main-link .title");
- }
-
- <template>
- <PluginOutlet
- @name="above-topic-list-item"
- @outletArgs={{hash topic=this.topic}}
- />
- {{this.topicListItemContents}}
- </template>
-}
diff --git a/app/assets/javascripts/discourse/app/components/topic-list.gjs b/app/assets/javascripts/discourse/app/components/topic-list.gjs
index bb0cd08705f..86276a743cc 100644
--- a/app/assets/javascripts/discourse/app/components/topic-list.gjs
+++ b/app/assets/javascripts/discourse/app/components/topic-list.gjs
@@ -1,339 +1,20 @@
-import Component from "@ember/component";
-import { hash } from "@ember/helper";
-import { dependentKeyCompat } from "@ember/object/compat";
-import { alias } from "@ember/object/computed";
-import { service } from "@ember/service";
-import {
- classNameBindings,
- classNames,
- tagName,
-} from "@ember-decorators/component";
-import { observes, on } from "@ember-decorators/object";
-import PluginOutlet from "discourse/components/plugin-outlet";
-import TopicListItem from "discourse/components/topic-list-item";
-import raw from "discourse/helpers/raw";
-import discourseComputed from "discourse/lib/decorators";
+import Component from "@glimmer/component";
+import curryComponent from "ember-curry-component";
+import List from "discourse/components/topic-list/list";
import deprecated from "discourse/lib/deprecated";
-import { RAW_TOPIC_LIST_DEPRECATION_OPTIONS } from "discourse/lib/plugin-api";
-import LoadMore from "discourse/mixins/load-more";
-import { i18n } from "discourse-i18n";
-@tagName("table")
-@classNames("topic-list")
-@classNameBindings("bulkSelectEnabled:sticky-header")
-export default class TopicList extends Component.extend(LoadMore) {
- static reopen() {
+export default class TopicListShim extends Component {
+ constructor() {
+ super(...arguments);
deprecated(
- "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
+ `components/topic-list is deprecated, and should be replaced with components/topics-list/list`,
+ { id: "discourse.legacy-topic-list" }
);
-
- return super.reopen(...arguments);
- }
-
- 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.",
- RAW_TOPIC_LIST_DEPRECATION_OPTIONS
- );
-
- return super.reopenClass(...arguments);
- }
-
- @service modal;
- @service router;
- @service siteSettings;
-
- showTopicPostBadges = true;
- listTitle = "topic.title";
- lastCheckedElementId = null;
-
- // Overwrite this to perform client side filtering of topics, if desired
- @alias("topics") filteredTopics;
-
- get canDoBulkActions() {
- return (
- this.currentUser?.canManageTopic && this.bulkSelectHelper?.selected.length
- );
- }
-
- @on("init")
- _init() {
- this.addObserver("hideCategory", this.rerender);
- this.addObserver("order", this.rerender);
- this.addObserver("ascending", this.rerender);
- this.refreshLastVisited();
- }
-
- get selected() {
- return this.bulkSelectHelper?.selected;
- }
-
- // for the classNameBindings
- @dependentKeyCompat
- get bulkSelectEnabled() {
- return (
- this.get("canBulkSelect") && this.bulkSelectHelper?.bulkSelectEnabled
- );
- }
-
- get toggleInTitle() {
- return (
- !this.bulkSelectHelper?.bulkSelectEnabled && this.get("canBulkSelect")
- );
- }
-
- @discourseComputed
- sortable() {
- return !!this.changeSort;
- }
-
- @discourseComputed("order")
- showLikes(order) {
- return order === "likes";
- }
-
- @discourseComputed("order")
- showOpLikes(order) {
- return order === "op_likes";
- }
-
- @observes("topics.[]")
- topicsAdded() {
- // special case so we don't keep scanning huge lists
- if (!this.lastVisitedTopic) {
- this.refreshLastVisited();
- }
- }
-
- @observes("topics", "order", "ascending", "category", "top", "hot")
- lastVisitedTopicChanged() {
- this.refreshLastVisited();
- }
-
- scrolled() {
- super.scrolled(...arguments);
- let onScroll = this.onScroll;
- if (!onScroll) {
- return;
- }
-
- onScroll.call(this);
- }
-
- _updateLastVisitedTopic(topics, order, ascending, top, hot) {
- this.set("lastVisitedTopic", null);
-
- if (!this.highlightLastVisited) {
- return;
- }
-
- if (order && order !== "activity") {
- return;
- }
-
- if (top || hot) {
- return;
- }
-
- if (!topics || topics.length === 1) {
- return;
- }
-
- if (ascending) {
- return;
- }
-
- let user = this.currentUser;
- if (!user || !user.previous_visit_at) {
- return;
- }
-
- let lastVisitedTopic, topic;
-
- let prevVisit = user.get("previousVisitAt");
-
- // this is more efficient cause we keep appending to list
- // work backwards
- let start = 0;
- while (topics[start] && topics[start].get("pinned")) {
- start++;
- }
-
- let i;
- for (i = topics.length - 1; i >= start; i--) {
- if (topics[i].get("bumpedAt") > prevVisit) {
- lastVisitedTopic = topics[i];
- break;
- }
- topic = topics[i];
- }
-
- if (!lastVisitedTopic || !topic) {
- return;
- }
-
- // end of list that was scanned
- if (topic.get("bumpedAt") > prevVisit) {
- return;
- }
-
- this.set("lastVisitedTopic", lastVisitedTopic);
- }
-
- refreshLastVisited() {
- this._updateLastVisitedTopic(
- this.topics,
- this.order,
- this.ascending,
- this.top,
- this.hot
- );
- }
-
- click(e) {
- const onClick = (sel, callback) => {
- let target = e.target.closest(sel);
-
- if (target) {
- callback(target);
- }
- };
-
- onClick("button.bulk-select", () => {
- this.bulkSelectHelper.toggleBulkSelect();
- this.rerender();
- });
-
- onClick("button.bulk-select-all", () => {
- this.bulkSelectHelper.autoAddTopicsToBulkSelect = true;
- document
- .querySelectorAll("input.bulk-select:not(:checked)")
- .forEach((el) => el.click());
- });
-
- onClick("button.bulk-clear-all", () => {
- this.bulkSelectHelper.autoAddTopicsToBulkSelect = false;
- document
- .querySelectorAll("input.bulk-select:checked")
- .forEach((el) => el.click());
- });
-
- onClick("th.sortable", (element) => {
- this.changeSort(element.dataset.sortOrder);
- this.rerender();
- });
-
- onClick("button.topics-replies-toggle", (element) => {
- if (element.classList.contains("--all")) {
- this.changeNewListSubset(null);
- } else if (element.classList.contains("--topics")) {
- this.changeNewListSubset("topics");
- } else if (element.classList.contains("--replies")) {
- this.changeNewListSubset("replies");
- }
- this.rerender();
- });
- }
-
- keyDown(e) {
- if (e.key === "Enter" || e.key === " ") {
- let onKeyDown = (sel, callback) => {
- let target = e.target.closest(sel);
-
- if (target) {
- callback.call(this, target);
- }
- };
-
- onKeyDown("th.sortable", (element) => {
- e.preventDefault();
- this.changeSort(element.dataset.sortOrder);
- this.rerender();
- });
- }
}
<template>
- <caption class="sr-only">{{i18n "sr_topic_list_caption"}}</caption>
-
- <thead class="topic-list-header">
- {{raw
- "topic-list-header"
- canBulkSelect=this.canBulkSelect
- toggleInTitle=this.toggleInTitle
- hideCategory=this.hideCategory
- showPosters=this.showPosters
- showLikes=this.showLikes
- showOpLikes=this.showOpLikes
- order=this.order
- ascending=this.ascending
- sortable=this.sortable
- listTitle=this.listTitle
- bulkSelectEnabled=this.bulkSelectEnabled
- bulkSelectHelper=this.bulkSelectHelper
- canDoBulkActions=this.canDoBulkActions
- showTopicsAndRepliesToggle=this.showTopicsAndRepliesToggle
- newListSubset=this.newListSubset
- newRepliesCount=this.newRepliesCount
- newTopicsCount=this.newTopicsCount
- }}
- </thead>
-
- <PluginOutlet
- @name="before-topic-list-body"
- @outletArgs={{hash
- topics=this.topics
- selected=this.selected
- bulkSelectEnabled=this.bulkSelectEnabled
- lastVisitedTopic=this.lastVisitedTopic
- discoveryList=this.discoveryList
- hideCategory=this.hideCategory
- }}
- />
-
- <tbody class="topic-list-body">
- {{#each this.filteredTopics as |topic index|}}
- <TopicListItem
- @topic={{topic}}
- @bulkSelectEnabled={{this.bulkSelectEnabled}}
- @showTopicPostBadges={{this.showTopicPostBadges}}
- @hideCategory={{this.hideCategory}}
- @showPosters={{this.showPosters}}
- @showLikes={{this.showLikes}}
- @showOpLikes={{this.showOpLikes}}
- @expandGloballyPinned={{this.expandGloballyPinned}}
- @expandAllPinned={{this.expandAllPinned}}
- @lastVisitedTopic={{this.lastVisitedTopic}}
- @selected={{this.selected}}
- @lastChecked={{this.lastChecked}}
- @tagsForUser={{this.tagsForUser}}
- @focusLastVisitedTopic={{this.focusLastVisitedTopic}}
- @index={{index}}
- />
- {{raw
- "list/visited-line"
- lastVisitedTopic=this.lastVisitedTopic
- topic=topic
- }}
- <PluginOutlet
- @name="after-topic-list-item"
- @outletArgs={{hash topic=topic index=index}}
- @connectorTagName="tr"
- />
- {{/each}}
- </tbody>
-
- <PluginOutlet
- @name="after-topic-list-body"
- @outletArgs={{hash
- topics=this.topics
- selected=this.selected
- bulkSelectEnabled=this.bulkSelectEnabled
- lastVisitedTopic=this.lastVisitedTopic
- discoveryList=this.discoveryList
- hideCategory=this.hideCategory
- }}
- />
+ {{#let (curryComponent List this.args) as |CurriedComponent|}}
+ <CurriedComponent />
+ {{/let}}
</template>
}
diff --git a/app/assets/javascripts/discourse/app/components/topic-status.gjs b/app/assets/javascripts/discourse/app/components/topic-status.gjs
index 2869aa5f749..ba03f3531e2 100644
--- a/app/assets/javascripts/discourse/app/components/topic-status.gjs
+++ b/app/assets/javascripts/discourse/app/components/topic-status.gjs
@@ -1,5 +1,5 @@
import Component from "@glimmer/component";
-import { concat, get, hash } from "@ember/helper";
+import { hash } from "@ember/helper";
import { on } from "@ember/modifier";
import { action } from "@ember/object";
import { service } from "@ember/service";
@@ -7,7 +7,6 @@ import { and } from "truth-helpers";
import PluginOutlet from "discourse/components/plugin-outlet";
import icon from "discourse/helpers/d-icon";
import element from "discourse/helpers/element";
-import TopicStatusIcons from "discourse/helpers/topic-status-icons";
import { i18n } from "discourse-i18n";
export default class TopicStatus extends Component {
@@ -108,22 +107,10 @@ export default class TopicStatus extends Component {
class="topic-status"
>{{icon "far-eye-slash"}}</span>
{{~/if~}}
-
- {{~#if this.site.useGlimmerTopicList~}}
- <PluginOutlet
- @name="after-topic-status"
- @outletArgs={{hash topic=@topic context=@context}}
- />
- {{~else~}}
- {{~#each TopicStatusIcons.entries as |entry|~}}
- {{~#if (get @topic entry.attribute)~}}
- <span
- title={{i18n (concat "topic_statuses." entry.titleKey ".help")}}
- class="topic-status"
- >{{icon entry.iconName}}</span>
- {{~/if~}}
- {{~/each~}}
- {{~/if~}}
+ <PluginOutlet
+ @name="after-topic-status"
+ @outletArgs={{hash topic=@topic context=@context}}
+ />
{{~! no whitespace ~}}
</this.wrapperElement>
{{~! no whitespace ~}}
diff --git a/app/assets/javascripts/discourse/app/discourse-common-loader-shims.js b/app/assets/javascripts/discourse/app/discourse-common-loader-shims.js
index 5c5c8bb0310..3d27f5f7c46 100644
--- a/app/assets/javascripts/discourse/app/discourse-common-loader-shims.js
+++ b/app/assets/javascripts/discourse/app/discourse-common-loader-shims.js
@@ -84,15 +84,6 @@ loaderShim("discourse-common/lib/object", () =>
loaderShim("discourse-common/lib/popular-themes", () =>
importSync("discourse/lib/popular-themes")
);
-loaderShim("discourse-common/lib/raw-handlebars-helpers", () =>
- importSync("discourse/lib/raw-handlebars-helpers")
-);
-loaderShim("discourse-common/lib/raw-handlebars", () =>
- importSync("discourse/lib/raw-handlebars")
-);
-loaderShim("discourse-common/lib/raw-templates", () =>
- importSync("discourse/lib/raw-templates")
-);
loaderShim("discourse-common/lib/suffix-trie", () =>
importSync("discourse/lib/suffix-trie")
);
diff --git a/app/assets/javascripts/discourse/app/helpers/age-with-tooltip.js b/app/assets/javascripts/discourse/app/helpers/age-with-tooltip.js
index f4da9a42ea5..dcf9b206261 100644
--- a/app/assets/javascripts/discourse/app/helpers/age-with-tooltip.js
+++ b/app/assets/javascripts/discourse/app/helpers/age-with-tooltip.js
@@ -1,8 +1,5 @@
import { htmlSafe } from "@ember/template";
import { autoUpdatingRelativeAge } from "discourse/lib/formatter";
-import { registerRawHelper } from "discourse/lib/helpers";
-
-registerRawHelper("age-with-tooltip", ageWithTooltip);
export default function ageWithTooltip(dt, params = {}) {
return htmlSafe(
diff --git a/app/assets/javascripts/discourse/app/helpers/avatar.js b/app/assets/javascripts/discourse/app/helpers/avatar.js
index 4ce4831ee1f..fc525e11afc 100644
--- a/app/assets/javascripts/discourse/app/helpers/avatar.js
+++ b/app/assets/javascripts/discourse/app/helpers/avatar.js
@@ -1,7 +1,6 @@
import { get } from "@ember/object";
import { htmlSafe } from "@ember/template";
import { avatarImg } from "discourse/lib/avatar-utils";
-import { registerRawHelper } from "discourse/lib/helpers";
import { prioritizeNameInUx } from "discourse/lib/settings";
import { formatUsername } from "discourse/lib/utilities";
import { i18n } from "discourse-i18n";
@@ -81,7 +80,6 @@ export function renderAvatar(user, options) {
}
}
-registerRawHelper("avatar", avatar);
export default function avatar(user, params) {
return htmlSafe(renderAvatar.call(this, user, params));
}
diff --git a/app/assets/javascripts/discourse/app/helpers/base-path.js b/app/assets/javascripts/discourse/app/helpers/base-path.js
index 77499376626..6a28abda0ed 100644
--- a/app/assets/javascripts/discourse/app/helpers/base-path.js
+++ b/app/assets/javascripts/discourse/app/helpers/base-path.js
@@ -1,7 +1,4 @@
import getUrl from "discourse/lib/get-url";
-import { registerRawHelper } from "discourse/lib/helpers";
-
-registerRawHelper("base-path", basePath);
export default function basePath() {
return getUrl("");
diff --git a/app/assets/javascripts/discourse/app/helpers/base-url.js b/app/assets/javascripts/discourse/app/helpers/base-url.js
index fa94031244d..5ef660f87a2 100644
--- a/app/assets/javascripts/discourse/app/helpers/base-url.js
+++ b/app/assets/javascripts/discourse/app/helpers/base-url.js
@@ -1,8 +1,5 @@
import deprecated from "discourse/lib/deprecated";
import getUrl from "discourse/lib/get-url";
-import { registerRawHelper } from "discourse/lib/helpers";
-
-registerRawHelper("base-url", baseUrl);
export default function baseUrl() {
deprecated("Use `{{base-path}}` instead of `{{base-url}}`", {
diff --git a/app/assets/javascripts/discourse/app/helpers/category-badge.js b/app/assets/javascripts/discourse/app/helpers/category-badge.js
index be28d345657..15f14e61896 100644
--- a/app/assets/javascripts/discourse/app/helpers/category-badge.js
+++ b/app/assets/javascripts/discourse/app/helpers/category-badge.js
@@ -1,8 +1,5 @@
import { isPresent } from "@ember/utils";
import { categoryLinkHTML } from "discourse/helpers/category-link";
-import { registerRawHelper } from "discourse/lib/helpers";
-
-registerRawHelper("category-badge", categoryBadge);
export default function categoryBadge(cat, options = {}) {
return categoryLinkHTML(cat, {
diff --git a/app/assets/javascripts/discourse/app/helpers/category-link.js b/app/assets/javascripts/discourse/app/helpers/category-link.js
index 6b134fb2621..db8f58eb386 100644
--- a/app/assets/javascripts/discourse/app/helpers/category-link.js
+++ b/app/assets/javascripts/discourse/app/helpers/category-link.js
@@ -3,7 +3,7 @@ import { htmlSafe } from "@ember/template";
import categoryVariables from "discourse/helpers/category-variables";
import replaceEmoji from "discourse/helpers/replace-emoji";
import getURL from "discourse/lib/get-url";
-import { helperContext, registerRawHelper } from "discourse/lib/helpers";
+import { helperContext } from "discourse/lib/helpers";
import { iconHTML } from "discourse/lib/icon-library";
import { applyValueTransformer } from "discourse/lib/transformer";
import { escapeExpression } from "discourse/lib/utilities";
@@ -116,7 +116,6 @@ export function categoryLinkHTML(category, options) {
}
export default categoryLinkHTML;
-registerRawHelper("category-link", categoryLinkHTML);
function buildTopicCount(count) {
return `<span class="topic-count" aria-label="${i18n(
diff --git a/app/assets/javascripts/discourse/app/helpers/cold-age-class.js b/app/assets/javascripts/discourse/app/helpers/cold-age-class.js
index c7196458548..04bd4b4241c 100644
--- a/app/assets/javascripts/discourse/app/helpers/cold-age-class.js
+++ b/app/assets/javascripts/discourse/app/helpers/cold-age-class.js
@@ -1,12 +1,10 @@
-import { helperContext, registerRawHelper } from "discourse/lib/helpers";
+import { helperContext } from "discourse/lib/helpers";
function daysSinceEpoch(dt) {
// 1000 * 60 * 60 * 24 = days since epoch
return dt.getTime() / 86400000;
}
-registerRawHelper("cold-age-class", coldAgeClass);
-
export default function coldAgeClass(dt, params = {}) {
let className = params["class"] || "age";
diff --git a/app/assets/javascripts/discourse/app/helpers/component-for-collection.js b/app/assets/javascripts/discourse/app/helpers/component-for-collection.js
index b1f61fb13a1..c41473a421f 100644
--- a/app/assets/javascripts/discourse/app/helpers/component-for-collection.js
+++ b/app/assets/javascripts/discourse/app/helpers/component-for-collection.js
@@ -1,7 +1,3 @@
-import { registerRawHelper } from "discourse/lib/helpers";
-
-registerRawHelper("component-for-collection", componentForCollection);
-
export default function componentForCollection(
collectionIdentifier,
selectKit
diff --git a/app/assets/javascripts/discourse/app/helpers/component-for-row.js b/app/assets/javascripts/discourse/app/helpers/component-for-row.js
index c5654bf28dc..17307b6377d 100644
--- a/app/assets/javascripts/discourse/app/helpers/component-for-row.js
+++ b/app/assets/javascripts/discourse/app/helpers/component-for-row.js
@@ -1,7 +1,3 @@
-import { registerRawHelper } from "discourse/lib/helpers";
-
-registerRawHelper("component-for-row", componentForRow);
-
export default function componentForRow(
collectionForIdentifier,
item,
diff --git a/app/assets/javascripts/discourse/app/helpers/d-icon.js b/app/assets/javascripts/discourse/app/helpers/d-icon.js
index d16fde94020..0059a8a1dee 100644
--- a/app/assets/javascripts/discourse/app/helpers/d-icon.js
+++ b/app/assets/javascripts/discourse/app/helpers/d-icon.js
@@ -1,9 +1,6 @@
import { htmlSafe } from "@ember/template";
-import { registerRawHelper } from "discourse/lib/helpers";
import { renderIcon } from "discourse/lib/icon-library";
export default function icon(id, options = {}) {
return htmlSafe(renderIcon("string", id, options));
}
-
-registerRawHelper("d-icon", icon);
diff --git a/app/assets/javascripts/discourse/app/helpers/decorate-username-selector.js b/app/assets/javascripts/discourse/app/helpers/decorate-username-selector.js
index 7dd4b270ee9..3c000b811ca 100644
--- a/app/assets/javascripts/discourse/app/helpers/decorate-username-selector.js
+++ b/app/assets/javascripts/discourse/app/helpers/decorate-username-selector.js
@@ -1,5 +1,4 @@
import { htmlSafe } from "@ember/template";
-import { registerRawHelper } from "discourse/lib/helpers";
let usernameDecorators = [];
export function addUsernameSelectorDecorator(decorator) {
@@ -20,8 +19,6 @@ export function decorateUsername(username) {
return decorations.length ? htmlSafe(decorations.join("")) : "";
}
-registerRawHelper("decorate-username-selector", decorateUsernameSelector);
-
export default function decorateUsernameSelector(username) {
return decorateUsername(username);
}
diff --git a/app/assets/javascripts/discourse/app/helpers/dir-span.js b/app/assets/javascripts/discourse/app/helpers/dir-span.js
index 306c912ff2d..590745f7c23 100644
--- a/app/assets/javascripts/discourse/app/helpers/dir-span.js
+++ b/app/assets/javascripts/discourse/app/helpers/dir-span.js
@@ -1,5 +1,5 @@
import { htmlSafe } from "@ember/template";
-import { helperContext, registerRawHelper } from "discourse/lib/helpers";
+import { helperContext } from "discourse/lib/helpers";
import { escapeExpression } from "discourse/lib/utilities";
function setDir(text) {
@@ -9,8 +9,6 @@ function setDir(text) {
return `<span ${mixed ? 'dir="auto"' : ""}>${content}</span>`;
}
-registerRawHelper("dir-span", dirSpan);
-
export default function dirSpan(str, params = {}) {
let isHtmlSafe = false;
if (params.htmlSafe) {
diff --git a/app/assets/javascripts/discourse/app/helpers/discourse-tag.js b/app/assets/javascripts/discourse/app/helpers/discourse-tag.js
index 8d6d65ba4bc..9fa0cb17968 100644
--- a/app/assets/javascripts/discourse/app/helpers/discourse-tag.js
+++ b/app/assets/javascripts/discourse/app/helpers/discourse-tag.js
@@ -1,8 +1,6 @@
import { htmlSafe } from "@ember/template";
-import { registerRawHelper } from "discourse/lib/helpers";
import renderTag from "discourse/lib/render-tag";
-registerRawHelper("discourse-tag", discourseTag);
export default function discourseTag(name, params) {
return htmlSafe(renderTag(name, params));
}
diff --git a/app/assets/javascripts/discourse/app/helpers/discourse-tags.js b/app/assets/javascripts/discourse/app/helpers/discourse-tags.js
index 89eec39b104..07debbdc56e 100644
--- a/app/assets/javascripts/discourse/app/helpers/discourse-tags.js
+++ b/app/assets/javascripts/discourse/app/helpers/discourse-tags.js
@@ -1,8 +1,6 @@
import { htmlSafe } from "@ember/template";
-import { registerRawHelper } from "discourse/lib/helpers";
import renderTags from "discourse/lib/render-tags";
-registerRawHelper("discourse-tags", discourseTags);
export default function discourseTags(topic, params) {
return htmlSafe(renderTags(topic, params));
}
diff --git a/app/assets/javascripts/discourse/app/helpers/emoji.js b/app/assets/javascripts/discourse/app/helpers/emoji.js
index ffa990bdc9b..90d3da1b075 100644
--- a/app/assets/javascripts/discourse/app/helpers/emoji.js
+++ b/app/assets/javascripts/discourse/app/helpers/emoji.js
@@ -1,9 +1,7 @@
import { htmlSafe } from "@ember/template";
-import { registerRawHelper } from "discourse/lib/helpers";
import { emojiUnescape } from "discourse/lib/text";
import { escapeExpression } from "discourse/lib/utilities";
-registerRawHelper("emoji", emoji);
export default function emoji(code, options) {
const escaped = escapeExpression(`:${code}:`);
return htmlSafe(emojiUnescape(escaped, options));
diff --git a/app/assets/javascripts/discourse/app/helpers/fa-icon.js b/app/assets/javascripts/discourse/app/helpers/fa-icon.js
index 68871d81dba..87f010d5526 100644
--- a/app/assets/javascripts/discourse/app/helpers/fa-icon.js
+++ b/app/assets/javascripts/discourse/app/helpers/fa-icon.js
@@ -1,13 +1,11 @@
import { htmlSafe } from "@ember/template";
import deprecated from "discourse/lib/deprecated";
-import { registerRawHelper } from "discourse/lib/helpers";
import { renderIcon } from "discourse/lib/icon-library";
export function iconHTML(id, params) {
return renderIcon("string", id, params);
}
-registerRawHelper("fa-icon", faIcon);
export default function faIcon(icon, params) {
deprecated("Use `{{d-icon}}` instead of `{{fa-icon}}", {
id: "discourse.fa-icon",
diff --git a/app/assets/javascripts/discourse/app/helpers/format-age.js b/app/assets/javascripts/discourse/app/helpers/format-age.js
index 04b4ee30be4..cb1d16688f0 100644
--- a/app/assets/javascripts/discourse/app/helpers/format-age.js
+++ b/app/assets/javascripts/discourse/app/helpers/format-age.js
@@ -1,8 +1,6 @@
import { htmlSafe } from "@ember/template";
import { autoUpdatingRelativeAge } from "discourse/lib/formatter";
-import { registerRawHelper } from "discourse/lib/helpers";
-registerRawHelper("format-age", formatAge);
export default function formatAge(dt) {
dt = new Date(dt);
return htmlSafe(autoUpdatingRelativeAge(dt));
diff --git a/app/assets/javascripts/discourse/app/helpers/format-date.js b/app/assets/javascripts/discourse/app/helpers/format-date.js
index 0efcf127dc0..da53b4184bb 100644
--- a/app/assets/javascripts/discourse/app/helpers/format-date.js
+++ b/app/assets/javascripts/discourse/app/helpers/format-date.js
@@ -1,13 +1,11 @@
import { htmlSafe } from "@ember/template";
import { autoUpdatingRelativeAge } from "discourse/lib/formatter";
-import { registerRawHelper } from "discourse/lib/helpers";
/**
Display logic for dates. It is unbound in Ember but will use jQuery to
update the dates on a regular interval.
**/
-registerRawHelper("format-date", formatDate);
export default function formatDate(val, params = {}) {
let leaveAgo,
format = "medium",
diff --git a/app/assets/javascripts/discourse/app/helpers/format-duration.js b/app/assets/javascripts/discourse/app/helpers/format-duration.js
index 4556ae53cd7..fd53d4bd2a3 100644
--- a/app/assets/javascripts/discourse/app/helpers/format-duration.js
+++ b/app/assets/javascripts/discourse/app/helpers/format-duration.js
@@ -1,8 +1,6 @@
import { htmlSafe } from "@ember/template";
import { durationTiny } from "discourse/lib/formatter";
-import { registerRawHelper } from "discourse/lib/helpers";
-registerRawHelper("format-duration", formatDuration);
export default function formatDuration(seconds) {
return htmlSafe(durationTiny(seconds));
}
diff --git a/app/assets/javascripts/discourse/app/helpers/format-username.js b/app/assets/javascripts/discourse/app/helpers/format-username.js
index 71b4c216fb1..123d84403bb 100644
--- a/app/assets/javascripts/discourse/app/helpers/format-username.js
+++ b/app/assets/javascripts/discourse/app/helpers/format-username.js
@@ -1,5 +1,3 @@
-import { registerRawHelper } from "discourse/lib/helpers";
import { formatUsername } from "discourse/lib/utilities";
export default formatUsername;
-registerRawHelper("format-username", formatUsername);
diff --git a/app/assets/javascripts/discourse/app/helpers/get-url.js b/app/assets/javascripts/discourse/app/helpers/get-url.js
index 495997d6bcc..cae31b63447 100644
--- a/app/assets/javascripts/discourse/app/helpers/get-url.js
+++ b/app/assets/javascripts/discourse/app/helpers/get-url.js
@@ -1,7 +1,4 @@
import { default as emberGetUrl } from "discourse/lib/get-url";
-import { registerRawHelper } from "discourse/lib/helpers";
-
-registerRawHelper("get-url", getUrl);
export default function getUrl(value) {
return emberGetUrl(value);
diff --git a/app/assets/javascripts/discourse/app/helpers/html-safe.js b/app/assets/javascripts/discourse/app/helpers/html-safe.js
index f86b180b6b3..618b1dbbc81 100644
--- a/app/assets/javascripts/discourse/app/helpers/html-safe.js
+++ b/app/assets/javascripts/discourse/app/helpers/html-safe.js
@@ -1,7 +1,4 @@
import { htmlSafe as emberHtmlSafe } from "@ember/template";
-import { registerRawHelper } from "discourse/lib/helpers";
-
-registerRawHelper("html-safe", htmlSafe);
export default function htmlSafe(string) {
return emberHtmlSafe(string);
diff --git a/app/assets/javascripts/discourse/app/helpers/i18n-yes-no.js b/app/assets/javascripts/discourse/app/helpers/i18n-yes-no.js
index 4ac082bc11d..94f1a6c3de4 100644
--- a/app/assets/javascripts/discourse/app/helpers/i18n-yes-no.js
+++ b/app/assets/javascripts/discourse/app/helpers/i18n-yes-no.js
@@ -1,8 +1,5 @@
-import { registerRawHelper } from "discourse/lib/helpers";
import { i18n } from "discourse-i18n";
-registerRawHelper("i18n-yes-no", i18nYesNo);
-
export default function i18nYesNo(value, params) {
return i18n(value ? "yes_value" : "no_value", params);
}
diff --git a/app/assets/javascripts/discourse/app/helpers/i18n.js b/app/assets/javascripts/discourse/app/helpers/i18n.js
index a6803c7ff82..b0c2e37346a 100644
--- a/app/assets/javascripts/discourse/app/helpers/i18n.js
+++ b/app/assets/javascripts/discourse/app/helpers/i18n.js
@@ -1,6 +1,3 @@
-import { registerRawHelper } from "discourse/lib/helpers";
import { i18n } from "discourse-i18n";
-registerRawHelper("i18n", i18n);
-
export default i18n;
diff --git a/app/assets/javascripts/discourse/app/helpers/number.js b/app/assets/javascripts/discourse/app/helpers/number.js
index 290610fad68..4ddb346a819 100644
--- a/app/assets/javascripts/discourse/app/helpers/number.js
+++ b/app/assets/javascripts/discourse/app/helpers/number.js
@@ -1,11 +1,8 @@
import { htmlSafe } from "@ember/template";
import { number as numberFormatter } from "discourse/lib/formatter";
-import { registerRawHelper } from "discourse/lib/helpers";
import { escapeExpression } from "discourse/lib/utilities";
import I18n, { i18n } from "discourse-i18n";
-registerRawHelper("number", number);
-
export default function number(orig, params = {}) {
orig = Math.round(parseFloat(orig));
if (isNaN(orig)) {
diff --git a/app/assets/javascripts/discourse/app/helpers/plugin-outlet.gjs b/app/assets/javascripts/discourse/app/helpers/plugin-outlet.gjs
deleted file mode 100644
index c06abb98371..00000000000
--- a/app/assets/javascripts/discourse/app/helpers/plugin-outlet.gjs
+++ /dev/null
@@ -1,28 +0,0 @@
-import { htmlSafe } from "@ember/template";
-import PluginOutlet from "discourse/components/plugin-outlet";
-import { connectorsExist } from "discourse/lib/plugin-connectors";
-import RawHandlebars from "discourse/lib/raw-handlebars";
-import rawRenderGlimmer from "discourse/lib/raw-render-glimmer";
-
-const GlimmerPluginOutletWrapper = <template>
- {{~! no whitespace ~}}
- <PluginOutlet @name={{@data.name}} @outletArgs={{@data.outletArgs}} />
- {{~! no whitespace ~}}
-</template>;
-
-RawHandlebars.registerHelper("plugin-outlet", function (options) {
- const { name, tagName, outletArgs } = options.hash;
-
- if (!connectorsExist(name)) {
- return htmlSafe("");
- }
-
- return htmlSafe(
- rawRenderGlimmer(
- this,
- `${tagName || "span"}.hbr-ember-outlet`,
- GlimmerPluginOutletWrapper,
- { name, outletArgs }
- )
- );
-});
diff --git a/app/assets/javascripts/discourse/app/helpers/raw-date.js b/app/assets/javascripts/discourse/app/helpers/raw-date.js
index 084e8d46864..d0d96fda911 100644
--- a/app/assets/javascripts/discourse/app/helpers/raw-date.js
+++ b/app/assets/javascripts/discourse/app/helpers/raw-date.js
@@ -1,8 +1,5 @@
import { htmlSafe } from "@ember/template";
import { longDate } from "discourse/lib/formatter";
-import { registerRawHelper } from "discourse/lib/helpers";
-
-registerRawHelper("raw-date", rawDate);
export default function rawDate(dt) {
return htmlSafe(longDate(new Date(dt)));
diff --git a/app/assets/javascripts/discourse/app/helpers/raw-hash.js b/app/assets/javascripts/discourse/app/helpers/raw-hash.js
deleted file mode 100644
index 47473dda072..00000000000
--- a/app/assets/javascripts/discourse/app/helpers/raw-hash.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import { registerRawHelper } from "discourse/lib/helpers";
-
-registerRawHelper("raw-hash", function (params) {
- return params;
-});
diff --git a/app/assets/javascripts/discourse/app/helpers/raw-plugin-outlet.js b/app/assets/javascripts/discourse/app/helpers/raw-plugin-outlet.js
deleted file mode 100644
index 532aac00b8c..00000000000
--- a/app/assets/javascripts/discourse/app/helpers/raw-plugin-outlet.js
+++ /dev/null
@@ -1,11 +0,0 @@
-import { htmlSafe } from "@ember/template";
-import { rawConnectorsFor } from "discourse/lib/plugin-connectors";
-import RawHandlebars from "discourse/lib/raw-handlebars";
-
-RawHandlebars.registerHelper("raw-plugin-outlet", function (args) {
- const connectors = rawConnectorsFor(args.hash.name);
- if (connectors.length) {
- const output = connectors.map((c) => c.template({ context: this }));
- return htmlSafe(output.join(""));
- }
-});
diff --git a/app/assets/javascripts/discourse/app/helpers/raw.js b/app/assets/javascripts/discourse/app/helpers/raw.js
deleted file mode 100644
index 7dcd2c816ec..00000000000
--- a/app/assets/javascripts/discourse/app/helpers/raw.js
+++ /dev/null
@@ -1,59 +0,0 @@
-import Helper from "@ember/component/helper";
-import { registerDestructor } from "@ember/destroyable";
-import { getOwner, setOwner } from "@ember/owner";
-import { schedule } from "@ember/runloop";
-import { service } from "@ember/service";
-import { htmlSafe } from "@ember/template";
-import { bind } from "discourse/lib/decorators";
-import { helperContext, registerRawHelper } from "discourse/lib/helpers";
-import { RUNTIME_OPTIONS } from "discourse/lib/raw-handlebars-helpers";
-import { findRawTemplate } from "discourse/lib/raw-templates";
-
-function renderRaw(ctx, template, templateName, params) {
- params = { ...params };
- params.parent ||= ctx;
-
- let context = helperContext();
- if (!params.view) {
- const viewClass = context.registry.resolve(`raw-view:${templateName}`);
-
- if (viewClass) {
- setOwner(params, getOwner(context));
- params.view = viewClass.create(params, context);
- }
-
- if (!params.view) {
- params = { ...params, ...context };
- }
- }
-
- return htmlSafe(template(params, RUNTIME_OPTIONS));
-}
-
-const helperFunction = function (templateName, params) {
- templateName = templateName.replace(".", "/");
-
- const template = findRawTemplate(templateName);
- if (!template) {
- // eslint-disable-next-line no-console
- console.warn("Could not find raw template: " + templateName);
- return;
- }
- return renderRaw(this, template, templateName, params);
-};
-
-registerRawHelper("raw", helperFunction);
-
-export default class RawHelper extends Helper {
- @service renderGlimmer;
-
- compute(args, params) {
- registerDestructor(this, this.cleanup);
- return helperFunction(...args, params);
- }
-
- @bind
- cleanup() {
- schedule("afterRender", () => this.renderGlimmer.cleanup());
- }
-}
diff --git a/app/assets/javascripts/discourse/app/helpers/replace-emoji.js b/app/assets/javascripts/discourse/app/helpers/replace-emoji.js
index 523a71752e7..90ab9bd58c4 100644
--- a/app/assets/javascripts/discourse/app/helpers/replace-emoji.js
+++ b/app/assets/javascripts/discourse/app/helpers/replace-emoji.js
@@ -1,10 +1,7 @@
import { htmlSafe, isHTMLSafe } from "@ember/template";
-import { registerRawHelper } from "discourse/lib/helpers";
import { emojiUnescape } from "discourse/lib/text";
import { escapeExpression } from "discourse/lib/utilities";
-registerRawHelper("replace-emoji", replaceEmoji);
-
export default function replaceEmoji(text, options) {
text = isHTMLSafe(text) ? text.toString() : escapeExpression(text);
return htmlSafe(emojiUnescape(text, options));
diff --git a/app/assets/javascripts/discourse/app/helpers/shorten-url.js b/app/assets/javascripts/discourse/app/helpers/shorten-url.js
index 36edb5175cb..3d8da0e6670 100644
--- a/app/assets/javascripts/discourse/app/helpers/shorten-url.js
+++ b/app/assets/javascripts/discourse/app/helpers/shorten-url.js
@@ -1,6 +1,3 @@
-import { registerRawHelper } from "discourse/lib/helpers";
-
-registerRawHelper("shorten-url", shortenUrl);
export default function shortenUrl(url) {
let matches = url.match(/\//g);
diff --git a/app/assets/javascripts/discourse/app/helpers/theme-i18n.js b/app/assets/javascripts/discourse/app/helpers/theme-i18n.js
index b1d0195e2ef..233e68c7ce3 100644
--- a/app/assets/javascripts/discourse/app/helpers/theme-i18n.js
+++ b/app/assets/javascripts/discourse/app/helpers/theme-i18n.js
@@ -1,7 +1,5 @@
-import { registerRawHelper } from "discourse/lib/helpers";
import { i18n } from "discourse-i18n";
-registerRawHelper("theme-i18n", themeI18n);
export default function themeI18n(themeId, key, params) {
if (typeof themeId !== "number") {
throw new Error(
diff --git a/app/assets/javascripts/discourse/app/helpers/theme-prefix.js b/app/assets/javascripts/discourse/app/helpers/theme-prefix.js
index bea741b7970..60cd5fc065e 100644
--- a/app/assets/javascripts/discourse/app/helpers/theme-prefix.js
+++ b/app/assets/javascripts/discourse/app/helpers/theme-prefix.js
@@ -1,6 +1,3 @@
-import { registerRawHelper } from "discourse/lib/helpers";
-
-registerRawHelper("theme-prefix", themePrefix);
export default function themePrefix(themeId, key) {
return `theme_translations.${themeId}.${key}`;
}
diff --git a/app/assets/javascripts/discourse/app/helpers/theme-setting.js b/app/assets/javascripts/discourse/app/helpers/theme-setting.js
index acd3c020ec7..a212e90fb62 100644
--- a/app/assets/javascripts/discourse/app/helpers/theme-setting.js
+++ b/app/assets/javascripts/discourse/app/helpers/theme-setting.js
@@ -1,7 +1,5 @@
-import { registerRawHelper } from "discourse/lib/helpers";
import { getSetting as getThemeSetting } from "discourse/lib/theme-settings-store";
-registerRawHelper("theme-setting", themeSetting);
export default function themeSetting(themeId, key) {
if (typeof themeId !== "number") {
throw new Error(
diff --git a/app/assets/javascripts/discourse/app/helpers/topic-featured-link.js b/app/assets/javascripts/discourse/app/helpers/topic-featured-link.js
index 3cd95cd96db..d1c67a090c2 100644
--- a/app/assets/javascripts/discourse/app/helpers/topic-featured-link.js
+++ b/app/assets/javascripts/discourse/app/helpers/topic-featured-link.js
@@ -1,8 +1,6 @@
import { htmlSafe } from "@ember/template";
-import { registerRawHelper } from "discourse/lib/helpers";
import renderTopicFeaturedLink from "discourse/lib/render-topic-featured-link";
-registerRawHelper("topic-featured-link", topicFeaturedLink);
export default function topicFeaturedLink(topic, params) {
return htmlSafe(renderTopicFeaturedLink(topic, params));
}
diff --git a/app/assets/javascripts/discourse/app/helpers/topic-link.js b/app/assets/javascripts/discourse/app/helpers/topic-link.js
index 217e0e27676..1b6ee2ff1c0 100644
--- a/app/assets/javascripts/discourse/app/helpers/topic-link.js
+++ b/app/assets/javascripts/discourse/app/helpers/topic-link.js
@@ -1,7 +1,5 @@
import { htmlSafe } from "@ember/template";
-import { registerRawHelper } from "discourse/lib/helpers";
-registerRawHelper("topic-link", topicLink);
export default function topicLink(topic, args = {}) {
const title = topic.get("fancyTitle");
diff --git a/app/assets/javascripts/discourse/app/helpers/topic-status-icons.js b/app/assets/javascripts/discourse/app/helpers/topic-status-icons.js
deleted file mode 100644
index 3efe797cb1e..00000000000
--- a/app/assets/javascripts/discourse/app/helpers/topic-status-icons.js
+++ /dev/null
@@ -1,18 +0,0 @@
-import deprecated from "discourse/lib/deprecated";
-import { RAW_TOPIC_LIST_DEPRECATION_OPTIONS } from "discourse/lib/plugin-api";
-
-const TopicStatusIcons = new (class {
- entries = [];
-
- addObject(entry) {
- deprecated(
- "TopicStatusIcons is deprecated. Use 'after-topic-status' plugin outlet instead.",
- RAW_TOPIC_LIST_DEPRECATION_OPTIONS
- );
-
- const [attribute, iconName, titleKey] = entry;
- this.entries.push({ attribute, iconName, titleKey });
- }
-})();
-
-export default TopicStatusIcons;
diff --git a/app/assets/javascripts/discourse/app/helpers/value-entered.js b/app/assets/javascripts/discourse/app/helpers/value-entered.js
index 78c731f8126..d98c988350b 100644
--- a/app/assets/javascripts/discourse/app/helpers/value-entered.js
+++ b/app/assets/javascripts/discourse/app/helpers/value-entered.js
@@ -1,6 +1,3 @@
-import { registerRawHelper } from "discourse/lib/helpers";
-
-registerRawHelper("value-entered", valueEntered);
export default function valueEntered(value) {
if (!value) {
return "";
diff --git a/app/assets/javascripts/discourse/app/instance-initializers/auto-load-modules.js b/app/assets/javascripts/discourse/app/instance-initializers/auto-load-modules.js
index 4beb1ffc419..9a02796796e 100644
--- a/app/assets/javascripts/discourse/app/instance-initializers/auto-load-modules.js
+++ b/app/assets/javascripts/discourse/app/instance-initializers/auto-load-modules.js
@@ -1,8 +1,5 @@
import { setOwner } from "@ember/owner";
-import Handlebars from "handlebars";
import { createHelperContext, registerHelpers } from "discourse/lib/helpers";
-import RawHandlebars from "discourse/lib/raw-handlebars";
-import { registerRawHelpers } from "discourse/lib/raw-handlebars-helpers";
function isThemeOrPluginHelper(path) {
return (
@@ -38,7 +35,6 @@ export function autoLoadModules(owner, registry) {
createHelperContext(context);
registerHelpers(registry);
- registerRawHelpers(RawHandlebars, Handlebars, owner);
}
export default {
diff --git a/app/assets/javascripts/discourse/app/instance-initializers/component-templates.js b/app/assets/javascripts/discourse/app/instance-initializers/component-templates.js
index 519cf5d7d31..2b3f502567e 100644
--- a/app/assets/javascripts/discourse/app/instance-initializers/component-templates.js
+++ b/app/assets/javascripts/discourse/app/instance-initializers/component-templates.js
@@ -2,15 +2,12 @@ import * as GlimmerManager from "@glimmer/manager";
import ClassicComponent from "@ember/component";
import deprecated from "discourse/lib/deprecated";
import DiscourseTemplateMap from "discourse/lib/discourse-template-map";
-import { RAW_TOPIC_LIST_DEPRECATION_OPTIONS } from "discourse/lib/plugin-api";
import { getThemeInfo } from "discourse/lib/source-identifier";
// We're using a patched version of Ember with a modified GlimmerManager to make the code below work.
// This patch is not ideal, but Ember does not allow us to change a component template after initial association
// https://github.com/glimmerjs/glimmer-vm/blob/03a4b55c03/packages/%40glimmer/manager/lib/public/template.ts#L14-L20
-const LEGACY_TOPIC_LIST_OVERRIDES = ["topic-list", "topic-list-item"];
-
function sourceForModuleName(name) {
const pluginMatch = name.match(/^discourse\/plugins\/([^\/]+)\//)?.[1];
if (pluginMatch) {
@@ -74,25 +71,14 @@ export default {
const originalTemplate = GlimmerManager.getComponentTemplate(component);
if (originalTemplate) {
- if (LEGACY_TOPIC_LIST_OVERRIDES.includes(componentName)) {
- // Special handling for these, with a different deprecation id, so the auto-feature-flag works correctly
- deprecated(
- `Overriding '${componentName}' template is deprecated. Use the value transformer 'topic-list-columns' and other new topic-list plugin APIs instead.`,
- {
- ...RAW_TOPIC_LIST_DEPRECATION_OPTIONS,
- source: sourceForModuleName(finalOverrideModuleName),
- }
- );
- } else {
- deprecated(
- `Overriding component templates is deprecated, and will soon be disabled. Use plugin outlets, CSS, or other customization APIs instead. [${finalOverrideModuleName}]`,
- {
- id: "discourse.component-template-overrides",
- url: "https://meta.discourse.org/t/355668",
- source: sourceForModuleName(finalOverrideModuleName),
- }
- );
- }
+ deprecated(
+ `Overriding component templates is deprecated, and will soon be disabled. Use plugin outlets, CSS, or other customization APIs instead. [${finalOverrideModuleName}]`,
+ {
+ id: "discourse.component-template-overrides",
+ url: "https://meta.discourse.org/t/355668",
+ source: sourceForModuleName(finalOverrideModuleName),
+ }
+ );
const overrideTemplate = require(finalOverrideModuleName).default;
diff --git a/app/assets/javascripts/discourse/app/instance-initializers/eager-load-raw-templates.js b/app/assets/javascripts/discourse/app/instance-initializers/eager-load-raw-templates.js
deleted file mode 100644
index 86245adb363..00000000000
--- a/app/assets/javascripts/discourse/app/instance-initializers/eager-load-raw-templates.js
+++ /dev/null
@@ -1,7 +0,0 @@
-import { eagerLoadRawTemplateModules } from "discourse/lib/raw-templates";
-
-export default {
- initialize() {
- eagerLoadRawTemplateModules();
- },
-};
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
deleted file mode 100644
index b73462ef685..00000000000
--- a/app/assets/javascripts/discourse/app/instance-initializers/hbr-topic-list-overrides.js
+++ /dev/null
@@ -1,14 +0,0 @@
-import { registerDeprecationHandler } from "discourse/lib/deprecated";
-import { needsHbrTopicList } from "discourse/lib/raw-templates";
-
-export default {
- before: "inject-objects",
-
- initialize() {
- registerDeprecationHandler((message, opts) => {
- if (opts?.id === "discourse.hbr-topic-list-overrides") {
- needsHbrTopicList(true);
- }
- });
- },
-};
diff --git a/app/assets/javascripts/discourse/app/lib/helpers.js b/app/assets/javascripts/discourse/app/lib/helpers.js
index cdbcd53111f..3cecf00063f 100644
--- a/app/assets/javascripts/discourse/app/lib/helpers.js
+++ b/app/assets/javascripts/discourse/app/lib/helpers.js
@@ -1,9 +1,7 @@
import Helper from "@ember/component/helper";
-import { get } from "@ember/object";
import { dasherize } from "@ember/string";
import { htmlSafe } from "@ember/template";
import deprecated from "discourse/lib/deprecated";
-import RawHandlebars from "discourse/lib/raw-handlebars";
export function makeArray(obj) {
if (obj === null || obj === undefined) {
@@ -27,17 +25,6 @@ export function htmlHelper(fn) {
const _helpers = {};
-function rawGet(ctx, property, options) {
- if (options.types && options.data.view) {
- let view = options.data.view;
- return view.getStream
- ? view.getStream(property).value()
- : view.getAttr(property);
- } else {
- return get(ctx, property);
- }
-}
-
export function registerHelper(name, fn) {
_helpers[name] = Helper.helper(fn);
}
@@ -63,31 +50,6 @@ export function helperContext() {
return _helperContext;
}
-function resolveParams(ctx, options) {
- let params = {};
- const hash = options.hash;
-
- if (hash) {
- if (options.hashTypes) {
- Object.keys(hash).forEach(function (k) {
- const type = options.hashTypes[k];
- if (
- type === "STRING" ||
- type === "StringLiteral" ||
- type === "SubExpression"
- ) {
- params[k] = hash[k];
- } else if (type === "ID" || type === "PathExpression") {
- params[k] = rawGet(ctx, hash[k], options);
- }
- });
- } else {
- params = hash;
- }
- }
- return params;
-}
-
/**
* Register a helper for Ember and raw-hbs. This exists for
* legacy reasons, and should be avoided in new code. Instead, you should
@@ -95,7 +57,7 @@ function resolveParams(ctx, options) {
*/
export function registerUnbound(name, fn) {
deprecated(
- `[registerUnbound ${name}] registerUnbound is deprecated. Instead, you should export a default function from 'discourse/helpers/${name}.js'. If the helper is also used in raw-hbs, you can register it using 'registerRawHelper'.`,
+ `[registerUnbound ${name}] registerUnbound is deprecated. Instead, you should export a default function from 'discourse/helpers/${name}.js'.`,
{ id: "discourse.register-unbound" }
);
@@ -104,29 +66,14 @@ export function registerUnbound(name, fn) {
return fn(...params, args);
}
};
-
- registerRawHelper(name, fn);
}
/**
* Register a helper for raw-hbs only
*/
-export function registerRawHelper(name, fn) {
- const func = function (...args) {
- const options = args.pop();
- const properties = args;
-
- for (let i = 0; i < properties.length; i++) {
- if (
- options.types &&
- (options.types[i] === "ID" || options.types[i] === "PathExpression")
- ) {
- properties[i] = rawGet(this, properties[i], options);
- }
- }
-
- return fn.call(this, ...properties, resolveParams(this, options));
- };
-
- RawHandlebars.registerHelper(name, func);
+export function registerRawHelper(name) {
+ deprecated(
+ `[registerRawHelper ${name}] the raw handlebars system has been removed, so calls to registerRawHelper should be removed.`,
+ { id: "discourse.register-raw-helper" }
+ );
}
diff --git a/app/assets/javascripts/discourse/app/lib/plugin-api.gjs b/app/assets/javascripts/discourse/app/lib/plugin-api.gjs
index cf2f851d532..793d3cc3caf 100644
--- a/app/assets/javascripts/discourse/app/lib/plugin-api.gjs
+++ b/app/assets/javascripts/discourse/app/lib/plugin-api.gjs
@@ -199,11 +199,7 @@ const POST_STREAM_DEPRECATION_OPTIONS = {
// url: "", // TODO (glimmer-post-stream) uncomment when the topic is created on meta
};
-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 blockedModifications = ["component:topic-list"];
const appliedModificationIds = new WeakMap();
@@ -295,7 +291,11 @@ class PluginApi {
return;
}
- const klass = this.container.factoryFor(normalized);
+ let klass;
+ if (!blockedModifications.includes(normalized)) {
+ klass = this.container.factoryFor(normalized);
+ }
+
if (!klass) {
if (!opts.ignoreMissing) {
// eslint-disable-next-line no-console
@@ -328,17 +328,6 @@ class PluginApi {
* ```
**/
modifyClass(resolverName, changes, opts) {
- if (
- resolverName === "component:topic-list" ||
- resolverName === "component:topic-list-item" ||
- resolverName === "raw-view:topic-status"
- ) {
- deprecated(
- `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
- );
- }
-
const klass = this._resolveClass(resolverName, opts);
if (!klass) {
return;
@@ -376,17 +365,6 @@ class PluginApi {
* ```
**/
modifyClassStatic(resolverName, changes, opts) {
- if (
- resolverName === "component:topic-list" ||
- resolverName === "component:topic-list-item" ||
- resolverName === "raw-view:topic-status"
- ) {
- deprecated(
- `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
- );
- }
-
const klass = this._resolveClass(resolverName, opts);
if (!klass) {
return;
diff --git a/app/assets/javascripts/discourse/app/lib/plugin-connectors.js b/app/assets/javascripts/discourse/app/lib/plugin-connectors.js
index 5afeb542b34..3d92b0bf71d 100644
--- a/app/assets/javascripts/discourse/app/lib/plugin-connectors.js
+++ b/app/assets/javascripts/discourse/app/lib/plugin-connectors.js
@@ -6,10 +6,8 @@ import {
import templateOnly from "@ember/component/template-only";
import { isDeprecatedOutletArgument } from "discourse/helpers/deprecated-outlet-argument";
import deprecated, { withSilencedDeprecations } from "discourse/lib/deprecated";
-import { buildRawConnectorCache } from "discourse/lib/raw-templates";
let _connectorCache;
-let _rawConnectorCache;
let _extraConnectorClasses = {};
let _extraConnectorComponents = {};
let debugOutletCallback;
@@ -64,7 +62,6 @@ function findOutlets(keys, callback) {
export function clearCache() {
_connectorCache = null;
- _rawConnectorCache = null;
}
/**
@@ -235,13 +232,6 @@ export function renderedConnectorsFor(outletName, args, context, owner) {
});
}
-export function rawConnectorsFor(outletName) {
- if (!_rawConnectorCache) {
- _rawConnectorCache = buildRawConnectorCache();
- }
- return _rawConnectorCache[outletName] || [];
-}
-
export function buildArgsWithDeprecations(args, deprecatedArgs, opts = {}) {
const output = {};
diff --git a/app/assets/javascripts/discourse/app/lib/raw-handlebars-helpers.js b/app/assets/javascripts/discourse/app/lib/raw-handlebars-helpers.js
deleted file mode 100644
index c9550c038a3..00000000000
--- a/app/assets/javascripts/discourse/app/lib/raw-handlebars-helpers.js
+++ /dev/null
@@ -1,112 +0,0 @@
-import { get } from "@ember/object";
-
-export const RUNTIME_OPTIONS = {
- allowProtoPropertiesByDefault: true,
-};
-
-export function registerRawHelpers(hbs, handlebarsClass, owner) {
- if (!hbs.helpers) {
- hbs.helpers = Object.create(handlebarsClass.helpers);
- }
-
- lazyLoadHelpers(hbs, owner);
-
- if (hbs.__helpers_registered) {
- return;
- }
- hbs.__helpers_registered = true;
-
- hbs.helpers["get"] = function (context, options) {
- if (!context || !options.contexts) {
- return;
- }
-
- if (typeof context !== "string") {
- return context;
- }
-
- let firstContext = options.contexts[0];
- let val = firstContext[context];
-
- if (context.toString().startsWith("controller.")) {
- context = context.slice(context.indexOf(".") + 1);
- }
-
- return val === undefined ? get(firstContext, context) : val;
- };
-
- // #each .. in support (as format is transformed to this)
- hbs.registerHelper(
- "each",
- function (localName, inKeyword, contextName, options) {
- if (typeof contextName === "undefined") {
- return;
- }
- let list = get(this, contextName);
- let output = [];
- let innerContext = options.contexts[0];
- for (let i = 0; i < list.length; i++) {
- innerContext[localName] = list[i];
- output.push(options.fn(innerContext));
- }
- delete innerContext[localName];
- return output.join("");
- }
- );
-
- function stringCompatHelper(fn) {
- const old = hbs.helpers[fn];
- hbs.helpers[fn] = function (context, options) {
- return old.apply(this, [hbs.helpers.get(context, options), options]);
- };
- }
-
- // HACK: Ensure that the variable is resolved only once.
- // The "get" function will be called twice because both `if` and `unless`
- // helpers are patched to resolve the variable and `unless` is implemented
- // as not `if`. For example, for {{#unless var}} will generate a stack
- // trace like:
- //
- // - patched-unless("var") "var" is resolved to its value, val
- // - unless(val) unless is implemented as !if
- // - !patched-if(val) val is already resolved, but it is resolved again
- // - !if(???) at this point, ??? usually stands for undefined
- //
- // The following code ensures that patched-unless will call `if` directly,
- // `patched-unless("var")` will return `!if(val)`.
- const oldIf = hbs.helpers["if"];
- hbs.helpers["unless"] = function (context, options) {
- return oldIf.apply(this, [
- hbs.helpers.get(context, options),
- {
- fn: options.inverse,
- inverse: options.fn,
- hash: options.hash,
- },
- ]);
- };
-
- stringCompatHelper("if");
- stringCompatHelper("with");
-}
-
-function lazyLoadHelpers(hbs, owner) {
- // Reimplements `helperMissing` so that it triggers a lookup() for
- // a helper of that name. Means we don't need to eagerly load all
- // helpers/* files during boot.
- hbs.registerHelper("helperMissing", function (...args) {
- const opts = args[args.length - 1];
- if (opts?.name) {
- // Lookup and evaluate the relevant module. Raw helpers may be registered as a side effect
- owner.lookup(`helper:${opts.name}`);
-
- if (hbs.helpers[opts.name]) {
- // Helper now exists, invoke it
- return hbs.helpers[opts.name]?.call(this, ...arguments);
- } else {
- // Not a helper, treat as property
- return hbs.helpers["get"].call(this, ...arguments);
- }
- }
- });
-}
diff --git a/app/assets/javascripts/discourse/app/lib/raw-handlebars.js b/app/assets/javascripts/discourse/app/lib/raw-handlebars.js
deleted file mode 100644
index 6d805d33662..00000000000
--- a/app/assets/javascripts/discourse/app/lib/raw-handlebars.js
+++ /dev/null
@@ -1,134 +0,0 @@
-import Handlebars from "handlebars";
-
-// This is a mechanism for quickly rendering templates which is Ember aware
-// templates are highly compatible with Ember so you don't need to worry about calling "get"
-// and discourseComputed properties function, additionally it uses stringParams like Ember does
-const RawHandlebars = Handlebars.create();
-
-function buildPath(blk, args) {
- let result = {
- type: "PathExpression",
- data: false,
- depth: blk.path.depth,
- loc: blk.path.loc,
- };
-
- // Server side precompile doesn't have jquery.extend
- Object.keys(args).forEach(function (a) {
- result[a] = args[a];
- });
-
- return result;
-}
-
-function replaceGet(ast) {
- let visitor = new Handlebars.Visitor();
- visitor.mutating = true;
-
- visitor.MustacheStatement = function (mustache) {
- if (!(mustache.params.length || mustache.hash)) {
- mustache.params[0] = mustache.path;
- mustache.path = buildPath(mustache, {
- parts: ["get"],
- original: "get",
- strict: true,
- falsy: true,
- });
- }
- return Handlebars.Visitor.prototype.MustacheStatement.call(this, mustache);
- };
-
- // rewrite `each x as |y|` as each y in x`
- // This allows us to use the same syntax in all templates
- visitor.BlockStatement = function (block) {
- if (block.path.original === "each" && block.params.length === 1) {
- let paramName = block.program.blockParams[0];
- block.params = [
- buildPath(block, { original: paramName }),
- { type: "CommentStatement", value: "in" },
- block.params[0],
- ];
- delete block.program.blockParams;
- }
-
- return Handlebars.Visitor.prototype.BlockStatement.call(this, block);
- };
-
- visitor.accept(ast);
-}
-
-if (Handlebars.Compiler) {
- RawHandlebars.Compiler = function () {};
- RawHandlebars.Compiler.prototype = Object.create(
- Handlebars.Compiler.prototype
- );
- RawHandlebars.Compiler.prototype.compiler = RawHandlebars.Compiler;
-
- RawHandlebars.JavaScriptCompiler = function () {};
-
- RawHandlebars.JavaScriptCompiler.prototype = Object.create(
- Handlebars.JavaScriptCompiler.prototype
- );
- RawHandlebars.JavaScriptCompiler.prototype.compiler =
- RawHandlebars.JavaScriptCompiler;
- RawHandlebars.JavaScriptCompiler.prototype.namespace = "RawHandlebars";
-
- RawHandlebars.precompile = function (value, asObject, { plugins = [] } = {}) {
- let ast = Handlebars.parse(value);
- replaceGet(ast);
- plugins.forEach((plugin) => plugin(ast));
-
- let options = {
- knownHelpers: {
- get: true,
- },
- data: true,
- stringParams: true,
- };
-
- asObject = asObject === undefined ? true : asObject;
-
- let environment = new RawHandlebars.Compiler().compile(ast, options);
- return new RawHandlebars.JavaScriptCompiler().compile(
- environment,
- options,
- undefined,
- asObject
- );
- };
-
- RawHandlebars.compile = function (string, { plugins = [] } = {}) {
- let ast = Handlebars.parse(string);
- replaceGet(ast);
- plugins.forEach((plugin) => plugin(ast));
-
- // this forces us to rewrite helpers
- let options = { data: true, stringParams: true };
- let environment = new RawHandlebars.Compiler().compile(ast, options);
- let templateSpec = new RawHandlebars.JavaScriptCompiler().compile(
- environment,
- options,
- undefined,
- true
- );
-
- let t = RawHandlebars.template(templateSpec);
- t.isMethod = false;
-
- return t;
- };
-}
-
-export function template() {
- return RawHandlebars.template.apply(this, arguments);
-}
-
-export function precompile() {
- return RawHandlebars.precompile.apply(this, arguments);
-}
-
-export function compile() {
- return RawHandlebars.compile.apply(this, arguments);
-}
-
-export default RawHandlebars;
diff --git a/app/assets/javascripts/discourse/app/lib/raw-render-glimmer.js b/app/assets/javascripts/discourse/app/lib/raw-render-glimmer.js
deleted file mode 100644
index da0eb9815ce..00000000000
--- a/app/assets/javascripts/discourse/app/lib/raw-render-glimmer.js
+++ /dev/null
@@ -1,55 +0,0 @@
-import { getOwner } from "@ember/owner";
-import { schedule } from "@ember/runloop";
-
-let counter = 0;
-
-/**
- * Generate HTML which can be inserted into a raw-hbs template to render a Glimmer component.
- * The result of this function must be rendered immediately, so that an `afterRender` hook
- * can access the element in the DOM and attach the glimmer component.
- *
- * Example usage:
- *
- * ```hbs
- * {{! raw-templates/something-cool.hbr }}
- * {{html-safe view.html}}
- * ```
- *
- * ```gjs
- * // raw-views/something-cool.gjs
- * import EmberObject from "@ember/object";
- * import rawRenderGlimmer from "discourse/lib/raw-render-glimmer";
- *
- * export default class SomethingCool extends EmberObject {
- * get html() {
- * return rawRenderGlimmer(this, "div", <template>Hello {{@data.name}}</template>, { name: this.name });
- * }
- * ```
- *
- * And then this can be invoked from any other raw view (including raw plugin outlets) like:
- *
- * ```hbs
- * {{raw "something-cool" name="david"}}
- * ```
- */
-export default function rawRenderGlimmer(owner, renderInto, component, data) {
- const renderGlimmerService = getOwner(owner).lookup("service:render-glimmer");
-
- counter++;
- const id = `_render_glimmer_${counter}`;
- const [type, ...classNames] = renderInto.split(".");
-
- schedule("afterRender", () => {
- const element = document.getElementById(id);
- if (element) {
- const componentInfo = {
- element,
- component,
- data,
- };
- renderGlimmerService.add(componentInfo);
- }
- });
-
- return `<${type} id="${id}" class="${classNames.join(" ")}"></${type}>`;
-}
diff --git a/app/assets/javascripts/discourse/app/lib/raw-templates.js b/app/assets/javascripts/discourse/app/lib/raw-templates.js
deleted file mode 100644
index 9dc58e8f729..00000000000
--- a/app/assets/javascripts/discourse/app/lib/raw-templates.js
+++ /dev/null
@@ -1,108 +0,0 @@
-import require from "require";
-import deprecated from "discourse/lib/deprecated";
-import { RAW_TOPIC_LIST_DEPRECATION_OPTIONS } from "discourse/lib/plugin-api";
-import { getResolverOption } from "discourse/resolver";
-
-export const __DISCOURSE_RAW_TEMPLATES = {};
-let _needsHbrTopicList = false;
-
-export function needsHbrTopicList(value) {
- if (value === undefined) {
- return _needsHbrTopicList;
- } else {
- _needsHbrTopicList = value;
- }
-}
-
-export function resetNeedsHbrTopicList() {
- _needsHbrTopicList = false;
-}
-
-const TOPIC_LIST_TEMPLATE_NAMES = [
- "list/action-list",
- "list/activity-column",
- "list/category-column",
- "list/new-list-header-controls",
- "list/participant-groups",
- "list/post-count-or-badges",
- "list/posters-column",
- "list/posts-count-column",
- "list/topic-excerpt",
- "list/topic-list-item",
- "list/unread-indicator",
- "list/visited-line",
- "mobile/list/topic-list-item",
- "topic-bulk-select-dropdown",
- "topic-list-header-column",
- "topic-list-header",
- "topic-post-badges",
- "topic-status",
-];
-
-export function addRawTemplate(name, template, opts = {}) {
- const cleanName = name.replace(/^javascripts\//, "");
- if (
- (TOPIC_LIST_TEMPLATE_NAMES.includes(cleanName) ||
- name.includes("/connectors/")) &&
- !opts.core &&
- !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, RAW_TOPIC_LIST_DEPRECATION_OPTIONS);
-
- needsHbrTopicList(true);
- }
-
- // Core templates should never overwrite themes / plugins
- if (opts.core && __DISCOURSE_RAW_TEMPLATES[name]) {
- return;
- }
- __DISCOURSE_RAW_TEMPLATES[name] = template;
-}
-
-export function removeRawTemplate(name) {
- delete __DISCOURSE_RAW_TEMPLATES[name];
-}
-
-export function findRawTemplate(name) {
- if (getResolverOption("mobileView")) {
- return (
- __DISCOURSE_RAW_TEMPLATES[`javascripts/mobile/${name}`] ||
- __DISCOURSE_RAW_TEMPLATES[`javascripts/${name}`] ||
- __DISCOURSE_RAW_TEMPLATES[`mobile/${name}`] ||
- __DISCOURSE_RAW_TEMPLATES[name]
- );
- }
-
- return (
- __DISCOURSE_RAW_TEMPLATES[`javascripts/${name}`] ||
- __DISCOURSE_RAW_TEMPLATES[name]
- );
-}
-
-export function buildRawConnectorCache() {
- let result = {};
- Object.keys(__DISCOURSE_RAW_TEMPLATES).forEach((resource) => {
- const segments = resource.split("/");
- const connectorIndex = segments.indexOf("connectors");
-
- if (connectorIndex >= 0) {
- const outletName = segments[connectorIndex + 1];
- result[outletName] ??= [];
- result[outletName].push({
- template: __DISCOURSE_RAW_TEMPLATES[resource],
- });
- }
- });
- return result;
-}
-
-export function eagerLoadRawTemplateModules() {
- for (const key of Object.keys(requirejs.entries)) {
- if (key.includes("/raw-templates/")) {
- require(key);
- }
- }
-}
diff --git a/app/assets/javascripts/discourse/app/lib/utilities.js b/app/assets/javascripts/discourse/app/lib/utilities.js
index 58faa807bd7..cdbb4e950bd 100644
--- a/app/assets/javascripts/discourse/app/lib/utilities.js
+++ b/app/assets/javascripts/discourse/app/lib/utilities.js
@@ -1,4 +1,3 @@
-import Handlebars from "handlebars";
import $ from "jquery";
import * as AvatarUtils from "discourse/lib/avatar-utils";
import deprecated from "discourse/lib/deprecated";
@@ -41,11 +40,6 @@ export function escapeExpression(string) {
return "";
}
- // don't escape SafeStrings, since they're already safe
- if (string instanceof Handlebars.SafeString) {
- return string.toString();
- }
-
return escape(string);
}
diff --git a/app/assets/javascripts/discourse/app/loader-shims.js b/app/assets/javascripts/discourse/app/loader-shims.js
index 29657c48d18..80ea6f7b988 100644
--- a/app/assets/javascripts/discourse/app/loader-shims.js
+++ b/app/assets/javascripts/discourse/app/loader-shims.js
@@ -27,7 +27,6 @@ loaderShim("a11y-dialog", () => importSync("a11y-dialog"));
loaderShim("discourse-i18n", () => importSync("discourse-i18n"));
loaderShim("ember-modifier", () => importSync("ember-modifier"));
loaderShim("ember-route-template", () => importSync("ember-route-template"));
-loaderShim("handlebars", () => importSync("handlebars"));
loaderShim("jquery", () => importSync("jquery"));
loaderShim("js-yaml", () => importSync("js-yaml"));
loaderShim("message-bus-client", () => importSync("message-bus-client"));
diff --git a/app/assets/javascripts/discourse/app/models/site.js b/app/assets/javascripts/discourse/app/models/site.js
index 50b5670f26c..13817690792 100644
--- a/app/assets/javascripts/discourse/app/models/site.js
+++ b/app/assets/javascripts/discourse/app/models/site.js
@@ -89,7 +89,6 @@ export default class Site extends RestModel {
@sort("categories", "topicCountDesc") categoriesByCount;
#glimmerPostStreamEnabled;
- #glimmerTopicDecision;
init() {
super.init(...arguments);
@@ -161,51 +160,6 @@ export default class Site extends RestModel {
return enabled;
}
- get useGlimmerTopicList() {
- if (this.#glimmerTopicDecision !== undefined) {
- // Caches the decision after the first call, and avoids re-printing the same message
- return this.#glimmerTopicDecision;
- }
-
- let decision;
-
- const { needsHbrTopicList } = require("discourse/lib/raw-templates");
-
- /* eslint-disable no-console */
- const settingValue = this.siteSettings.glimmer_topic_list_mode;
- if (settingValue === "enabled") {
- if (needsHbrTopicList()) {
- console.log(
- "⚠️ Using the new 'glimmer' topic list, even though some themes/plugins are not ready"
- );
- } else {
- console.log("✅ Using the new 'glimmer' topic list");
- }
-
- decision = true;
- } else if (settingValue === "disabled") {
- decision = false;
- } else {
- // auto
- if (needsHbrTopicList()) {
- console.log(
- "⚠️ Detected themes/plugins which are incompatible with the new 'glimmer' topic-list. Falling back to old implementation."
- );
- decision = false;
- } else {
- if (!isTesting() && !isRailsTesting()) {
- console.log("✅ Using the new 'glimmer' topic list");
- }
- decision = true;
- }
- }
- /* eslint-enable no-console */
-
- this.#glimmerTopicDecision = decision;
-
- return decision;
- }
-
@computed("categories.[]")
get categoriesById() {
const map = new Map();
diff --git a/app/assets/javascripts/discourse/app/raw-templates/flat-button.hbr b/app/assets/javascripts/discourse/app/raw-templates/flat-button.hbr
deleted file mode 100644
index b74ca394e20..00000000000
--- a/app/assets/javascripts/discourse/app/raw-templates/flat-button.hbr
+++ /dev/null
@@ -1,3 +0,0 @@
-<button class='btn-transparent {{class}}' title='{{i18n "topics.bulk.toggle"}}'>
- {{d-icon icon}}
-</button>
diff --git a/app/assets/javascripts/discourse/app/raw-templates/list/action-list.hbr b/app/assets/javascripts/discourse/app/raw-templates/list/action-list.hbr
deleted file mode 100644
index 5714b98d83f..00000000000
--- a/app/assets/javascripts/discourse/app/raw-templates/list/action-list.hbr
+++ /dev/null
@@ -1,8 +0,0 @@
-{{#if postNumbers}}
-<div class='post-actions {{className}}'>
- {{d-icon icon}}
- {{#each postNumbers as |postNumber|}}
- <a href='{{topic.url}}/{{postNumber}}'>#{{postNumber}}</a>
- {{/each}}
-</div>
-{{/if}}
diff --git a/app/assets/javascripts/discourse/app/raw-templates/list/activity-column.hbr b/app/assets/javascripts/discourse/app/raw-templates/list/activity-column.hbr
deleted file mode 100644
index d2d4313272c..00000000000
--- a/app/assets/javascripts/discourse/app/raw-templates/list/activity-column.hbr
+++ /dev/null
@@ -1,7 +0,0 @@
-<{{tagName}} class="{{class}} {{cold-age-class topic.createdAt startDate=topic.bumpedAt class=""}} activity" title="{{html-safe topic.bumpedAtTitle}}">
- <a class="post-activity" href="{{topic.lastPostUrl}}">
- {{~raw-plugin-outlet name="topic-list-before-relative-date"~}}
- {{~plugin-outlet name="topic-list-before-relative-date" outletArgs=(raw-hash topic=topic)~}}
- {{~format-date topic.bumpedAt format="tiny" noTitle="true"~}}
- </a>
-</{{tagName}}>
diff --git a/app/assets/javascripts/discourse/app/raw-templates/list/category-column.hbr b/app/assets/javascripts/discourse/app/raw-templates/list/category-column.hbr
deleted file mode 100644
index 32cc25b0c25..00000000000
--- a/app/assets/javascripts/discourse/app/raw-templates/list/category-column.hbr
+++ /dev/null
@@ -1 +0,0 @@
-<td class='category topic-list-data'>{{category-link category}}</td>
diff --git a/app/assets/javascripts/discourse/app/raw-templates/list/new-list-header-controls.hbr b/app/assets/javascripts/discourse/app/raw-templates/list/new-list-header-controls.hbr
deleted file mode 100644
index 9757caf8c30..00000000000
--- a/app/assets/javascripts/discourse/app/raw-templates/list/new-list-header-controls.hbr
+++ /dev/null
@@ -1,13 +0,0 @@
-{{#if view.staticLabel}}
- <span class="static-label">{{view.staticLabel}}</span>
-{{else}}
- <button class="topics-replies-toggle --all{{#if view.allActive}} active{{/if}}">
- {{i18n "filters.new.all"}}
- </button>
- <button class="topics-replies-toggle --topics{{#if view.topicsActive}} active{{/if}}">
- {{view.topicsButtonLabel}}
- </button>
- <button class="topics-replies-toggle --replies{{#if view.repliesActive}} active{{/if}}">
- {{view.repliesButtonLabel}}
- </button>
-{{/if}}
diff --git a/app/assets/javascripts/discourse/app/raw-templates/list/participant-groups.hbr b/app/assets/javascripts/discourse/app/raw-templates/list/participant-groups.hbr
deleted file mode 100644
index 53d796a7860..00000000000
--- a/app/assets/javascripts/discourse/app/raw-templates/list/participant-groups.hbr
+++ /dev/null
@@ -1,18 +0,0 @@
-<div
- class="participant-group-wrapper"
- role="list"
- aria-label="{{i18n 'topic.participant_groups'}}"
->
- {{#each groups as |group|}}
- <div class="participant-group">
- <a
- class="user-group trigger-group-card"
- href="{{group.url}}"
- data-group-card="{{group.name}}"
- >
- {{d-icon "users"}}
- {{group.name}}
- </a>
- </div>
- {{/each}}
-</div>
\ No newline at end of file
diff --git a/app/assets/javascripts/discourse/app/raw-templates/list/post-count-or-badges.hbr b/app/assets/javascripts/discourse/app/raw-templates/list/post-count-or-badges.hbr
deleted file mode 100644
index 4c8a662ca2b..00000000000
--- a/app/assets/javascripts/discourse/app/raw-templates/list/post-count-or-badges.hbr
+++ /dev/null
@@ -1,5 +0,0 @@
-{{#if view.showBadges}}
- {{raw "topic-post-badges" unreadPosts=topic.unread_posts unseen=topic.unseen url=topic.lastUnreadUrl newDotText=newDotText}}
-{{else}}
- {{raw "list/posts-count-column" topic=topic tagName="div"}}
-{{/if}}
diff --git a/app/assets/javascripts/discourse/app/raw-templates/list/posters-column.hbr b/app/assets/javascripts/discourse/app/raw-templates/list/posters-column.hbr
deleted file mode 100644
index 51c470733f2..00000000000
--- a/app/assets/javascripts/discourse/app/raw-templates/list/posters-column.hbr
+++ /dev/null
@@ -1,9 +0,0 @@
-<td class='posters topic-list-data'>
-{{#each posters as |poster|}}
- {{#if poster.moreCount}}
- <a class="posters-more-count">{{poster.moreCount}}</a>
- {{else}}
- <a href="{{poster.user.path}}" data-user-card="{{poster.user.username}}" class="{{poster.extraClasses}}" aria-label="{{i18n "user.profile_possessive" username=poster.user.username}}">{{avatar poster avatarTemplatePath="user.avatar_template" usernamePath="user.username" namePath="user.name" imageSize="small"}}</a>
- {{/if}}
-{{/each}}
-</td>
diff --git a/app/assets/javascripts/discourse/app/raw-templates/list/posts-count-column.hbr b/app/assets/javascripts/discourse/app/raw-templates/list/posts-count-column.hbr
deleted file mode 100644
index 28a7f200960..00000000000
--- a/app/assets/javascripts/discourse/app/raw-templates/list/posts-count-column.hbr
+++ /dev/null
@@ -1,7 +0,0 @@
-<{{view.tagName}} class='num posts-map posts {{view.likesHeat}} topic-list-data'>
- <button class="btn-link posts-map badge-posts {{view.likesHeat}}" title="{{view.title}}" aria-label="{{view.title}}">
- {{raw-plugin-outlet name="topic-list-before-reply-count"}}
- {{plugin-outlet name="topic-list-before-reply-count" outletArgs=(raw-hash topic=topic)}}
- {{number topic.replyCount noTitle="true"}}
- </button>
-</{{view.tagName}}>
diff --git a/app/assets/javascripts/discourse/app/raw-templates/list/topic-excerpt.hbr b/app/assets/javascripts/discourse/app/raw-templates/list/topic-excerpt.hbr
deleted file mode 100644
index 9cc03e94047..00000000000
--- a/app/assets/javascripts/discourse/app/raw-templates/list/topic-excerpt.hbr
+++ /dev/null
@@ -1,8 +0,0 @@
-{{#if topic.hasExcerpt}}
- <a href="{{topic.url}}" class="topic-excerpt">
- {{dir-span topic.escapedExcerpt htmlSafe="true"}}
- {{#if topic.excerptTruncated}}
- <span class="topic-excerpt-more">{{i18n 'read_more'}}</span>
- {{/if}}
- </a>
-{{/if}}
diff --git a/app/assets/javascripts/discourse/app/raw-templates/list/topic-list-item.hbr b/app/assets/javascripts/discourse/app/raw-templates/list/topic-list-item.hbr
deleted file mode 100644
index fc86f729043..00000000000
--- a/app/assets/javascripts/discourse/app/raw-templates/list/topic-list-item.hbr
+++ /dev/null
@@ -1,97 +0,0 @@
-{{~raw-plugin-outlet name="topic-list-before-columns"}}
-
-{{#if bulkSelectEnabled}}
- <td class="bulk-select topic-list-data">
- <label for="bulk-select-{{topic.id}}">
- <input type="checkbox" class="bulk-select" id="bulk-select-{{topic.id}}">
- </label>
- </td>
-{{/if}}
-
-{{!--
- The `~` syntax strip spaces between the elements, making it produce
- `<a class=topic-post-badges>Some text</a><span class=topic-post-badges>`,
- with no space between them.
- This causes the topic-post-badge to be considered the same word as "text"
- at the end of the link, preventing it from line wrapping onto its own line.
---}}
-<td class='main-link clearfix topic-list-data' colspan="1">
- {{~raw-plugin-outlet name="topic-list-before-link"}}
- {{~plugin-outlet name="topic-list-before-link" outletArgs=(raw-hash topic=topic)}}
- <span class="link-top-line" role="heading" aria-level="2">
- {{~raw-plugin-outlet name="topic-list-before-status"}}
- {{~plugin-outlet name="topic-list-before-status" outletArgs=(raw-hash topic=topic)}}
- {{~raw "topic-status" topic=topic}}
- {{~topic-link topic class="raw-link raw-topic-link"}}
- {{~#if topic.featured_link}}
- &nbsp;{{~topic-featured-link topic}}
- {{~/if}}
- {{~raw-plugin-outlet name="topic-list-after-title"}}
- {{~plugin-outlet name="topic-list-after-title" outletArgs=(raw-hash topic=topic)}}
- {{~raw "list/unread-indicator" includeUnreadIndicator=includeUnreadIndicator
- topicId=topic.id
- unreadClass=unreadClass~}}
- {{~#if showTopicPostBadges}}
- {{~raw "topic-post-badges" unreadPosts=topic.unread_posts unseen=topic.unseen url=topic.lastUnreadUrl newDotText=newDotText}}
- {{~/if}}
- </span>
- <div class="link-bottom-line">
- {{#unless hideCategory}}
- {{#unless topic.isPinnedUncategorized}}
- {{~raw-plugin-outlet name="topic-list-before-category"}}
- {{~plugin-outlet name="topic-list-before-category" outletArgs=(raw-hash topic=topic)}}
- {{category-link topic.category}}
- {{/unless}}
- {{/unless}}
- {{discourse-tags topic mode="list" tagsForUser=tagsForUser}}
- {{#if participantGroups}}
- {{raw "list/participant-groups" groups=participantGroups}}
- {{/if}}
- {{raw "list/action-list" topic=topic postNumbers=topic.liked_post_numbers className="likes" icon="heart"}}
- </div>
- {{#if expandPinned}}
- {{raw "list/topic-excerpt" topic=topic}}
- {{/if}}
-
- {{~raw-plugin-outlet name="topic-list-main-link-bottom"}}
- {{~plugin-outlet name="topic-list-main-link-bottom" outletArgs=(raw-hash topic=topic)}}
-</td>
-
-{{~raw-plugin-outlet name="topic-list-after-main-link"}}
-{{~plugin-outlet name="topic-list-after-main-link" outletArgs=(raw-hash topic=topic)}}
-
-{{#if showPosters}}
- {{raw "list/posters-column" posters=topic.featuredUsers}}
-{{/if}}
-
-{{raw "list/posts-count-column" topic=topic}}
-
-{{#if showLikes}}
- <td class="num likes topic-list-data">
- {{#if hasLikes}}
- <a href='{{topic.summaryUrl}}'>
- {{number topic.like_count}} {{d-icon "heart"}}
- </a>
- {{/if}}
- </td>
-{{/if}}
-
-{{#if showOpLikes}}
- <td class="num likes">
- {{#if hasOpLikes}}
- <a href='{{topic.summaryUrl}}'>
- {{number topic.op_like_count}} {{d-icon "heart"}}
- </a>
- {{/if}}
- </td>
-{{/if}}
-
-<td class="num views {{topic.viewsHeat}} topic-list-data">
- {{raw-plugin-outlet name="topic-list-before-view-count"}}
- {{plugin-outlet name="topic-list-before-view-count" outletArgs=(raw-hash topic=topic)}}
- {{number topic.views numberKey="views_long"}}
-</td>
-
-{{raw "list/activity-column" topic=topic class="num topic-list-data" tagName="td"}}
-
-{{~raw-plugin-outlet name="topic-list-after-columns"}}
diff --git a/app/assets/javascripts/discourse/app/raw-templates/list/unread-indicator.hbr b/app/assets/javascripts/discourse/app/raw-templates/list/unread-indicator.hbr
deleted file mode 100644
index d951dd486bb..00000000000
--- a/app/assets/javascripts/discourse/app/raw-templates/list/unread-indicator.hbr
+++ /dev/null
@@ -1,5 +0,0 @@
-{{~#if includeUnreadIndicator~}}
- &nbsp;<span class='badge badge-notification unread-indicator indicator-topic-{{topicId}} {{unreadClass}}' title='{{i18n "topic.unread_indicator"}}'>
- {{~d-icon "asterisk"}}
- </span>
-{{~/if}}
diff --git a/app/assets/javascripts/discourse/app/raw-templates/list/visited-line.hbr b/app/assets/javascripts/discourse/app/raw-templates/list/visited-line.hbr
deleted file mode 100644
index 31b08654dc7..00000000000
--- a/app/assets/javascripts/discourse/app/raw-templates/list/visited-line.hbr
+++ /dev/null
@@ -1,9 +0,0 @@
-{{#if view.isLastVisited}}
- <tr class='topic-list-item-separator'>
- <td class="topic-list-data" colspan="6">
- <span>
- {{i18n 'topics.new_messages_marker'}}
- </span>
- </td>
- </tr>
-{{/if}}
diff --git a/app/assets/javascripts/discourse/app/raw-templates/mobile/list/topic-list-item.hbr b/app/assets/javascripts/discourse/app/raw-templates/mobile/list/topic-list-item.hbr
deleted file mode 100644
index a6410abb064..00000000000
--- a/app/assets/javascripts/discourse/app/raw-templates/mobile/list/topic-list-item.hbr
+++ /dev/null
@@ -1,63 +0,0 @@
-<td class="topic-list-data">
- {{~raw-plugin-outlet name="topic-list-before-columns"}}
- <div class='pull-left'>
- {{#if bulkSelectEnabled}}
- <label for="bulk-select-{{topic.id}}">
- <input type="checkbox" class="bulk-select" id="bulk-select-{{topic.id}}">
- </label>
- {{else}}
- <a href="{{topic.lastPostUrl}}" aria-label="{{i18n 'latest_poster_link' username=topic.lastPosterUser.username}}" data-user-card="{{topic.lastPosterUser.username}}">{{avatar topic.lastPosterUser imageSize="large"}}</a>
- {{/if}}
- </div>
- <div class='topic-item-metadata right'>
- {{!--
- The `~` syntax strip spaces between the elements, making it produce
- `<a class=topic-post-badges>Some text</a><span class=topic-post-badges>`,
- with no space between them.
- This causes the topic-post-badge to be considered the same word as "text"
- at the end of the link, preventing it from line wrapping onto its own line.
- --}}
- {{~raw-plugin-outlet name="topic-list-before-link"}}
- {{~plugin-outlet name="topic-list-before-link" outletArgs=(raw-hash topic=topic)}}
- <div class='main-link'>
- {{~raw-plugin-outlet name="topic-list-before-status"}}
- {{~plugin-outlet name="topic-list-before-status" outletArgs=(raw-hash topic=topic)}}
- {{~raw "topic-status" topic=topic~}}
- {{~topic-link topic class="raw-link raw-topic-link"}}
- {{~#if topic.featured_link~}}
- &nbsp;{{~topic-featured-link topic~}}
- {{~/if~}}
- {{~raw-plugin-outlet name="topic-list-after-title"}}
- {{~plugin-outlet name="topic-list-after-title" outletArgs=(raw-hash topic=topic)}}
- {{~#if topic.unseen~}}
- <span class="topic-post-badges">&nbsp;<span class="badge-notification new-topic"></span></span>
- {{~/if~}}
- {{~#if expandPinned~}}
- {{~raw "list/topic-excerpt" topic=topic~}}
- {{~/if~}}
- {{~raw-plugin-outlet name="topic-list-main-link-bottom"}}
- {{~plugin-outlet name="topic-list-main-link-bottom" outletArgs=(raw-hash topic=topic)}}
- </div>
- {{~raw-plugin-outlet name="topic-list-after-main-link"}}
- {{~plugin-outlet name="topic-list-after-main-link" outletArgs=(raw-hash topic=topic)}}
- <div class='pull-right'>
- {{raw "list/post-count-or-badges" topic=topic postBadgesEnabled=showTopicPostBadges}}
- </div>
- <div class="topic-item-stats clearfix">
- <span class="topic-item-stats__category-tags">
- {{#unless hideCategory}}
- {{~raw-plugin-outlet name="topic-list-before-category"}}
- {{~plugin-outlet name="topic-list-before-category" outletArgs=(raw-hash topic=topic)}}
- {{category-link topic.category~}}
- {{~/unless}}
- {{~discourse-tags topic mode="list"}}
- </span>
- <div class='num activity last'>
- <span class="age activity" title="{{topic.bumpedAtTitle}}"><a
- href="{{topic.lastPostUrl}}">{{format-date topic.bumpedAt format="tiny" noTitle="true"}}</a>
- </span>
- </div>
- {{~plugin-outlet name="topic-list-after-topic-item-stats" outletArgs=(raw-hash topic=topic)}}
- </div>
- {{~raw-plugin-outlet name="topic-list-after-columns"}}
-</td>
diff --git a/app/assets/javascripts/discourse/app/raw-templates/topic-bulk-select-dropdown.hbr b/app/assets/javascripts/discourse/app/raw-templates/topic-bulk-select-dropdown.hbr
deleted file mode 100644
index 82b20e114f7..00000000000
--- a/app/assets/javascripts/discourse/app/raw-templates/topic-bulk-select-dropdown.hbr
+++ /dev/null
@@ -1 +0,0 @@
-{{{view.html}}}
\ No newline at end of file
diff --git a/app/assets/javascripts/discourse/app/raw-templates/topic-list-header-column.hbr b/app/assets/javascripts/discourse/app/raw-templates/topic-list-header-column.hbr
deleted file mode 100644
index 3dc942f46fd..00000000000
--- a/app/assets/javascripts/discourse/app/raw-templates/topic-list-header-column.hbr
+++ /dev/null
@@ -1,35 +0,0 @@
-<th data-sort-order='{{order}}' class='{{view.className}} topic-list-data' scope="col" {{#if view.ariaSort}}aria-sort='{{view.ariaSort}}'{{/if}}>
- {{~#if canBulkSelect}}
- {{~#if showBulkToggle}}
- {{raw "flat-button" class="bulk-select" icon="list-check" title="topics.bulk.toggle"}}
- {{/if ~}}
- {{~#if bulkSelectEnabled}}
- <span class='bulk-select-topics'>
- {{~#if canDoBulkActions}}
- {{raw "topic-bulk-select-dropdown" bulkSelectHelper=bulkSelectHelper}}
- {{/if ~}}
- <button class='btn btn-default bulk-select-all'>{{i18n "topics.bulk.select_all"}}</button>
- <button class='btn btn-default bulk-clear-all'>{{i18n "topics.bulk.clear_all"}}</button>
- </span>
- {{/if ~}}
- {{/if ~}}
- {{~#unless bulkSelectEnabled}}
- {{~#if view.showTopicsAndRepliesToggle}}
- {{raw "list/new-list-header-controls" current=newListSubset newRepliesCount=newRepliesCount newTopicsCount=newTopicsCount}}
- {{else}}
- {{#if sortable}}
- <button aria-pressed='{{view.ariaPressed}}'>
- {{view.localizedName}}
- {{~#if view.isSorting}}
- {{d-icon view.sortIcon}}
- {{/if ~}}
- </button>
- {{else}}
- <span {{#if view.screenreaderOnly}}class="sr-only"{{/if}}>
- {{view.localizedName}}
- </span>
- {{/if}}
- {{/if ~}}
- {{/unless ~}}
- {{~plugin-outlet name="topic-list-heading-bottom" outletArgs=(raw-hash name=view.name bulkSelectEnabled=bulkSelectEnabled)~}}
-</th>
diff --git a/app/assets/javascripts/discourse/app/raw-templates/topic-list-header.hbr b/app/assets/javascripts/discourse/app/raw-templates/topic-list-header.hbr
deleted file mode 100644
index bd61b8a9625..00000000000
--- a/app/assets/javascripts/discourse/app/raw-templates/topic-list-header.hbr
+++ /dev/null
@@ -1,26 +0,0 @@
-{{~raw-plugin-outlet name="topic-list-header-before"~}}
-{{~plugin-outlet name="topic-list-header-before"~}}
-{{#if bulkSelectEnabled}}
- <th class="bulk-select topic-list-data">
- {{#if canBulkSelect}}
- {{raw "flat-button" class="bulk-select" icon="list-check" title="topics.bulk.toggle"}}
- {{/if}}
- </th>
-{{/if}}
-{{raw "topic-list-header-column" order='default' name=listTitle bulkSelectEnabled=bulkSelectEnabled showBulkToggle=toggleInTitle canBulkSelect=canBulkSelect canDoBulkActions=canDoBulkActions showTopicsAndRepliesToggle=showTopicsAndRepliesToggle newListSubset=newListSubset newRepliesCount=newRepliesCount newTopicsCount=newTopicsCount bulkSelectHelper=bulkSelectHelper }}
-{{raw-plugin-outlet name="topic-list-header-after-main-link"}}
-{{plugin-outlet name="topic-list-header-after-main-link"}}
-{{#if showPosters}}
- {{raw "topic-list-header-column" order='posters' name='posters' screenreaderOnly='true'}}
-{{/if}}
-{{raw "topic-list-header-column" sortable=sortable number='true' order='posts' name='replies'}}
-{{#if showLikes}}
- {{raw "topic-list-header-column" sortable=sortable number='true' order='likes' name='likes'}}
-{{/if}}
-{{#if showOpLikes}}
- {{raw "topic-list-header-column" sortable=sortable number='true' order='op_likes' name='likes'}}
-{{/if}}
-{{raw "topic-list-header-column" sortable=sortable number='true' order='views' name='views'}}
-{{raw "topic-list-header-column" sortable=sortable number='true' order='activity' name='activity'}}
-{{~raw-plugin-outlet name="topic-list-header-after"~}}
-{{~plugin-outlet name="topic-list-header-after"~}}
\ No newline at end of file
diff --git a/app/assets/javascripts/discourse/app/raw-templates/topic-post-badges.hbr b/app/assets/javascripts/discourse/app/raw-templates/topic-post-badges.hbr
deleted file mode 100644
index 81017949a6c..00000000000
--- a/app/assets/javascripts/discourse/app/raw-templates/topic-post-badges.hbr
+++ /dev/null
@@ -1,26 +0,0 @@
-<span class="topic-post-badges">
- {{~#if newPosts~}}
- &nbsp;<a
- href="{{url}}"
- class="badge badge-notification unread-posts"
- title="{{i18n 'topic.unread_posts' count=newPosts}}"
- aria-label="{{i18n 'topic.unread_posts' count=newPosts}}"
- >{{newPosts}}</a>
- {{~/if}}
- {{~#if unreadPosts~}}
- &nbsp;<a
- href="{{url}}"
- class="badge badge-notification unread-posts"
- title="{{i18n 'topic.unread_posts' count=unreadPosts}}"
- aria-label="{{i18n 'topic.unread_posts' count=unreadPosts}}"
- >{{unreadPosts}}</a>
- {{~/if}}
- {{~#if unseen~}}
- &nbsp;<a
- href="{{url}}"
- class="badge badge-notification new-topic"
- title="{{i18n 'topic.new'}}"
- aria-label="{{i18n 'topic.new'}}"
- >{{newDotText}}</a>
- {{~/if}}
-</span>
diff --git a/app/assets/javascripts/discourse/app/raw-templates/topic-status.hbr b/app/assets/javascripts/discourse/app/raw-templates/topic-status.hbr
deleted file mode 100644
index 9dd8ee5a9bc..00000000000
--- a/app/assets/javascripts/discourse/app/raw-templates/topic-status.hbr
+++ /dev/null
@@ -1,14 +0,0 @@
-{{~#if view.renderDiv ~}}
-<div class='topic-statuses'>
-{{/if ~}}
-{{~#each view.statuses as |status|~}}
-{{~#if status.href ~}}
-<a href='{{status.href}}' title='{{status.title}}' class='topic-status {{status.extraClasses}}'>{{d-icon status.icon}}</a>
-{{~else ~}}
-<{{status.openTag}} title='{{status.title}}' class='topic-status'>{{d-icon status.icon class=status.key}}</{{status.closeTag}}>
-{{~/if ~}}
-{{~/each}}
-{{~#if view.showDefault~}}{{d-icon view.showDefault}}{{~/if ~}}
-{{~#if view.renderDiv ~}}
-</div>
-{{/if ~}}
diff --git a/app/assets/javascripts/discourse/app/raw-views/list/new-list-header-controls.js b/app/assets/javascripts/discourse/app/raw-views/list/new-list-header-controls.js
deleted file mode 100644
index 8767cf4b5b5..00000000000
--- a/app/assets/javascripts/discourse/app/raw-views/list/new-list-header-controls.js
+++ /dev/null
@@ -1,57 +0,0 @@
-import EmberObject from "@ember/object";
-import discourseComputed from "discourse/lib/decorators";
-import { i18n } from "discourse-i18n";
-
-export default class NewListHeaderControls extends EmberObject {
- @discourseComputed
- topicsActive() {
- return this.current === "topics";
- }
-
- @discourseComputed
- repliesActive() {
- return this.current === "replies";
- }
-
- @discourseComputed
- allActive() {
- return !this.topicsActive && !this.repliesActive;
- }
-
- @discourseComputed
- repliesButtonLabel() {
- if (this.newRepliesCount > 0) {
- return i18n("filters.new.replies_with_count", {
- count: this.newRepliesCount,
- });
- } else {
- return i18n("filters.new.replies");
- }
- }
-
- @discourseComputed
- topicsButtonLabel() {
- if (this.newTopicsCount > 0) {
- return i18n("filters.new.topics_with_count", {
- count: this.newTopicsCount,
- });
- } else {
- return i18n("filters.new.topics");
- }
- }
-
- @discourseComputed
- staticLabel() {
- if (this.noStaticLabel) {
- return null;
- }
- if (this.newTopicsCount > 0 && this.newRepliesCount > 0) {
- return null;
- }
- if (this.newTopicsCount > 0) {
- return this.topicsButtonLabel;
- } else {
- return this.repliesButtonLabel;
- }
- }
-}
diff --git a/app/assets/javascripts/discourse/app/raw-views/list/post-count-or-badges.js b/app/assets/javascripts/discourse/app/raw-views/list/post-count-or-badges.js
deleted file mode 100644
index 3c50a8fe1c1..00000000000
--- a/app/assets/javascripts/discourse/app/raw-views/list/post-count-or-badges.js
+++ /dev/null
@@ -1,15 +0,0 @@
-import EmberObject from "@ember/object";
-import { and } from "@ember/object/computed";
-import discourseComputed from "discourse/lib/decorators";
-import { i18n } from "discourse-i18n";
-
-export default class PostCountOrBadges extends EmberObject {
- @and("postBadgesEnabled", "topic.unread_posts") showBadges;
-
- @discourseComputed
- newDotText() {
- return this.currentUser && this.currentUser.trust_level > 0
- ? ""
- : i18n("filters.new.lower_title");
- }
-}
diff --git a/app/assets/javascripts/discourse/app/raw-views/list/posts-count-column.js b/app/assets/javascripts/discourse/app/raw-views/list/posts-count-column.js
deleted file mode 100644
index be17e6e331a..00000000000
--- a/app/assets/javascripts/discourse/app/raw-views/list/posts-count-column.js
+++ /dev/null
@@ -1,49 +0,0 @@
-import EmberObject from "@ember/object";
-import discourseComputed from "discourse/lib/decorators";
-import I18n from "discourse-i18n";
-
-export default class PostsCountColumn extends EmberObject {
- tagName = "td";
-
- @discourseComputed("topic.like_count", "topic.posts_count")
- ratio(likeCount, postCount) {
- const likes = parseFloat(likeCount);
- const posts = parseFloat(postCount);
-
- if (posts < 10) {
- return 0;
- }
-
- return (likes || 0) / posts;
- }
-
- @discourseComputed("topic.replyCount", "ratioText")
- title(count, ratio) {
- return I18n.messageFormat("posts_likes_MF", {
- count,
- ratio,
- });
- }
-
- @discourseComputed("ratio")
- ratioText(ratio) {
- const settings = this.siteSettings;
- if (ratio > settings.topic_post_like_heat_high) {
- return "high";
- }
- if (ratio > settings.topic_post_like_heat_medium) {
- return "med";
- }
- if (ratio > settings.topic_post_like_heat_low) {
- return "low";
- }
- return "";
- }
-
- @discourseComputed("ratioText")
- likesHeat(ratioText) {
- if (ratioText && ratioText.length) {
- return `heatmap-${ratioText}`;
- }
- }
-}
diff --git a/app/assets/javascripts/discourse/app/raw-views/list/visited-line.js b/app/assets/javascripts/discourse/app/raw-views/list/visited-line.js
deleted file mode 100644
index 7d576bd1dd0..00000000000
--- a/app/assets/javascripts/discourse/app/raw-views/list/visited-line.js
+++ /dev/null
@@ -1,9 +0,0 @@
-import EmberObject from "@ember/object";
-import discourseComputed from "discourse/lib/decorators";
-
-export default class VisitedLine extends EmberObject {
- @discourseComputed
- isLastVisited() {
- return this.lastVisitedTopic === this.topic;
- }
-}
diff --git a/app/assets/javascripts/discourse/app/raw-views/topic-bulk-select-dropdown.gjs b/app/assets/javascripts/discourse/app/raw-views/topic-bulk-select-dropdown.gjs
deleted file mode 100644
index 3e1db81f25e..00000000000
--- a/app/assets/javascripts/discourse/app/raw-views/topic-bulk-select-dropdown.gjs
+++ /dev/null
@@ -1,41 +0,0 @@
-import EmberObject, { action } from "@ember/object";
-import { service } from "@ember/service";
-import BulkSelectTopicsDropdown from "discourse/components/bulk-select-topics-dropdown";
-import rawRenderGlimmer from "discourse/lib/raw-render-glimmer";
-import { i18n } from "discourse-i18n";
-
-const BulkSelectGlimmerWrapper = <template>
- <span class="bulk-select-topic-dropdown__count">
- {{i18n "topics.bulk.selected_count" [email protected]}}
- </span>
- <BulkSelectTopicsDropdown
- @bulkSelectHelper={{@data.bulkSelectHelper}}
- @afterBulkActionComplete={{@data.afterBulkAction}}
- />
-</template>;
-
-export default class extends EmberObject {
- @service router;
-
- get selectedCount() {
- return this.bulkSelectHelper.selected.length;
- }
-
- @action
- afterBulkAction() {
- return this.router.refresh();
- }
-
- get html() {
- return rawRenderGlimmer(
- this,
- "div.bulk-select-topics-dropdown",
- BulkSelectGlimmerWrapper,
- {
- bulkSelectHelper: this.bulkSelectHelper,
- selectedCount: this.selectedCount,
- afterBulkAction: this.afterBulkAction,
- }
- );
- }
-}
diff --git a/app/assets/javascripts/discourse/app/raw-views/topic-list-header-column.js b/app/assets/javascripts/discourse/app/raw-views/topic-list-header-column.js
deleted file mode 100644
index 2a85d61ca9a..00000000000
--- a/app/assets/javascripts/discourse/app/raw-views/topic-list-header-column.js
+++ /dev/null
@@ -1,72 +0,0 @@
-import EmberObject from "@ember/object";
-import { and } from "@ember/object/computed";
-import discourseComputed from "discourse/lib/decorators";
-import { i18n } from "discourse-i18n";
-
-export default class TopicListHeaderColumn extends EmberObject {
- sortable = null;
-
- @and("sortable", "isSorting") ariaPressed;
-
- @discourseComputed
- localizedName() {
- if (this.forceName) {
- return this.forceName;
- }
-
- return this.name ? i18n(this.name) : "";
- }
-
- @discourseComputed
- sortIcon() {
- const isAscending =
- (
- this.parent.ascending ||
- this.parent.context?.ascending ||
- ""
- ).toString() === "true";
-
- return `chevron-${isAscending ? "up" : "down"}`;
- }
-
- @discourseComputed
- isSorting() {
- return (
- this.sortable &&
- (this.parent.order === this.order ||
- this.parent.context?.order === this.order)
- );
- }
-
- @discourseComputed
- className() {
- const name = [];
-
- if (this.order) {
- name.push(this.order);
- }
-
- if (this.sortable) {
- name.push("sortable");
-
- if (this.isSorting) {
- name.push("sorting");
- }
- }
-
- if (this.number) {
- name.push("num");
- }
-
- return name.join(" ");
- }
-
- @discourseComputed
- ariaSort() {
- if (this.isSorting) {
- return this.parent.ascending ? "ascending" : "descending";
- } else {
- return false;
- }
- }
-}
diff --git a/app/assets/javascripts/discourse/app/raw-views/topic-status.js b/app/assets/javascripts/discourse/app/raw-views/topic-status.js
deleted file mode 100644
index 05e04c7d5b3..00000000000
--- a/app/assets/javascripts/discourse/app/raw-views/topic-status.js
+++ /dev/null
@@ -1,119 +0,0 @@
-import EmberObject from "@ember/object";
-import discourseComputed from "discourse/lib/decorators";
-import deprecated from "discourse/lib/deprecated";
-import { RAW_TOPIC_LIST_DEPRECATION_OPTIONS } from "discourse/lib/plugin-api";
-import { i18n } from "discourse-i18n";
-
-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.",
- RAW_TOPIC_LIST_DEPRECATION_OPTIONS
- );
-
- return super.reopen(...arguments);
- }
-
- 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.",
- RAW_TOPIC_LIST_DEPRECATION_OPTIONS
- );
-
- return super.reopenClass(...arguments);
- }
-
- showDefault = null;
-
- @discourseComputed("defaultIcon")
- renderDiv(defaultIcon) {
- return (defaultIcon || this.statuses.length > 0) && !this.noDiv;
- }
-
- @discourseComputed
- statuses() {
- const topic = this.topic;
- const results = [];
-
- // TODO, custom statuses? via override?
- if (topic.is_warning) {
- results.push({ icon: "envelope", key: "warning" });
- }
-
- if (topic.bookmarked) {
- const postNumbers = topic.bookmarked_post_numbers;
- let url = topic.url;
- let extraClasses = "";
- if (postNumbers && postNumbers[0] > 1) {
- url += "/" + postNumbers[0];
- } else {
- extraClasses = "op-bookmark";
- }
-
- results.push({
- extraClasses,
- icon: "bookmark",
- key: "bookmarked",
- href: url,
- });
- }
-
- if (topic.closed && topic.archived) {
- results.push({ icon: "lock", key: "locked_and_archived" });
- } else if (topic.closed) {
- results.push({ icon: "lock", key: "locked" });
- } else if (topic.archived) {
- results.push({ icon: "lock", key: "archived" });
- }
-
- if (topic.pinned) {
- results.push({ icon: "thumbtack", key: "pinned" });
- }
-
- if (topic.unpinned) {
- results.push({ icon: "thumbtack", key: "unpinned" });
- }
-
- if (topic.invisible) {
- results.push({ icon: "far-eye-slash", key: "unlisted" });
- }
-
- if (
- this.showPrivateMessageIcon &&
- topic.isPrivateMessage &&
- !topic.is_warning
- ) {
- results.push({ icon: "envelope", key: "personal_message" });
- }
-
- results.forEach((result) => {
- const translationParams = {};
-
- if (result.key === "unlisted") {
- translationParams.unlistedReason = topic.visibilityReasonTranslated;
- }
-
- result.title = i18n(
- `topic_statuses.${result.key}.help`,
- translationParams
- );
-
- if (
- this.currentUser &&
- (result.key === "pinned" || result.key === "unpinned")
- ) {
- result.openTag = "a href";
- result.closeTag = "a";
- } else {
- result.openTag = "span";
- result.closeTag = "span";
- }
- });
-
- let defaultIcon = this.defaultIcon;
- if (results.length === 0 && defaultIcon) {
- this.set("showDefault", defaultIcon);
- }
- return results;
- }
-}
diff --git a/app/assets/javascripts/discourse/app/services/deprecation-warning-handler.js b/app/assets/javascripts/discourse/app/services/deprecation-warning-handler.js
index f6e81171f7d..70958520f6f 100644
--- a/app/assets/javascripts/discourse/app/services/deprecation-warning-handler.js
+++ b/app/assets/javascripts/discourse/app/services/deprecation-warning-handler.js
@@ -28,7 +28,6 @@ export const CRITICAL_DEPRECATIONS = [
"discourse.qunit.acceptance-function",
"discourse.qunit.global-exists",
"discourse.post-stream.trigger-new-post",
- "discourse.hbr-topic-list-overrides",
"discourse.mobile-templates",
"discourse.mobile-view",
"discourse.mobile-templates",
diff --git a/app/assets/javascripts/discourse/app/services/render-glimmer.js b/app/assets/javascripts/discourse/app/services/render-glimmer.js
deleted file mode 100644
index 6d296869576..00000000000
--- a/app/assets/javascripts/discourse/app/services/render-glimmer.js
+++ /dev/null
@@ -1,31 +0,0 @@
-import Service from "@ember/service";
-import { TrackedSet } from "@ember-compat/tracked-built-ins";
-
-/**
- * This service is responsible for rendering glimmer components into HTML generated
- * by raw-hbs. It is not intended to be used directly.
- *
- * See discourse/lib/raw-render-glimmer.js for usage instructions.
- */
-export default class RenderGlimmerService extends Service {
- _registrations = new TrackedSet();
-
- add(info) {
- this._registrations.add(info);
- }
-
- remove(info) {
- this._registrations.delete(info);
- }
-
- /**
- * Removes registrations for elements which are no longer in the DOM.
- */
- cleanup() {
- this._registrations.forEach((info) => {
- if (!document.body.contains(info.element)) {
- this.remove(info);
- }
- });
- }
-}
diff --git a/app/assets/javascripts/discourse/ember-cli-build.js b/app/assets/javascripts/discourse/ember-cli-build.js
index cb46afaa0e6..80d9b5d26ff 100644
--- a/app/assets/javascripts/discourse/ember-cli-build.js
+++ b/app/assets/javascripts/discourse/ember-cli-build.js
@@ -13,7 +13,6 @@ const { Webpack } = require("@embroider/webpack");
const { StatsWriterPlugin } = require("webpack-stats-plugin");
const { RetryChunkLoadPlugin } = require("webpack-retry-chunk-load-plugin");
const withSideWatch = require("./lib/with-side-watch");
-const RawHandlebarsCompiler = require("discourse-hbr/raw-handlebars-compiler");
const crypto = require("crypto");
const commonBabelConfig = require("./lib/common-babel-config");
const TerserPlugin = require("terser-webpack-plugin");
@@ -65,11 +64,9 @@ module.exports = function (defaults) {
...commonBabelConfig(),
trees: {
- app: RawHandlebarsCompiler(
- withSideWatch("app", {
- watching: ["../discourse-markdown-it", "../truth-helpers"],
- })
- ),
+ app: withSideWatch("app", {
+ watching: ["../discourse-markdown-it", "../truth-helpers"],
+ }),
},
});
diff --git a/app/assets/javascripts/discourse/package.json b/app/assets/javascripts/discourse/package.json
index 01ec89c027d..e1694a4b146 100644
--- a/app/assets/javascripts/discourse/package.json
+++ b/app/assets/javascripts/discourse/package.json
@@ -27,13 +27,11 @@
"@messageformat/runtime": "^3.0.1",
"ace-builds": "^1.39.1",
"decorator-transforms": "^2.3.0",
- "discourse-hbr": "workspace:1.0.0",
"discourse-widget-hbs": "workspace:1.0.0",
"ember-curry-component": "^0.3.0",
"ember-resolver": "^13.1.0",
"ember-route-template": "^1.0.3",
"ember-tracked-storage-polyfill": "^1.0.0",
- "handlebars": "^4.7.8",
"highlight.js": "11.11.1",
"immer": "^10.1.1",
"jspreadsheet-ce": "^4.15.0",
diff --git a/app/assets/javascripts/discourse/tests/acceptance/hbr-plugin-outlet-test.gjs b/app/assets/javascripts/discourse/tests/acceptance/hbr-plugin-outlet-test.gjs
deleted file mode 100644
index 472110f9f17..00000000000
--- a/app/assets/javascripts/discourse/tests/acceptance/hbr-plugin-outlet-test.gjs
+++ /dev/null
@@ -1,20 +0,0 @@
-import { visit } from "@ember/test-helpers";
-import { hbs } from "ember-cli-htmlbars";
-import { test } from "qunit";
-import { acceptance } from "discourse/tests/helpers/qunit-helpers";
-import { registerTemporaryModule } from "discourse/tests/helpers/temporary-module-helper";
-
-acceptance("Hbr Plugin Outlet", function (needs) {
- needs.hooks.beforeEach(function () {
- registerTemporaryModule(
- "discourse/theme-12/templates/connectors/topic-list-before-link/hello",
- hbs`<span class="lala">{{@outletArgs.topic.id}}</span>`
- );
- });
-
- test("renders ember plugin outlets in hbr contexts", async function (assert) {
- await visit("/");
- assert.dom(".lala").exists("renders the outlet");
- assert.dom(".lala").hasText("11557", "has the topic id");
- });
-});
diff --git a/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js b/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js
index 7f73e29a3d5..ebcaa91cfd4 100644
--- a/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js
+++ b/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js
@@ -61,7 +61,6 @@ import {
resetExtraClasses,
} from "discourse/lib/plugin-connectors";
import PreloadStore from "discourse/lib/preload-store";
-import { resetNeedsHbrTopicList } from "discourse/lib/raw-templates";
import { clearTopicFooterButtons } from "discourse/lib/register-topic-footer-button";
import { clearTopicFooterDropdowns } from "discourse/lib/register-topic-footer-dropdown";
import { clearTagsHtmlCallbacks } from "discourse/lib/render-tags";
@@ -268,7 +267,6 @@ export function testCleanup(container, app) {
resetWidgetCleanCallbacks();
clearPluginHeaderActionComponents();
clearRegisteredTabs();
- resetNeedsHbrTopicList();
clearAddedTrackedPostProperties();
resetGroupPostSmallActionCodes();
resetPostSmallActionClassesCallbacks();
diff --git a/app/assets/javascripts/discourse/tests/integration/components/topic-list-item-test.gjs b/app/assets/javascripts/discourse/tests/integration/components/topic-list-item-test.gjs
index d267a3134ec..89330570bc3 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/topic-list-item-test.gjs
+++ b/app/assets/javascripts/discourse/tests/integration/components/topic-list-item-test.gjs
@@ -1,8 +1,7 @@
import { render } from "@ember/test-helpers";
import { module, test } from "qunit";
-import TopicListItem from "discourse/components/topic-list/item";
import TopicList from "discourse/components/topic-list/list";
-import HbrTopicListItem from "discourse/components/topic-list-item";
+import BulkSelectHelper from "discourse/lib/bulk-select-helper";
import { withPluginApi } from "discourse/lib/plugin-api";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
@@ -11,21 +10,21 @@ module("Integration | Component | topic-list-item", function (hooks) {
test("checkbox is rendered checked if topic is in selected array", async function (assert) {
const store = this.owner.lookup("service:store");
- const topic = store.createRecord("topic", { id: 24234 });
- const topic2 = store.createRecord("topic", { id: 24235 });
- const selected = [topic];
+ const topics = [
+ store.createRecord("topic", { id: 24234 }),
+ store.createRecord("topic", { id: 24235 }),
+ ];
+
+ const bulkSelectHelper = new BulkSelectHelper(this);
+ bulkSelectHelper.toggleBulkSelect();
+ bulkSelectHelper.selected.push(topics[0]);
await render(
<template>
- <HbrTopicListItem
- @topic={{topic}}
- @bulkSelectEnabled={{true}}
- @selected={{selected}}
- />
- <HbrTopicListItem
- @topic={{topic2}}
- @bulkSelectEnabled={{true}}
- @selected={{selected}}
+ <TopicList
+ @topics={{topics}}
+ @bulkSelectHelper={{bulkSelectHelper}}
+ @canBulkSelect={{true}}
/>
</template>
);
@@ -49,14 +48,12 @@ module("Integration | Component | topic-list-item", function (hooks) {
});
const store = this.owner.lookup("service:store");
- const topic = store.createRecord("topic", { id: 1234, foo: true });
- const topic2 = store.createRecord("topic", { id: 1235, foo: false });
- await render(
- <template>
- <TopicListItem @topic={{topic}} />
- <TopicListItem @topic={{topic2}} />
- </template>
- );
+ const topics = [
+ store.createRecord("topic", { id: 1234, foo: true }),
+ store.createRecord("topic", { id: 1235, foo: false }),
+ ];
+
+ await render(<template><TopicList @topics={{topics}} /></template>);
assert.dom(".topic-list-item[data-topic-id='1234']").hasClass("bar");
assert
diff --git a/app/assets/javascripts/discourse/tests/integration/components/topic-list-test.gjs b/app/assets/javascripts/discourse/tests/integration/components/topic-list-test.gjs
index b1c704c197e..4e7d3dfb4f6 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/topic-list-test.gjs
+++ b/app/assets/javascripts/discourse/tests/integration/components/topic-list-test.gjs
@@ -1,7 +1,6 @@
import { getOwner } from "@ember/owner";
import { click, render } from "@ember/test-helpers";
import { module, test } from "qunit";
-import HbrTopicList from "discourse/components/topic-list";
import TopicList from "discourse/components/topic-list/list";
import BulkSelectHelper from "discourse/lib/bulk-select-helper";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
@@ -19,7 +18,7 @@ module("Integration | Component | topic-list", function (hooks) {
await render(
<template>
- <HbrTopicList
+ <TopicList
@canBulkSelect={{true}}
@bulkSelectHelper={{bulkSelectHelper}}
@topics={{topics}}
diff --git a/app/assets/javascripts/discourse/tests/integration/components/widgets/topic-status-test.gjs b/app/assets/javascripts/discourse/tests/integration/components/widgets/topic-status-test.gjs
index 41f73940df9..00eb8c90a2c 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/widgets/topic-status-test.gjs
+++ b/app/assets/javascripts/discourse/tests/integration/components/widgets/topic-status-test.gjs
@@ -2,8 +2,6 @@ import { getOwner } from "@ember/owner";
import { click, render } from "@ember/test-helpers";
import { module, test } from "qunit";
import MountWidget from "discourse/components/mount-widget";
-import TopicStatusIcons from "discourse/helpers/topic-status-icons";
-import { withSilencedDeprecations } from "discourse/lib/deprecated";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
module("Integration | Component | Widget | topic-status", function (hooks) {
@@ -23,29 +21,6 @@ module("Integration | Component | Widget | topic-status", function (hooks) {
assert.dom(".topic-status .d-icon-lock").exists();
});
- test("extendability", async function (assert) {
- this.siteSettings.glimmer_topic_list_mode = "disabled";
- withSilencedDeprecations("discourse.hbr-topic-list-overrides", () => {
- TopicStatusIcons.addObject([
- "has_accepted_answer",
- "far-square-check",
- "solved",
- ]);
- });
-
- const store = getOwner(this).lookup("service:store");
- const args = {
- topic: store.createRecord("topic", { has_accepted_answer: true }),
- disableActions: true,
- };
-
- await render(
- <template><MountWidget @widget="topic-status" @args={{args}} /></template>
- );
-
- assert.dom(".topic-status .d-icon-far-square-check").exists();
- });
-
test("toggling pin status", async function (assert) {
const store = getOwner(this).lookup("service:store");
const args = {
diff --git a/app/assets/javascripts/discourse/tests/integration/hbr-topic-list-detection-test.js b/app/assets/javascripts/discourse/tests/integration/hbr-topic-list-detection-test.js
deleted file mode 100644
index 655525bd12e..00000000000
--- a/app/assets/javascripts/discourse/tests/integration/hbr-topic-list-detection-test.js
+++ /dev/null
@@ -1,109 +0,0 @@
-import { module, test } from "qunit";
-import TopicList from "discourse/components/topic-list";
-import TopicListItem from "discourse/components/topic-list-item";
-import { withSilencedDeprecations } from "discourse/lib/deprecated";
-import { withPluginApi } from "discourse/lib/plugin-api";
-import { rawConnectorsFor } from "discourse/lib/plugin-connectors";
-import {
- addRawTemplate,
- needsHbrTopicList,
- removeRawTemplate,
-} from "discourse/lib/raw-templates";
-import {
- disableRaiseOnDeprecation,
- enableRaiseOnDeprecation,
-} from "discourse/tests/helpers/raise-on-deprecation";
-
-module("Integration | Lib | hbr topic list detection", function (hooks) {
- hooks.beforeEach(function () {
- disableRaiseOnDeprecation();
- });
-
- hooks.afterEach(function () {
- enableRaiseOnDeprecation();
- });
-
- test("template overrides", async function (assert) {
- try {
- addRawTemplate("flat-button", "non-topic list override");
- assert.false(needsHbrTopicList());
-
- addRawTemplate("list/topic-list-item", "topic list override");
- assert.true(needsHbrTopicList());
- } finally {
- removeRawTemplate("flat-button");
- removeRawTemplate("list/topic-list-item");
- }
- });
-
- test("hbr connectors", async function (assert) {
- assert.false(needsHbrTopicList());
-
- // all raw connectors are topic list connectors
- addRawTemplate(
- "javascripts/raw-test/connectors/topic-list-after-title/foo",
- "topic list connector"
- );
- assert.strictEqual(rawConnectorsFor("topic-list-after-title").length, 1);
- assert.true(needsHbrTopicList());
- });
-
- test("reopen", async function (assert) {
- withSilencedDeprecations("discourse.hbr-topic-list-overrides", () => {
- TopicList.reopen({});
- });
- assert.false(needsHbrTopicList());
-
- TopicList.reopen({});
- assert.true(needsHbrTopicList());
- });
-
- test("reopenClass", async function (assert) {
- withSilencedDeprecations("discourse.hbr-topic-list-overrides", () => {
- TopicListItem.reopenClass({});
- });
- assert.false(needsHbrTopicList());
-
- TopicListItem.reopenClass({});
- assert.true(needsHbrTopicList());
- });
-
- test("modifyClass", async function (assert) {
- withPluginApi("1.0.0", (api) => {
- api.modifyClass(
- "component:mobile-nav",
- (Superclass) => class extends Superclass {}
- );
- assert.false(needsHbrTopicList());
-
- withSilencedDeprecations("discourse.hbr-topic-list-overrides", () => {
- api.modifyClass(
- "component:topic-list-item",
- (Superclass) => class extends Superclass {}
- );
- });
- assert.false(needsHbrTopicList());
-
- api.modifyClass(
- "component:topic-list-item",
- (Superclass) => class extends Superclass {}
- );
- assert.true(needsHbrTopicList());
- });
- });
-
- test("modifyClassStatic", async function (assert) {
- withPluginApi("1.0.0", (api) => {
- api.modifyClassStatic("component:mobile-nav", { pluginId: "test" });
- assert.false(needsHbrTopicList());
-
- withSilencedDeprecations("discourse.hbr-topic-list-overrides", () => {
- api.modifyClassStatic("component:topic-list", { pluginId: "test" });
- });
- assert.false(needsHbrTopicList());
-
- api.modifyClassStatic("component:topic-list", { pluginId: "test" });
- assert.true(needsHbrTopicList());
- });
- });
-});
diff --git a/app/assets/javascripts/discourse/tests/integration/helpers/raw-test.gjs b/app/assets/javascripts/discourse/tests/integration/helpers/raw-test.gjs
deleted file mode 100644
index 828eff9280e..00000000000
--- a/app/assets/javascripts/discourse/tests/integration/helpers/raw-test.gjs
+++ /dev/null
@@ -1,150 +0,0 @@
-import Component from "@glimmer/component";
-import { tracked } from "@glimmer/tracking";
-import { getOwner } from "@ember/owner";
-import { render, settled } from "@ember/test-helpers";
-import { module, test } from "qunit";
-import RenderGlimmerContainer from "discourse/components/render-glimmer-container";
-import raw from "discourse/helpers/raw";
-import { compile } from "discourse/lib/raw-handlebars";
-import { RUNTIME_OPTIONS } from "discourse/lib/raw-handlebars-helpers";
-import rawRenderGlimmer from "discourse/lib/raw-render-glimmer";
-import { addRawTemplate, removeRawTemplate } from "discourse/lib/raw-templates";
-import { setupRenderingTest } from "discourse/tests/helpers/component-test";
-
-// We don't have any way to actually compile raw hbs inside tests, so this is only testing
-// the helper itself, not the actual rendering of templates.
-module("Integration | Helper | raw", function (hooks) {
- setupRenderingTest(hooks);
-
- hooks.afterEach(() => {
- removeRawTemplate("raw-test");
- });
-
- test("can render a template", async function (assert) {
- addRawTemplate("raw-test", (params) => `raw test ${params.someArg}`);
-
- await render(
- <template>
- <span>{{raw "raw-test" someArg="foo"}}</span>
- </template>
- );
-
- assert.dom(`span`).hasText("raw test foo");
- });
-
- test("can render glimmer inside", async function (assert) {
- let willDestroyCalled = false;
-
- class MyComponent extends Component {
- <template>Hello from glimmer {{@data.someArg}}</template>
-
- willDestroy() {
- super.willDestroy(...arguments);
- willDestroyCalled = true;
- }
- }
-
- addRawTemplate("raw-test", (params) =>
- rawRenderGlimmer(this, "div", MyComponent, { someArg: params.someArg })
- );
-
- class TestState {
- @tracked showRawTemplate = true;
- }
-
- const testState = new TestState();
-
- const renderGlimmerService = getOwner(this).lookup(
- "service:render-glimmer"
- );
-
- await render(
- <template>
- {{! RenderGlimmerContainer is normally rendered by application.hbs
- but this is not an acceptance test so we gotta include it manually }}
- <RenderGlimmerContainer />
- <span>
- {{#if testState.showRawTemplate}}
- {{raw "raw-test" someArg="foo"}}
- {{/if}}
- </span>
- </template>
- );
-
- assert.dom(`span`).hasText("Hello from glimmer foo");
- assert.strictEqual(
- renderGlimmerService._registrations.size,
- 1,
- "renderGlimmer service has one registration"
- );
-
- testState.showRawTemplate = false;
- await settled();
-
- assert.dom(`span`).hasText("");
- assert.strictEqual(
- renderGlimmerService._registrations.size,
- 0,
- "renderGlimmer service has no registrations"
- );
-
- assert.true(willDestroyCalled, "component was cleaned up correctly");
- });
-
- test("does not add extra whitespace", async function (assert) {
- const SimpleTemplate = <template>baz</template>;
-
- addRawTemplate("raw-test", () =>
- rawRenderGlimmer(this, "span.bar", SimpleTemplate)
- );
-
- await render(
- <template>
- <RenderGlimmerContainer />
- {{raw "raw-test"}}
- </template>
- );
-
- assert.dom("span.bar").hasText(/^baz$/);
- });
-
- test("#each helper preserves the outer context", async function (assert) {
- const template = `
- {{#each items as |item|}}
- {{string}} {{item}}
- {{/each}}
- `;
- addRawTemplate("raw-test", compile(template));
-
- const items = [1, 2];
- await render(
- <template>
- <span>{{raw "raw-test" string="foo" items=items}}</span>
- </template>
- );
-
- assert.dom("span").hasText("foo 1 foo 2");
- });
-
- test("#each helper handles getters", async function (assert) {
- const template = `
- {{#each items as |item|}}
- {{string}} {{item}}
- {{/each}}
- `;
- const compiledTemplate = compile(template);
-
- class Test {
- items = [1, 2];
-
- get string() {
- return "foo";
- }
- }
-
- const object = new Test();
-
- const output = compiledTemplate(object, RUNTIME_OPTIONS);
- assert.true(/\s*foo 1\s*foo 2\s*/.test(output));
- });
-});
diff --git a/app/assets/javascripts/discourse/tests/unit/lib/autocomplete-test.js b/app/assets/javascripts/discourse/tests/unit/lib/autocomplete-test.js
index dc4a05385d6..103d28a5ae5 100644
--- a/app/assets/javascripts/discourse/tests/unit/lib/autocomplete-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/lib/autocomplete-test.js
@@ -1,9 +1,8 @@
import { triggerKeyEvent } from "@ember/test-helpers";
import { setupTest } from "ember-qunit";
-import { compile } from "handlebars";
import $ from "jquery";
import { module, test } from "qunit";
-import { setCaretPosition } from "discourse/lib/utilities";
+import { escapeExpression, setCaretPosition } from "discourse/lib/utilities";
import {
simulateKey,
simulateKeys,
@@ -14,17 +13,13 @@ module("Unit | Utility | autocomplete", function (hooks) {
let _element;
- const template = compile(
- `
+ const template = (context) => `
<div id='ac-testing' class='autocomplete ac-test'>
<ul>
- {{#each options as |option|}}
- <li><a href>{{option}}</a></li>
- {{/each}}
+ ${context.options.map((option) => `<li><a href>${escapeExpression(option)}</a></li>`).join("")}
</ul>
</div>
- `.trim()
- );
+ `;
function textArea() {
_element = document.createElement("TEXTAREA");
diff --git a/app/assets/javascripts/discourse/tests/unit/lib/utilities-test.js b/app/assets/javascripts/discourse/tests/unit/lib/utilities-test.js
index d3845d98a3f..9503124387c 100644
--- a/app/assets/javascripts/discourse/tests/unit/lib/utilities-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/lib/utilities-test.js
@@ -1,6 +1,5 @@
import { getOwner } from "@ember/owner";
import { setupTest } from "ember-qunit";
-import Handlebars from "handlebars";
import { module, test } from "qunit";
import sinon from "sinon";
import {
@@ -39,12 +38,6 @@ module("Unit | Utilities", function (hooks) {
"escapes unsafe characters"
);
- assert.strictEqual(
- escapeExpression(new Handlebars.SafeString("&gt;")),
- "&gt;",
- "does not double-escape safe strings"
- );
-
assert.strictEqual(
escapeExpression(undefined),
"",
diff --git a/app/assets/javascripts/handlebars-shim.js b/app/assets/javascripts/handlebars-shim.js
deleted file mode 100644
index 9d8403d1890..00000000000
--- a/app/assets/javascripts/handlebars-shim.js
+++ /dev/null
@@ -1,19 +0,0 @@
-// allow us to import this as a module
-if (typeof define !== "undefined") {
- define("handlebars", ["exports"], function (__exports__) {
- // It might not be defined server side, which is OK for pretty-text
- if (typeof Handlebars !== "undefined") {
- // eslint-disable-next-line
- __exports__.default = Handlebars;
- __exports__.compile = function () {
- // eslint-disable-next-line
- return Handlebars.compile.apply(this, arguments);
- };
- }
- });
-
- define("handlebars-compiler", ["exports"], function (__exports__) {
- // eslint-disable-next-line
- __exports__.default = Handlebars.compile;
- });
-}
diff --git a/app/assets/javascripts/theme-transpiler/package.json b/app/assets/javascripts/theme-transpiler/package.json
index dc42df1801f..455633cea85 100644
--- a/app/assets/javascripts/theme-transpiler/package.json
+++ b/app/assets/javascripts/theme-transpiler/package.json
@@ -20,7 +20,6 @@
"ember-cli-htmlbars": "^6.3.0",
"ember-source": "~5.12.0",
"ember-this-fallback": "^0.4.0",
- "handlebars": "^4.7.8",
"path-browserify": "^1.0.1",
"polyfill-crypto.getrandomvalues": "^1.0.0",
"postcss": "^8.5.3",
diff --git a/app/assets/javascripts/theme-transpiler/transpiler.js b/app/assets/javascripts/theme-transpiler/transpiler.js
index 54e19ed9791..32a02cc9423 100644
--- a/app/assets/javascripts/theme-transpiler/transpiler.js
+++ b/app/assets/javascripts/theme-transpiler/transpiler.js
@@ -23,12 +23,10 @@ import DecoratorTransforms from "decorator-transforms";
import colocatedBabelPlugin from "ember-cli-htmlbars/lib/colocated-babel-plugin";
import { precompile } from "ember-source/dist/ember-template-compiler";
import EmberThisFallback from "ember-this-fallback";
-import Handlebars from "handlebars";
// A sub-dependency of content-tag (getrandom) needs `getRandomValues`
// so we polyfill it
import getRandomValues from "polyfill-crypto.getrandomvalues";
import { minify as terserMinify } from "terser";
-import RawHandlebars from "discourse/lib/raw-handlebars";
import { WidgetHbsCompiler } from "discourse-widget-hbs/lib/widget-hbs-compiler";
globalThis.crypto = { getRandomValues };
import "./postcss";
@@ -102,31 +100,6 @@ function buildTemplateCompilerBabelPlugins({ extension, themeId }) {
];
}
-function buildThemeRawHbsTemplateManipulatorPlugin(themeId) {
- return function (ast) {
- ["SubExpression", "MustacheStatement"].forEach((pass) => {
- const visitor = new Handlebars.Visitor();
- visitor.mutating = true;
- visitor[pass] = (node) => manipulateAstNodeForTheme(node, themeId);
- visitor.accept(ast);
- });
- };
-}
-
-globalThis.compileRawTemplate = function (source, themeId) {
- try {
- const plugins = [];
- if (themeId) {
- plugins.push(buildThemeRawHbsTemplateManipulatorPlugin(themeId));
- }
- return RawHandlebars.precompile(source, false, { plugins }).toString();
- } catch (error) {
- // Workaround for https://github.com/rubyjs/mini_racer/issues/262
- error.message = JSON.stringify(error.message);
- throw error;
- }
-};
-
globalThis.transpile = function (source, options = {}) {
const { moduleId, filename, extension, skipModule, themeId } = options;
diff --git a/app/assets/stylesheets/common/base/discourse.scss b/app/assets/stylesheets/common/base/discourse.scss
index e4620504b99..d3a07e32a09 100644
--- a/app/assets/stylesheets/common/base/discourse.scss
+++ b/app/assets/stylesheets/common/base/discourse.scss
@@ -818,7 +818,3 @@ a#skip-link {
overflow: hidden !important;
margin-right: var(--scroll-gap, 0);
}
-
-.hbr-ember-outlet {
- display: contents;
-}
diff --git a/app/models/theme_field.rb b/app/models/theme_field.rb
index acd63339a67..922336d73f4 100644
--- a/app/models/theme_field.rb
+++ b/app/models/theme_field.rb
@@ -135,7 +135,10 @@ class ThemeField < ActiveRecord::Base
begin
if is_raw
- js_compiler.append_raw_template(name, hbs_template)
+ js_compiler.append_js_error(
+ "discourse/templates/#{name}",
+ "Raw templates are no longer supported",
+ )
else
js_compiler.append_ember_template(
"discourse/templates/#{name.delete_prefix("/")}",
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index 4af440d1520..06db6a4b55b 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -2757,7 +2757,6 @@ en:
default_navigation_menu_categories: "Selected categories will be displayed under Navigation Menu's Categories section by default."
default_navigation_menu_tags: "Selected tags will be displayed under Navigation Menu's Tags section by default."
experimental_new_new_view_groups: 'Enable a new topics list that combines unread and new topics and make the "Everything" link in the sidebar link to it.'
- glimmer_topic_list_mode: "Control whether the new 'glimmer' topic-list implementation is used. 'auto' will enable automatically once all your themes and plugins are ready. See <a href='https://meta.discourse.org/t/343404'>the Meta topic</a> for more information."
glimmer_post_stream_mode: "Control whether the new 'glimmer' post stream implementation is used. 'auto' will enable automatically once all your themes and plugins are ready. This implementation is under active development, and is not intended for production use. Do not develop themes/plugins against it until the implementation is finalized and announced."
glimmer_post_stream_mode_auto_groups: "Enable the new 'glimmer' post menu implementation in 'auto' mode for the specified user groups. This implementation is under active development, and is not intended for production use. Do not develop themes/plugins against it until the implementation is finalized and announced."
experimental_form_templates: "Enable the form templates feature. Manage the templates at <a href='%{base_path}/admin/customize/form-templates'>Customize / Templates</a>."
diff --git a/config/site_settings.yml b/config/site_settings.yml
index b2cad53ec22..0d8706d365c 100644
--- a/config/site_settings.yml
+++ b/config/site_settings.yml
@@ -3941,14 +3941,6 @@ experimental:
allow_any: false
refresh: true
area: "group_permissions"
- glimmer_topic_list_mode:
- client: true
- type: enum
- choices:
- - disabled
- - auto
- - enabled
- default: enabled
glimmer_post_stream_mode_auto_groups:
client: true
type: group_list
diff --git a/lib/pretty_text.rb b/lib/pretty_text.rb
index 04ec6d9a718..571be71a227 100644
--- a/lib/pretty_text.rb
+++ b/lib/pretty_text.rb
@@ -70,7 +70,6 @@ module PrettyText
md_node_modules = "#{Rails.root}/app/assets/javascripts/discourse-markdown-it/node_modules"
ctx.load("#{d_node_modules}/loader.js/dist/loader/loader.js")
ctx.load("#{md_node_modules}/markdown-it/dist/markdown-it.js")
- ctx.load("#{root_path}/handlebars-shim.js")
ctx.load("#{md_node_modules}/xss/dist/xss.js")
ctx.load("#{Rails.root}/lib/pretty_text/vendor-shims.js")
diff --git a/lib/theme_javascript_compiler.rb b/lib/theme_javascript_compiler.rb
index f4960b2fed2..7b6b2eb3965 100644
--- a/lib/theme_javascript_compiler.rb
+++ b/lib/theme_javascript_compiler.rb
@@ -100,14 +100,6 @@ class ThemeJavascriptCompiler
tree.transform_keys! do |filename|
if filename.ends_with? ".js.es6"
filename.sub(/\.js\.es6\z/, ".js")
- elsif filename.include? "/templates/"
- filename = filename.sub(/\.raw\.hbs\z/, ".hbr") if filename.ends_with? ".raw.hbs"
-
- if filename.ends_with? ".hbr"
- filename.sub(%r{/templates/}, "/raw-templates/")
- else
- filename
- end
else
filename
end
@@ -176,8 +168,6 @@ class ThemeJavascriptCompiler
append_module(content, module_name, extension, include_variables:)
elsif extension == "hbs"
append_ember_template(module_name, content)
- elsif extension == "hbr"
- append_raw_template(module_name.sub("discourse/raw-templates/", ""), content)
else
append_js_error(filename, "unknown file extension '#{extension}' (#{filename})")
end
@@ -208,40 +198,6 @@ class ThemeJavascriptCompiler
raise CompileError.new ex.message
end
- def raw_template_name(name)
- name.sub(/\.(raw|hbr)\z/, "")
- end
-
- def append_raw_template(name, hbs_template)
- compiled =
- DiscourseJsProcessor::Transpiler.new.compile_raw_template(hbs_template, theme_id: @theme_id)
- source_for_comment = hbs_template.gsub("*/", '*\/').indent(4, " ")
- modern_replacement_marker = hbs_template.include?("{{!-- has-modern-replacement --}}")
-
- source = <<~JS
- /*
- #{source_for_comment}
- */
-
- import { template as compiler } from "discourse/lib/raw-handlebars";
- import { addRawTemplate } from "discourse/lib/raw-templates";
-
- let template = compiler(#{compiled});
-
- addRawTemplate(#{raw_template_name(name).to_json}, template, {
- themeId: #{@theme_id},
- themeName: #{@theme_name.to_json},
- hasModernReplacement: #{modern_replacement_marker}
- });
-
- export default template;
- JS
-
- append_module source, "raw-templates/#{raw_template_name(name)}", "js", include_variables: false
- rescue MiniRacer::RuntimeError, DiscourseJsProcessor::TranspileError => ex
- raise CompileError.new ex.message
- end
-
def append_raw_script(filename, script)
@output_tree << [filename, script + "\n"]
end
diff --git a/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/topic-list-item.hbs b/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/topic-list-item.hbs
index bcbd1eee056..6e53d76ca4f 100644
--- a/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/topic-list-item.hbs
+++ b/plugins/styleguide/assets/javascripts/discourse/components/sections/molecules/topic-list-item.hbs
@@ -31,9 +31,5 @@
</StyleguideExample>
<StyleguideExample @title="<TopicListItem> - latest" class="half-size">
- {{#if this.site.useGlimmerTopicList}}
- <TopicList::LatestTopicListItem @topic={{@dummy.topic}} />
- {{else}}
- <LatestTopicListItem @topic={{@dummy.topic}} />
- {{/if}}
+ <TopicList::LatestTopicListItem @topic={{@dummy.topic}} />
</StyleguideExample>
\ No newline at end of file
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index ef27e536e2d..4563a1db885 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -290,9 +290,6 @@ importers:
decorator-transforms:
specifier: ^2.3.0
version: 2.3.0(@babel/[email protected])
- discourse-hbr:
- specifier: workspace:1.0.0
- version: link:../discourse-hbr
discourse-widget-hbs:
specifier: workspace:1.0.0
version: link:../discourse-widget-hbs
@@ -308,9 +305,6 @@ importers:
ember-tracked-storage-polyfill:
specifier: ^1.0.0
version: 1.0.0
- handlebars:
- specifier: ^4.7.8
- version: 4.7.8
highlight.js:
specifier: 11.11.1
version: 11.11.1
@@ -634,15 +628,6 @@ importers:
specifier: ^1.0.15
version: 1.0.15
- app/assets/javascripts/discourse-hbr:
- dependencies:
- broccoli-filter:
- specifier: ^1.3.0
- version: 1.3.0
- handlebars:
- specifier: ^4.7.8
- version: 4.7.8
-
app/assets/javascripts/discourse-i18n:
dependencies:
'@embroider/addon-shim':
@@ -684,9 +669,6 @@ importers:
deprecation-silencer:
specifier: workspace:1.0.0
version: link:../deprecation-silencer
- discourse-hbr:
- specifier: workspace:1.0.0
- version: link:../discourse-hbr
discourse-widget-hbs:
specifier: workspace:1.0.0
version: link:../discourse-widget-hbs
@@ -724,9 +706,6 @@ importers:
ember-cli-htmlbars:
specifier: ^6.3.0
version: 6.3.0
- handlebars:
- specifier: ^4.7.8
- version: 4.7.8
devDependencies:
'@ember/optional-features':
specifier: ^2.2.0
@@ -1051,9 +1030,6 @@ importers:
ember-this-fallback:
specifier: ^0.4.0
version: 0.4.0(patch_hash=znalyv6akdxlqfpmxunrdi3osa)([email protected])([email protected](patch_hash=xx7mvsb7nmshqkkqhmf45r3hse)(@glimmer/[email protected](@babel/[email protected]))(@glint/[email protected])([email protected])([email protected](@swc/[email protected])([email protected])))
- handlebars:
- specifier: ^4.7.8
- version: 4.7.8
path-browserify:
specifier: ^1.0.1
version: 1.0.1
diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml
index 9f1de2b5d1d..492db59dcc3 100644
--- a/pnpm-workspace.yaml
+++ b/pnpm-workspace.yaml
@@ -4,7 +4,6 @@ packages:
- "app/assets/javascripts/deprecation-silencer"
- "app/assets/javascripts/dialog-holder"
- "app/assets/javascripts/discourse"
-- "app/assets/javascripts/discourse-hbr"
- "app/assets/javascripts/discourse-i18n"
- "app/assets/javascripts/discourse-markdown-it"
- "app/assets/javascripts/discourse-plugins"
diff --git a/spec/lib/discourse_js_processor_spec.rb b/spec/lib/discourse_js_processor_spec.rb
index aa840f5c954..7bee91c5317 100644
--- a/spec/lib/discourse_js_processor_spec.rb
+++ b/spec/lib/discourse_js_processor_spec.rb
@@ -136,72 +136,6 @@ RSpec.describe DiscourseJsProcessor do
JS
end
- describe "Raw template theme transformations" do
- # For the raw templates, we can easily render them serverside, so let's do that
-
- let(:compiler) { DiscourseJsProcessor::Transpiler.new }
- let(:theme_id) { 22 }
-
- let(:helpers) { <<~JS }
- Handlebars.registerHelper('theme-prefix', function(themeId, string) {
- return `theme_translations.${themeId}.${string}`
- })
- Handlebars.registerHelper('theme-i18n', function(themeId, string) {
- return `translated(theme_translations.${themeId}.${string})`
- })
- Handlebars.registerHelper('theme-setting', function(themeId, string) {
- return `setting(${themeId}:${string})`
- })
- Handlebars.registerHelper('dummy-helper', function(string) {
- return `dummy(${string})`
- })
- JS
-
- let(:mini_racer) do
- ctx = MiniRacer::Context.new
- ctx.eval(
- File.open(
- "#{Rails.root}/app/assets/javascripts/discourse/node_modules/handlebars/dist/handlebars.js",
- ).read,
- )
- ctx.eval(helpers)
- ctx
- end
-
- def render(template)
- compiled = compiler.compile_raw_template(template, theme_id: theme_id)
- mini_racer.eval "Handlebars.template(#{compiled.squish})({})"
- end
-
- it "adds the theme id to the helpers" do
- # Works normally
- expect(render("{{theme-prefix 'translation_key'}}")).to eq(
- "theme_translations.22.translation_key",
- )
- expect(render("{{theme-i18n 'translation_key'}}")).to eq(
- "translated(theme_translations.22.translation_key)",
- )
- expect(render("{{theme-setting 'setting_key'}}")).to eq("setting(22:setting_key)")
-
- # Works when used inside other statements
- expect(render("{{dummy-helper (theme-prefix 'translation_key')}}")).to eq(
- "dummy(theme_translations.22.translation_key)",
- )
- end
-
- it "doesn't duplicate number parameter inside {{each}}" do
- expect(
- compiler.compile_raw_template(
- "{{#each item as |test test2|}}{{theme-setting 'setting_key'}}{{/each}}",
- theme_id: theme_id,
- ),
- ).to include(
- '{"name":"theme-setting","hash":{},"hashTypes":{},"hashContexts":{},"types":["NumberLiteral","StringLiteral"]',
- )
- # Fail would be if theme-setting is defined with types:["NumberLiteral","NumberLiteral","StringLiteral"]
- end
- end
-
describe "Ember template transformations" do
# For the Ember (Glimmer) templates, serverside rendering is not trivial,
# so we compile the expected result with the standard compiler and compare to the theme compiler
diff --git a/spec/lib/theme_javascript_compiler_spec.rb b/spec/lib/theme_javascript_compiler_spec.rb
index 50706ab879f..0a672179189 100644
--- a/spec/lib/theme_javascript_compiler_spec.rb
+++ b/spec/lib/theme_javascript_compiler_spec.rb
@@ -3,23 +3,6 @@
RSpec.describe ThemeJavascriptCompiler do
let(:compiler) { ThemeJavascriptCompiler.new(1, "marks") }
- describe "#append_raw_template" do
- it "uses the correct template paths" do
- template = "<h1>hello</h1>"
- name = "/path/to/templates1"
- compiler.append_raw_template("#{name}.raw", template)
- expect(compiler.raw_content.to_s).to include("addRawTemplate)(\"#{name}\"")
-
- name = "/path/to/templates2"
- compiler.append_raw_template("#{name}.hbr", template)
- expect(compiler.raw_content.to_s).to include("addRawTemplate)(\"#{name}\"")
-
- name = "/path/to/templates3"
- compiler.append_raw_template("#{name}.hbs", template)
- expect(compiler.raw_content.to_s).to include("addRawTemplate)(\"#{name}.hbs\"")
- end
- end
-
describe "#append_ember_template" do
it "maintains module names so that discourse-boot.js can correct them" do
compiler.append_ember_template("/connectors/blah-1", "{{var}}")
@@ -95,12 +78,6 @@ RSpec.describe ThemeJavascriptCompiler do
end
describe "error handling" do
- it "handles syntax errors in raw templates" do
- expect do
- compiler.append_raw_template("sometemplate.hbr", "{{invalidtemplate")
- end.to raise_error(ThemeJavascriptCompiler::CompileError, /Parse error on line 1/)
- end
-
it "handles syntax errors in ember templates" do
expect do
compiler.append_ember_template("sometemplate", "{{invalidtemplate")
diff --git a/spec/models/theme_field_spec.rb b/spec/models/theme_field_spec.rb
index 196298ec065..533bde56225 100644
--- a/spec/models/theme_field_spec.rb
+++ b/spec/models/theme_field_spec.rb
@@ -226,12 +226,6 @@ HTML
name: "discourse/templates/discovery.hbs",
value: "{{hello-world}}",
)
- raw_hbs_field =
- theme.set_field(
- target: :extra_js,
- name: "discourse/templates/discovery.hbr",
- value: "{{hello-world}}",
- )
hbr_field =
theme.set_field(
target: :extra_js,
@@ -255,7 +249,6 @@ HTML
expect(theme.javascript_cache.content).to include(
"define(\"discourse/theme-#{theme.id}/discourse/templates/discovery\", [\"exports\", ",
)
- expect(theme.javascript_cache.content).to include('addRawTemplate)("discovery"')
expect(theme.javascript_cache.content).to include(
"define(\"discourse/theme-#{theme.id}/discourse/controllers/discovery\"",
)
@@ -266,6 +259,9 @@ HTML
expect(theme.javascript_cache.content).to include(
"[THEME #{theme.id} '#{theme.name}'] Compile error: unknown file extension 'blah' (discourse/controllers/discovery.blah)",
)
+ expect(theme.javascript_cache.content).to include(
+ "[THEME #{theme.id} '#{theme.name}'] Compile error: unknown file extension 'hbr' (discourse/templates/other_discovery.hbr)",
+ )
# Check sourcemap
expect(theme.javascript_cache.source_map).to eq(nil)
@@ -281,11 +277,10 @@ HTML
"discourse/controllers/discovery.blah",
"discourse/controllers/discovery.js",
"discourse/templates/discovery.js",
- "raw-templates/discovery.js",
- "raw-templates/other_discovery.js",
+ "discourse/templates/other_discovery.hbr",
)
expect(map["sourceRoot"]).to eq("theme-#{theme.id}/")
- expect(map["sourcesContent"].length).to eq(6)
+ expect(map["sourcesContent"].length).to eq(5)
end
def create_upload_theme_field!(name)
diff --git a/spec/models/theme_spec.rb b/spec/models/theme_spec.rb
index 5c799d1a63d..95817be009e 100644
--- a/spec/models/theme_spec.rb
+++ b/spec/models/theme_spec.rb
@@ -142,7 +142,7 @@ HTML
expect(baked).to include(field.javascript_cache.url)
expect(field.javascript_cache.content).to include("@ember/template-factory")
- expect(field.javascript_cache.content).to include("raw-handlebars")
+ expect(field.javascript_cache.content).to include("Raw templates are no longer supported")
end
it "can destroy unbaked theme without errors" do
diff --git a/spec/system/topic_list/glimmer_spec.rb b/spec/system/topic_list/glimmer_spec.rb
index bc64c273460..29aafffeb91 100644
--- a/spec/system/topic_list/glimmer_spec.rb
+++ b/spec/system/topic_list/glimmer_spec.rb
@@ -6,10 +6,7 @@ describe "glimmer topic list", type: :system do
let(:topic_list) { PageObjects::Components::TopicList.new }
let(:topic_page) { PageObjects::Pages::Topic.new }
- before do
- SiteSetting.glimmer_topic_list_mode = "enabled"
- sign_in(user)
- end
+ before { sign_in(user) }
describe "/latest" do
it "shows the list" do