mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 10:20:58 -06:00
UX: Switch My Posts link in sidebar to My Drafts when drafts are present (#20491)
This commit is contained in:
parent
e195e6f614
commit
82a84241ca
@ -55,10 +55,17 @@ export default class MyPostsSectionLink extends BaseSectionLink {
|
||||
}
|
||||
|
||||
get text() {
|
||||
return I18n.t("sidebar.sections.community.links.my_posts.content");
|
||||
if (this._hasDraft && this.currentUser?.new_new_view_enabled) {
|
||||
return I18n.t("sidebar.sections.community.links.my_posts.content_drafts");
|
||||
} else {
|
||||
return I18n.t("sidebar.sections.community.links.my_posts.content");
|
||||
}
|
||||
}
|
||||
|
||||
get badgeText() {
|
||||
if (this._hasDraft && this.currentUser?.new_new_view_enabled) {
|
||||
return this.draftCount.toString();
|
||||
}
|
||||
if (this._hasDraft && !this.hideCount) {
|
||||
return I18n.t("sidebar.sections.community.links.my_posts.draft_count", {
|
||||
count: this.draftCount,
|
||||
@ -71,6 +78,9 @@ export default class MyPostsSectionLink extends BaseSectionLink {
|
||||
}
|
||||
|
||||
get prefixValue() {
|
||||
if (this._hasDraft && this.currentUser?.new_new_view_enabled) {
|
||||
return "pencil-alt";
|
||||
}
|
||||
return "user";
|
||||
}
|
||||
|
||||
|
@ -583,6 +583,39 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) {
|
||||
);
|
||||
});
|
||||
|
||||
test("my posts changes its text when drafts are present and new new view experiment is enabled", async function (assert) {
|
||||
updateCurrentUser({
|
||||
sidebar_list_destination: "unread_new",
|
||||
new_new_view_enabled: true,
|
||||
});
|
||||
await visit("/");
|
||||
|
||||
assert.strictEqual(
|
||||
query(".sidebar-section-link-my-posts").textContent.trim(),
|
||||
I18n.t("sidebar.sections.community.links.my_posts.content"),
|
||||
"displays the default text when no drafts are present"
|
||||
);
|
||||
|
||||
await publishToMessageBus(`/user-drafts/${loggedInUser().id}`, {
|
||||
draft_count: 1,
|
||||
});
|
||||
|
||||
assert.strictEqual(
|
||||
query(
|
||||
".sidebar-section-link-my-posts .sidebar-section-link-content-text"
|
||||
).textContent.trim(),
|
||||
I18n.t("sidebar.sections.community.links.my_posts.content_drafts"),
|
||||
"displays the text that's appropriate for when drafts are present"
|
||||
);
|
||||
assert.strictEqual(
|
||||
query(
|
||||
".sidebar-section-link-my-posts .sidebar-section-link-content-badge"
|
||||
).textContent.trim(),
|
||||
"1",
|
||||
"displays the draft count with no text"
|
||||
);
|
||||
});
|
||||
|
||||
test("visiting top route", async function (assert) {
|
||||
await visit("/top");
|
||||
|
||||
|
@ -4438,6 +4438,7 @@ en:
|
||||
title: "List of all users"
|
||||
my_posts:
|
||||
content: "My Posts"
|
||||
content_drafts: "My Drafts"
|
||||
title: "My recent topic activity"
|
||||
title_drafts: "My unposted drafts"
|
||||
draft_count:
|
||||
|
Loading…
Reference in New Issue
Block a user