FIX: Use prioritize_username_in_ux in post notices.
This commit is contained in:
parent
77931b70c3
commit
18ff790e79
|
@ -431,15 +431,25 @@ createWidget("post-contents", {
|
|||
createWidget("post-notice", {
|
||||
tagName: "div.post-notice",
|
||||
|
||||
buildClasses(attrs) {
|
||||
if (attrs.postNoticeType === "first") {
|
||||
return ["new-user"];
|
||||
} else if (attrs.postNoticeType === "returning") {
|
||||
return ["returning-user"];
|
||||
}
|
||||
return [];
|
||||
},
|
||||
|
||||
html(attrs) {
|
||||
const user = this.siteSettings.prioritize_username_in_ux || !attrs.name ? attrs.username : attrs.name;
|
||||
let text, icon;
|
||||
if (attrs.postNoticeType === "first") {
|
||||
icon = "hands-helping";
|
||||
text = I18n.t("post.notice.first", { user: attrs.username });
|
||||
text = I18n.t("post.notice.first", { user });
|
||||
} else if (attrs.postNoticeType === "returning") {
|
||||
icon = "far-smile";
|
||||
text = I18n.t("post.notice.return", {
|
||||
user: attrs.username,
|
||||
user,
|
||||
time: relativeAge(attrs.postNoticeTime, {
|
||||
format: "tiny",
|
||||
addAgo: true
|
||||
|
|
|
@ -853,21 +853,43 @@ widgetTest("pm map", {
|
|||
}
|
||||
});
|
||||
|
||||
widgetTest("post notice", {
|
||||
widgetTest("post notice - with username", {
|
||||
template: '{{mount-widget widget="post" args=args}}',
|
||||
beforeEach() {
|
||||
this.siteSettings.prioritize_username_in_ux = true;
|
||||
this.set("args", {
|
||||
postNoticeType: "returning",
|
||||
postNoticeTime: new Date("2010-01-01 12:00:00 UTC"),
|
||||
username: "codinghorror"
|
||||
username: "codinghorror",
|
||||
name: "Jeff"
|
||||
});
|
||||
},
|
||||
test(assert) {
|
||||
assert.equal(
|
||||
find(".post-notice")
|
||||
find(".post-notice.returning-user")
|
||||
.text()
|
||||
.trim(),
|
||||
I18n.t("post.notice.return", { user: "codinghorror", time: "Jan '10" })
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
widgetTest("post notice - with name", {
|
||||
template: '{{mount-widget widget="post" args=args}}',
|
||||
beforeEach() {
|
||||
this.siteSettings.prioritize_username_in_ux = false;
|
||||
this.set("args", {
|
||||
postNoticeType: "first",
|
||||
username: "codinghorror",
|
||||
name: "Jeff"
|
||||
});
|
||||
},
|
||||
test(assert) {
|
||||
assert.equal(
|
||||
find(".post-notice.new-user")
|
||||
.text()
|
||||
.trim(),
|
||||
I18n.t("post.notice.first", { user: "Jeff", time: "Jan '10" })
|
||||
);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue