diff --git a/app/assets/javascripts/discourse/app/controllers/share-topic.js b/app/assets/javascripts/discourse/app/controllers/share-topic.js index b9a06513730..638a704c319 100644 --- a/app/assets/javascripts/discourse/app/controllers/share-topic.js +++ b/app/assets/javascripts/discourse/app/controllers/share-topic.js @@ -16,19 +16,31 @@ export default Controller.extend( bufferedProperty("invite"), { topic: null, + post: null, + allowInvites: false, + showNotifyUsers: false, restrictedGroups: null, onShow() { - this.set("showNotifyUsers", false); + this.setProperties({ + topic: null, + post: null, + allowInvites: false, + showNotifyUsers: false, + }); if (this.model && this.model.read_restricted) { this.restrictedGroupWarning(); } }, - @discourseComputed("topic.shareUrl") - topicUrl(url) { - return url ? getAbsoluteURL(url) : null; + @discourseComputed("post.shareUrl", "topic.shareUrl") + url(postUrl, topicUrl) { + if (postUrl) { + return getAbsoluteURL(postUrl); + } else if (topicUrl) { + return getAbsoluteURL(topicUrl); + } }, @discourseComputed( @@ -57,7 +69,7 @@ export default Controller.extend( this.set("showNotifyUsers", false); Sharing.shareSource(source, { title: this.topic.title, - url: this.topicUrl, + url: this.url, }); }, @@ -81,7 +93,10 @@ export default Controller.extend( ajax(`/t/${this.topic.id}/invite-notify`, { type: "POST", - data: { usernames: this.users }, + data: { + usernames: this.users, + post_number: this.post ? this.post.post_number : undefined, + }, }) .then(() => { this.setProperties({ showNotifyUsers: false }); diff --git a/app/assets/javascripts/discourse/app/initializers/topic-footer-buttons.js b/app/assets/javascripts/discourse/app/initializers/topic-footer-buttons.js index a5a52277718..e00c100309f 100644 --- a/app/assets/javascripts/discourse/app/initializers/topic-footer-buttons.js +++ b/app/assets/javascripts/discourse/app/initializers/topic-footer-buttons.js @@ -18,7 +18,7 @@ export default { priority: SHARE_PRIORITY, label() { if (!this.get("topic.isPrivateMessage") || this.site.mobileView) { - return "topic.share.title"; + return "footer_nav.share"; } }, title: "topic.share.help", diff --git a/app/assets/javascripts/discourse/app/templates/modal/share-topic.hbs b/app/assets/javascripts/discourse/app/templates/modal/share-topic.hbs index 330637850b8..8c4c3a7a857 100644 --- a/app/assets/javascripts/discourse/app/templates/modal/share-topic.hbs +++ b/app/assets/javascripts/discourse/app/templates/modal/share-topic.hbs @@ -1,12 +1,14 @@ -{{#d-modal-body title="topic.share.title"}} +{{#d-modal-body rawTitle=(if post (i18n "post.share.title" post_number=post.post_number) (i18n "topic.share.title"))}}