UX: Switch My Posts link in sidebar to My Drafts when drafts are present (#20491)

This commit is contained in:
Osama Sayegh 2023-03-02 01:29:18 +03:00 committed by GitHub
parent e195e6f614
commit 82a84241ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 1 deletions

View File

@ -55,10 +55,17 @@ export default class MyPostsSectionLink extends BaseSectionLink {
}
get text() {
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";
}

View File

@ -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");

View File

@ -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: