DEV: Convert share-source to gjs (#25964)

This commit is contained in:
Jarek Radosz 2024-02-29 15:12:17 +01:00 committed by GitHub
parent f087234ff7
commit 03de0421af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 25 additions and 34 deletions

View File

@ -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}}

View File

@ -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>

View File

@ -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"),
});
},
});

View File

@ -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;

View File

@ -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}}
/>

View File

@ -1,10 +0,0 @@
import Component from "@ember/component";
export default Component.extend({
tagName: "",
actions: {
share(source) {
this.action(source);
},
},
});