UX: Removed tracked section link from Community section in Sidebar (#19122)

Product has decided that the tracked section link provides very little
value at this moment in time so we're removing it.

See https://meta.discourse.org/t/245374 for more context.
This commit is contained in:
Alan Guo Xiang Tan 2022-11-21 16:45:19 +08:00 committed by GitHub
parent 3f24a5e9e2
commit 59e02bd210
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 0 additions and 504 deletions

View File

@ -4,7 +4,6 @@ import Composer from "discourse/models/composer";
import { getOwner } from "discourse-common/lib/get-owner";
import PermissionType from "discourse/models/permission-type";
import EverythingSectionLink from "discourse/lib/sidebar/common/community-section/everything-section-link";
import TrackedSectionLink from "discourse/lib/sidebar/user/community-section/tracked-section-link";
import MyPostsSectionLink from "discourse/lib/sidebar/user/community-section/my-posts-section-link";
import GroupsSectionLink from "discourse/lib/sidebar/common/community-section/groups-section-link";
import UsersSectionLink from "discourse/lib/sidebar/common/community-section/users-section-link";
@ -35,7 +34,6 @@ export default class SidebarUserCommunitySection extends SidebarCommonCommunityS
get defaultMainSectionLinks() {
return [
EverythingSectionLink,
TrackedSectionLink,
MyPostsSectionLink,
AdminSectionLink,
ReviewSectionLink,

View File

@ -1,101 +0,0 @@
import I18n from "I18n";
import { tracked } from "@glimmer/tracking";
import BaseSectionLink from "discourse/lib/sidebar/base-community-section-link";
import { isTrackedTopic } from "discourse/lib/topic-list-tracked-filter";
import { UNREAD_LIST_DESTINATION } from "discourse/controllers/preferences/sidebar";
export default class TrackedSectionLink extends BaseSectionLink {
@tracked totalUnread = 0;
@tracked totalNew = 0;
@tracked hideCount =
this.currentUser?.sidebarListDestination !== UNREAD_LIST_DESTINATION;
constructor() {
super(...arguments);
this.#refreshCounts();
}
onTopicTrackingStateChange() {
this.#refreshCounts();
}
#refreshCounts() {
this.totalUnread = this.topicTrackingState.countUnread({
customFilterFn: isTrackedTopic,
});
if (this.totalUnread === 0) {
this.totalNew = this.topicTrackingState.countNew({
customFilterFn: isTrackedTopic,
});
}
}
get name() {
return "tracked";
}
get query() {
return { f: "tracked" };
}
get title() {
return I18n.t("sidebar.sections.community.links.tracked.title");
}
get text() {
return I18n.t("sidebar.sections.community.links.tracked.content");
}
get currentWhen() {
return "discovery.latest discovery.new discovery.unread discovery.top";
}
get badgeText() {
if (this.hideCount) {
return;
}
if (this.totalUnread > 0) {
return I18n.t("sidebar.unread_count", {
count: this.totalUnread,
});
} else if (this.totalNew > 0) {
return I18n.t("sidebar.new_count", {
count: this.totalNew,
});
} else {
return;
}
}
get route() {
if (this.currentUser?.sidebarListDestination === UNREAD_LIST_DESTINATION) {
if (this.totalUnread > 0) {
return "discovery.unread";
}
if (this.totalNew > 0) {
return "discovery.new";
}
}
return "discovery.latest";
}
get prefixValue() {
return "bell";
}
get suffixCSSClass() {
return "unread";
}
get suffixType() {
return "icon";
}
get suffixValue() {
if (this.hideCount && (this.totalUnread || this.totalNew)) {
return "circle";
}
}
}

View File

@ -18,7 +18,6 @@ import {
import topicFixtures from "discourse/tests/fixtures/discovery-fixtures";
import { cloneJSON } from "discourse-common/lib/object";
import { withPluginApi } from "discourse/lib/plugin-api";
import Site from "discourse/models/site";
import { NotificationLevels } from "discourse/lib/notification-levels";
acceptance("Sidebar - Logged on user - Community Section", function (needs) {
@ -269,139 +268,6 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) {
);
});
test("clicking on tracked link", async function (assert) {
await visit("/t/280");
await click(".sidebar-section-community .sidebar-section-link-tracked");
assert.strictEqual(
currentURL(),
"/latest?f=tracked",
"it should transition to the tracked url"
);
assert.strictEqual(
count(".sidebar-section-community .sidebar-section-link.active"),
1,
"only one link is marked as active"
);
assert.ok(
exists(".sidebar-section-community .sidebar-section-link-tracked.active"),
"the tracked link is marked as active"
);
});
test("clicking on tracked link - sidebar_list_destination set to unread/new and no unread or new topics", async function (assert) {
updateCurrentUser({
sidebar_list_destination: "unread_new",
});
await visit("/t/280");
await click(".sidebar-section-community .sidebar-section-link-tracked");
assert.strictEqual(
currentURL(),
"/latest?f=tracked",
"it should transition to the latest tracked url"
);
assert.ok(
exists(".sidebar-section-community .sidebar-section-link-tracked.active"),
"the tracked link is marked as active"
);
assert.strictEqual(
count(".sidebar-section-community .sidebar-section-link.active"),
1,
"only one link is marked as active"
);
});
test("clicking on tracked link - sidebar_list_destination set to unread/new with new topics", async function (assert) {
const categories = Site.current().categories;
const category = categories.find((c) => c.id === 1001);
category.set("notification_level", NotificationLevels.TRACKING);
const topicTrackingState = this.container.lookup(
"service:topic-tracking-state"
);
topicTrackingState.states.set("t112", {
last_read_post_number: null,
id: 112,
notification_level: NotificationLevels.TRACKING,
category_id: 1001,
created_in_new_period: true,
});
updateCurrentUser({
sidebar_list_destination: "unread_new",
});
await visit("/t/280");
await click(".sidebar-section-community .sidebar-section-link-tracked");
assert.strictEqual(
currentURL(),
"/new?f=tracked",
"it should transition to the tracked new page"
);
assert.ok(
exists(".sidebar-section-community .sidebar-section-link-tracked.active"),
"the tracked link is marked as active"
);
assert.strictEqual(
count(".sidebar-section-community .sidebar-section-link.active"),
1,
"only one link is marked as active"
);
});
test("clicking on tracked link - sidebar_list_destination set to unread/new with new and unread topics", async function (assert) {
const categories = Site.current().categories;
const category = categories.find((c) => c.id === 1001);
category.set("notification_level", NotificationLevels.TRACKING);
const topicTrackingState = this.container.lookup(
"service:topic-tracking-state"
);
topicTrackingState.states.set("t112", {
last_read_post_number: null,
id: 112,
notification_level: NotificationLevels.TRACKING,
category_id: 1001,
created_in_new_period: true,
});
topicTrackingState.states.set("t113", {
last_read_post_number: 1,
highest_post_number: 2,
id: 113,
notification_level: NotificationLevels.TRACKING,
category_id: 1001,
created_in_new_period: true,
});
updateCurrentUser({
sidebar_list_destination: "unread_new",
});
await visit("/t/280");
await click(".sidebar-section-community .sidebar-section-link-tracked");
assert.strictEqual(
currentURL(),
"/unread?f=tracked",
"it should transition to the tracked unread page"
);
assert.ok(
exists(".sidebar-section-community .sidebar-section-link-tracked.active"),
"the tracked link is marked as active"
);
assert.strictEqual(
count(".sidebar-section-community .sidebar-section-link.active"),
1,
"only one link is marked as active"
);
});
test("clicking on users link", async function (assert) {
await visit("/t/280");
@ -942,51 +808,6 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) {
);
});
test("visiting top route with tracked filter", async function (assert) {
await visit("/top?f=tracked");
assert.strictEqual(
count(".sidebar-section-community .sidebar-section-link.active"),
1,
"only one link is marked as active"
);
assert.ok(
exists(".sidebar-section-community .sidebar-section-link-tracked.active"),
"the tracked link is marked as active"
);
});
test("visiting unread route with tracked filter", async function (assert) {
await visit("/unread?f=tracked");
assert.strictEqual(
count(".sidebar-section-community .sidebar-section-link.active"),
1,
"only one link is marked as active"
);
assert.ok(
exists(".sidebar-section-community .sidebar-section-link-tracked.active"),
"the tracked link is marked as active"
);
});
test("visiting new route with tracked filter", async function (assert) {
await visit("/new?f=tracked");
assert.strictEqual(
count(".sidebar-section-community .sidebar-section-link.active"),
1,
"only one link is marked as active"
);
assert.ok(
exists(".sidebar-section-community .sidebar-section-link-tracked.active"),
"the tracked link is marked as active"
);
});
test("review link is not shown when user cannot review", async function (assert) {
updateCurrentUser({ can_review: false, reviewable_count: 0 });
@ -1067,225 +888,6 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) {
);
});
test("new and unread count for tracked link", async function (assert) {
const categories = Site.current().categories;
// Category id 1001 has two subcategories
const category = categories.find((c) => c.id === 1001);
category.set("notification_level", NotificationLevels.TRACKING);
updateCurrentUser({
sidebar_list_destination: "unread_new",
});
this.container.lookup("service:topic-tracking-state").loadStates([
{
topic_id: 1,
highest_post_number: 1,
last_read_post_number: null,
created_at: "2022-05-11T03:09:31.959Z",
category_id: category.id,
notification_level: NotificationLevels.TRACKING,
created_in_new_period: true,
treat_as_new_topic_start_date: "2022-05-09T03:17:34.286Z",
},
{
topic_id: 2,
highest_post_number: 12,
last_read_post_number: 11,
created_at: "2020-02-09T09:40:02.672Z",
category_id: category.subcategories[0].id,
notification_level: NotificationLevels.TRACKING,
created_in_new_period: false,
treat_as_new_topic_start_date: "2022-05-09T03:17:34.286Z",
},
{
topic_id: 3,
highest_post_number: 12,
last_read_post_number: 11,
created_at: "2020-02-09T09:40:02.672Z",
category_id: category.subcategories[0].subcategories[0].id,
notification_level: NotificationLevels.TRACKING,
created_in_new_period: false,
treat_as_new_topic_start_date: "2022-05-09T03:17:34.286Z",
},
{
topic_id: 4,
highest_post_number: 15,
last_read_post_number: 14,
created_at: "2021-06-14T12:41:02.477Z",
category_id: 3,
notification_level: NotificationLevels.TRACKING,
created_in_new_period: false,
treat_as_new_topic_start_date: "2022-05-09T03:17:34.286Z",
},
{
topic_id: 5,
highest_post_number: 1,
last_read_post_number: null,
created_at: "2021-06-14T12:41:02.477Z",
category_id: 3,
notification_level: null,
created_in_new_period: true,
treat_as_new_topic_start_date: "2022-05-09T03:17:34.286Z",
},
{
topic_id: 6,
highest_post_number: 17,
last_read_post_number: 16,
created_at: "2020-10-31T03:41:42.257Z",
category_id: 1234,
notification_level: NotificationLevels.TRACKING,
created_in_new_period: false,
treat_as_new_topic_start_date: "2022-05-09T03:17:34.286Z",
tags: ["tag3"],
},
]);
await visit("/");
assert.strictEqual(
query(
".sidebar-section-link-tracked .sidebar-section-link-content-badge"
).textContent.trim(),
"3 unread",
"it displays the right unread count"
);
// simulate reading topic id 2
await publishToMessageBus("/unread", {
topic_id: 2,
message_type: "read",
payload: {
last_read_post_number: 12,
highest_post_number: 12,
},
});
assert.strictEqual(
query(
".sidebar-section-link-tracked .sidebar-section-link-content-badge"
).textContent.trim(),
"2 unread",
"it updates the unread count"
);
// simulate reading topic id 3
await publishToMessageBus("/unread", {
topic_id: 3,
message_type: "read",
payload: {
last_read_post_number: 17,
highest_post_number: 17,
},
});
// simulate reading topic id 6
await publishToMessageBus("/unread", {
topic_id: 6,
message_type: "read",
payload: {
last_read_post_number: 17,
highest_post_number: 17,
},
});
assert.strictEqual(
query(
".sidebar-section-link-tracked .sidebar-section-link-content-badge"
).textContent.trim(),
"1 new",
"it displays the new count once there are no tracked unread topics"
);
// simulate reading topic id 1
await publishToMessageBus("/unread", {
topic_id: 1,
message_type: "read",
payload: {
last_read_post_number: 1,
highest_post_number: 1,
},
});
assert.ok(
!exists(
".sidebar-section-link-tracked .sidebar-section-link-content-badge"
),
"it removes new count once there are no tracked new topics"
);
});
test("show suffix indicator for new content on tracked link", async function (assert) {
const categories = Site.current().categories;
// Category id 1001 has two subcategories
const category = categories.find((c) => c.id === 1001);
category.set("notification_level", NotificationLevels.TRACKING);
updateCurrentUser({
sidebar_list_destination: "default",
});
this.container.lookup("service:topic-tracking-state").loadStates([
{
topic_id: 1,
highest_post_number: 1,
last_read_post_number: null,
created_at: "2022-05-11T03:09:31.959Z",
category_id: category.id,
notification_level: NotificationLevels.TRACKING,
created_in_new_period: true,
treat_as_new_topic_start_date: "2022-05-09T03:17:34.286Z",
},
{
topic_id: 2,
highest_post_number: 12,
last_read_post_number: 11,
created_at: "2020-02-09T09:40:02.672Z",
category_id: category.subcategories[0].id,
notification_level: NotificationLevels.TRACKING,
created_in_new_period: false,
treat_as_new_topic_start_date: "2022-05-09T03:17:34.286Z",
},
]);
await visit("/");
assert.ok(
exists(".sidebar-section-link-tracked .sidebar-section-link-suffix")
);
// simulate reading topic id 2
await publishToMessageBus("/unread", {
topic_id: 2,
message_type: "read",
payload: {
last_read_post_number: 12,
highest_post_number: 12,
},
});
assert.ok(
exists(".sidebar-section-link-tracked .sidebar-section-link-suffix")
);
// simulate reading topic id 1
await publishToMessageBus("/unread", {
topic_id: 1,
message_type: "read",
payload: {
last_read_post_number: 1,
highest_post_number: 1,
},
});
assert.ok(
!exists(".sidebar-section-link-tracked .sidebar-section-link-suffix"),
"it removes the suffix indicator if there are no tracked new topics"
);
});
test("adding section link via plugin API with Object", async function (assert) {
withPluginApi("1.2.0", (api) => {
api.addCommunitySectionLink({

View File

@ -4238,9 +4238,6 @@ en:
title: "All topics"
faq:
content: "FAQ"
tracked:
content: "Tracked"
title: "All tracked topics"
groups:
content: "Groups"
title: "All groups"