A platform for community discussion. Free, open, simple.
DEV: Convert CustomHtml to glimmer/gjs (#37397)
Jarek Radoszd6d3fc86294a
diff --git a/frontend/discourse/admin/components/version-checks.gjs b/frontend/discourse/admin/components/version-checks.gjsindex bbe0db84f1e..86df24cec24 100644--- a/frontend/discourse/admin/components/version-checks.gjs+++ b/frontend/discourse/admin/components/version-checks.gjs@@ -139,12 +139,7 @@ const VersionChecks = <template></div>{{/if}}- <CustomHtml- @name="update-header"- @versionCheck={{@versionCheck}}- @tagName="div"- @classNames="update-header"- />+ <CustomHtml @name="update-header" class="update-header" /><PluginOutlet@name="admin-upgrade-header"diff --git a/frontend/discourse/app/components/custom-html.gjs b/frontend/discourse/app/components/custom-html.gjsnew file mode 100644index 00000000000..b1ed4defd14--- /dev/null+++ b/frontend/discourse/app/components/custom-html.gjs@@ -0,0 +1,38 @@+import Component from "@glimmer/component";+import { action } from "@ember/object";+import didInsert from "@ember/render-modifiers/modifiers/did-insert";+import willDestroy from "@ember/render-modifiers/modifiers/will-destroy";+import { service } from "@ember/service";+import { getCustomHTML } from "discourse/helpers/custom-html";++export default class CustomHtml extends Component {+ @service appEvents;++ get html() {+ return getCustomHTML(this.args.name);+ }++ @action+ didInsertElement() {+ if (this.args.triggerAppEvent) {+ this.appEvents.trigger(`inserted-custom-html:${this.args.name}`);+ }+ }++ @action+ willDestroyElement() {+ if (this.args.triggerAppEvent) {+ this.appEvents.trigger(`destroyed-custom-html:${this.args.name}`);+ }+ }++ <template>+ <div+ {{didInsert this.didInsertElement}}+ {{willDestroy this.willDestroyElement}}+ ...attributes+ >+ {{this.html}}+ </div>+ </template>+}diff --git a/frontend/discourse/app/components/custom-html.js b/frontend/discourse/app/components/custom-html.jsdeleted file mode 100644index 3c7b330e07a..00000000000--- a/frontend/discourse/app/components/custom-html.js+++ /dev/null@@ -1,33 +0,0 @@-/* eslint-disable ember/no-classic-components */-import Component from "@ember/component";-import { hbs } from "ember-cli-htmlbars";-import { getCustomHTML } from "discourse/helpers/custom-html";--export default class CustomHtml extends Component {- triggerAppEvent = null;-- init() {- super.init(...arguments);- const name = this.name;- const html = getCustomHTML(name);-- if (html) {- this.set("html", html);- this.set("layout", hbs`{{this.html}}`);- }- }-- didInsertElement() {- super.didInsertElement(...arguments);- if (this.triggerAppEvent === "true") {- this.appEvents.trigger(`inserted-custom-html:${this.name}`);- }- }-- willDestroyElement() {- super.willDestroyElement(...arguments);- if (this.triggerAppEvent === "true") {- this.appEvents.trigger(`destroyed-custom-html:${this.name}`);- }- }-}diff --git a/frontend/discourse/app/templates/application.gjs b/frontend/discourse/app/templates/application.gjsindex 1d28fc96138..6e64ee60bbe 100644--- a/frontend/discourse/app/templates/application.gjs+++ b/frontend/discourse/app/templates/application.gjs@@ -147,8 +147,8 @@ export default <template>{{#if @controller.showFooter}}<CustomHtml@name="footer"- @triggerAppEvent="true"- @classNames="custom-footer-content"+ @triggerAppEvent={{true}}+ class="custom-footer-content"/>{{/if}}<PluginOutlet