A platform for community discussion. Free, open, simple.
DEV: Convert share-source to gjs (#25964)
Jarek Radosz03de0421af36
diff --git a/app/assets/javascripts/discourse/app/components/modal/share-topic.hbs b/app/assets/javascripts/discourse/app/components/modal/share-topic.hbsindex 8f66c59647d..680ab57639c 100644--- a/app/assets/javascripts/discourse/app/components/modal/share-topic.hbs+++ b/app/assets/javascripts/discourse/app/components/modal/share-topic.hbs@@ -34,12 +34,8 @@<div class="link-share-actions"><div class="sources">- {{#each this.sources as |s|}}- <ShareSource- @source={{s}}- @title={{this.topic.title}}- @action={{action "share"}}- />+ {{#each this.sources as |source|}}+ <ShareSource @source={{source}} @action={{this.share}} />{{/each}}{{#if this.allowInvites}}diff --git a/app/assets/javascripts/discourse/app/components/share-panel.hbs b/app/assets/javascripts/discourse/app/components/share-panel.hbsindex 690a6dfa7b4..0f024c13ccf 100644--- a/app/assets/javascripts/discourse/app/components/share-panel.hbs+++ b/app/assets/javascripts/discourse/app/components/share-panel.hbs@@ -11,11 +11,7 @@<div class="sources">{{#each this.sources as |source|}}- <ShareSource- @source={{source}}- @title={{this.topic.title}}- @action={{action "share"}}- />+ <ShareSource @source={{source}} @action={{this.share}} />{{/each}}</div></div>\ No newline at end of filediff --git a/app/assets/javascripts/discourse/app/components/share-panel.js b/app/assets/javascripts/discourse/app/components/share-panel.jsindex cd178a6e278..56805af04e5 100644--- a/app/assets/javascripts/discourse/app/components/share-panel.js+++ b/app/assets/javascripts/discourse/app/components/share-panel.js@@ -1,4 +1,5 @@import Component from "@ember/component";+import { action } from "@ember/object";import { alias } from "@ember/object/computed";import { isEmpty } from "@ember/utils";import Sharing from "discourse/lib/sharing";@@ -58,12 +59,11 @@ export default Component.extend({}, 200);},- actions: {- share(source) {- Sharing.shareSource(source, {- url: this.shareUrl,- title: this.get("topic.title"),- });- },+ @action+ share(source) {+ Sharing.shareSource(source, {+ url: this.shareUrl,+ title: this.topic.get("title"),+ });},});diff --git a/app/assets/javascripts/discourse/app/components/share-source.gjs b/app/assets/javascripts/discourse/app/components/share-source.gjsnew file mode 100644index 00000000000..2165048b8f0--- /dev/null+++ b/app/assets/javascripts/discourse/app/components/share-source.gjs@@ -0,0 +1,15 @@+import { fn } from "@ember/helper";+import DButton from "discourse/components/d-button";+import or from "truth-helpers/helpers/or";++const ShareSource = <template>+ <DButton+ @action={{fn @action @source}}+ @translatedTitle={{@source.title}}+ @icon={{or @source.icon @source.htmlIcon}}+ class="btn-default share-{{@source.id}}"+ ...attributes+ />+</template>;++export default ShareSource;diff --git a/app/assets/javascripts/discourse/app/components/share-source.hbs b/app/assets/javascripts/discourse/app/components/share-source.hbsdeleted file mode 100644index b6184d53f7c..00000000000--- a/app/assets/javascripts/discourse/app/components/share-source.hbs+++ /dev/null@@ -1,6 +0,0 @@-<DButton- @action={{fn (action "share") this.source}}- @translatedTitle={{this.source.title}}- @icon={{or this.source.icon this.source.htmlIcon}}- class={{concat "btn-default share-" this.source.id}}-/>\ No newline at end of filediff --git a/app/assets/javascripts/discourse/app/components/share-source.js b/app/assets/javascripts/discourse/app/components/share-source.jsdeleted file mode 100644index 972ffe3249f..00000000000--- a/app/assets/javascripts/discourse/app/components/share-source.js+++ /dev/null@@ -1,10 +0,0 @@-import Component from "@ember/component";-export default Component.extend({- tagName: "",-- actions: {- share(source) {- this.action(source);- },- },-});