mirror of
https://github.com/discourse/discourse.git
synced 2025-07-12 11:53:34 +00:00
FIX: Href attribute for post-date link (#16471)
This updates the fix in commit eb70ea4. Co-authored-by: Osama Sayegh <asooomaasoooma90@gmail.com> Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com>
This commit is contained in:
parent
f2468f1093
commit
650adbe423
@ -19,7 +19,6 @@ import { iconNode } from "discourse-common/lib/icon-library";
|
|||||||
import { postTransformCallbacks } from "discourse/widgets/post-stream";
|
import { postTransformCallbacks } from "discourse/widgets/post-stream";
|
||||||
import { prioritizeNameInUx } from "discourse/lib/settings";
|
import { prioritizeNameInUx } from "discourse/lib/settings";
|
||||||
import { relativeAgeMediumSpan } from "discourse/lib/formatter";
|
import { relativeAgeMediumSpan } from "discourse/lib/formatter";
|
||||||
import { wantsNewWindow } from "discourse/lib/intercept-click";
|
|
||||||
import { transformBasicPost } from "discourse/lib/transform-post";
|
import { transformBasicPost } from "discourse/lib/transform-post";
|
||||||
import autoGroupFlairForUser from "discourse/lib/avatar-flair";
|
import autoGroupFlairForUser from "discourse/lib/avatar-flair";
|
||||||
import showModal from "discourse/lib/show-modal";
|
import showModal from "discourse/lib/show-modal";
|
||||||
@ -353,25 +352,30 @@ createWidget("post-date", {
|
|||||||
tagName: "div.post-info.post-date",
|
tagName: "div.post-info.post-date",
|
||||||
|
|
||||||
html(attrs) {
|
html(attrs) {
|
||||||
const attributes = { href: attrs.shareUrl, class: "post-date" };
|
let date,
|
||||||
let date = attrs.created_at;
|
linkClassName = "post-date";
|
||||||
if (attrs.lastWikiEdit) {
|
|
||||||
attributes["class"] += " last-wiki-edit";
|
if (attrs.wiki && attrs.lastWikiEdit) {
|
||||||
date = attrs.lastWikiEdit;
|
linkClassName += " last-wiki-edit";
|
||||||
|
date = new Date(attrs.lastWikiEdit);
|
||||||
|
} else {
|
||||||
|
date = new Date(attrs.created_at);
|
||||||
}
|
}
|
||||||
return h("a", { attributes }, dateNode(new Date(date)));
|
return this.attach("link", {
|
||||||
|
rawLabel: dateNode(date),
|
||||||
|
className: linkClassName,
|
||||||
|
omitSpan: true,
|
||||||
|
title: "post.sr_date",
|
||||||
|
href: attrs.shareUrl,
|
||||||
|
action: "showShareModal",
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
click() {
|
showShareModal() {
|
||||||
if (wantsNewWindow(event)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const post = this.findAncestorModel();
|
const post = this.findAncestorModel();
|
||||||
const topic = post.topic;
|
const topic = post.topic;
|
||||||
const controller = showModal("share-topic", { model: topic.category });
|
const controller = showModal("share-topic", { model: topic.category });
|
||||||
controller.setProperties({ topic, post });
|
controller.setProperties({ topic, post });
|
||||||
event.preventDefault();
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import CategoryFixtures from "discourse/tests/fixtures/category-fixtures";
|
import CategoryFixtures from "discourse/tests/fixtures/category-fixtures";
|
||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
import { click, visit } from "@ember/test-helpers";
|
import { click, currentURL, visit } from "@ember/test-helpers";
|
||||||
import {
|
import {
|
||||||
acceptance,
|
acceptance,
|
||||||
exists,
|
exists,
|
||||||
@ -59,14 +59,19 @@ acceptance("Share and Invite modal", function (needs) {
|
|||||||
|
|
||||||
test("Post date link", async function (assert) {
|
test("Post date link", async function (assert) {
|
||||||
await visit("/t/short-topic-with-two-posts/54077");
|
await visit("/t/short-topic-with-two-posts/54077");
|
||||||
await click("#post_2 .post-info.post-date");
|
|
||||||
assert.ok(
|
assert.ok(
|
||||||
query("#post_2 .post-info.post-date a").href.endsWith(
|
query("#post_2 .post-info.post-date a").href.endsWith(
|
||||||
"/t/short-topic-with-two-posts/54077/2?u=eviltrout"
|
"/t/short-topic-with-two-posts/54077/2?u=eviltrout"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await click("#post_2 a.post-date");
|
||||||
assert.ok(exists(".share-topic-modal"), "it shows the share modal");
|
assert.ok(exists(".share-topic-modal"), "it shows the share modal");
|
||||||
|
assert.strictEqual(
|
||||||
|
currentURL(),
|
||||||
|
"/t/short-topic-with-two-posts/54077",
|
||||||
|
"it does not route to post #2"
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Share topic in a restricted category", async function (assert) {
|
test("Share topic in a restricted category", async function (assert) {
|
||||||
|
@ -3066,6 +3066,7 @@ en:
|
|||||||
deleted_by_author_simple: "(post deleted by author)"
|
deleted_by_author_simple: "(post deleted by author)"
|
||||||
collapse: "collapse"
|
collapse: "collapse"
|
||||||
sr_collapse_replies: "Collapse embedded replies"
|
sr_collapse_replies: "Collapse embedded replies"
|
||||||
|
sr_date: "Post date"
|
||||||
sr_expand_replies:
|
sr_expand_replies:
|
||||||
one: "This post has %{count} reply. Click to expand"
|
one: "This post has %{count} reply. Click to expand"
|
||||||
other: "This post has %{count} replies. Click to expand"
|
other: "This post has %{count} replies. Click to expand"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user