mirror of
https://github.com/discourse/discourse.git
synced 2025-05-26 12:05:25 +08:00
Fix share button in post menu
This commit is contained in:
@ -441,6 +441,38 @@ createWidget("post-contents", {
|
|||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_date(attrs) {
|
||||||
|
const lastWikiEdit =
|
||||||
|
attrs.wiki && attrs.lastWikiEdit && new Date(attrs.lastWikiEdit);
|
||||||
|
const createdAt = new Date(attrs.created_at);
|
||||||
|
return lastWikiEdit ? lastWikiEdit : createdAt;
|
||||||
|
},
|
||||||
|
|
||||||
|
share() {
|
||||||
|
const post = this.findAncestorModel();
|
||||||
|
|
||||||
|
const modalFallback = () => {
|
||||||
|
showModal("share-and-invite", {
|
||||||
|
modalClass: "share-and-invite",
|
||||||
|
panels: [
|
||||||
|
{
|
||||||
|
id: "share",
|
||||||
|
title: "topic.share.extended_title",
|
||||||
|
model: {
|
||||||
|
postNumber: this.attrs.post_number,
|
||||||
|
shareUrl: this.attrs.shareUrl,
|
||||||
|
date: this._date(this.attrs),
|
||||||
|
postId: post.get("id"),
|
||||||
|
topic: post.get("topic")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
nativeShare({ url: this.attrs.shareUrl }).then(null, modalFallback);
|
||||||
|
},
|
||||||
|
|
||||||
toggleRepliesBelow(goToPost = "false") {
|
toggleRepliesBelow(goToPost = "false") {
|
||||||
if (this.state.repliesBelow.length) {
|
if (this.state.repliesBelow.length) {
|
||||||
this.state.repliesBelow = [];
|
this.state.repliesBelow = [];
|
||||||
|
@ -22,6 +22,14 @@ acceptance("Topic", {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
QUnit.test("Share Modal", async assert => {
|
||||||
|
await visit("/t/internationalization-localization/280");
|
||||||
|
|
||||||
|
await click(".topic-post:first-child button.share");
|
||||||
|
assert.ok(exists(".modal.share-and-invite"), "it shows the share and invite modal");
|
||||||
|
});
|
||||||
|
|
||||||
QUnit.test("Showing and hiding the edit controls", async assert => {
|
QUnit.test("Showing and hiding the edit controls", async assert => {
|
||||||
await visit("/t/internationalization-localization/280");
|
await visit("/t/internationalization-localization/280");
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user