A platform for community discussion. Free, open, simple.
UX: Removed tracked section link from Community section in Sidebar (#19122)
Alan Guo Xiang Tan59e02bd210a7
diff --git a/app/assets/javascripts/discourse/app/components/sidebar/user/community-section.js b/app/assets/javascripts/discourse/app/components/sidebar/user/community-section.jsindex 1191981a203..2bcb92da48d 100644--- a/app/assets/javascripts/discourse/app/components/sidebar/user/community-section.js+++ b/app/assets/javascripts/discourse/app/components/sidebar/user/community-section.js@@ -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 SidebarCommonCommunitySget defaultMainSectionLinks() {return [EverythingSectionLink,- TrackedSectionLink,MyPostsSectionLink,AdminSectionLink,ReviewSectionLink,diff --git a/app/assets/javascripts/discourse/app/lib/sidebar/user/community-section/tracked-section-link.js b/app/assets/javascripts/discourse/app/lib/sidebar/user/community-section/tracked-section-link.jsdeleted file mode 100644index 8eaeb471295..00000000000--- a/app/assets/javascripts/discourse/app/lib/sidebar/user/community-section/tracked-section-link.js+++ /dev/null@@ -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";- }- }-}diff --git a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-community-section-test.js b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-community-section-test.jsindex 26f110febca..0b2ca1c1da3 100644--- a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-community-section-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-community-section-test.js@@ -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({diff --git a/config/locales/client.en.yml b/config/locales/client.en.ymlindex df210f42a95..864e251a45d 100644--- a/config/locales/client.en.yml+++ b/config/locales/client.en.yml@@ -4238,9 +4238,6 @@ en:title: "All topics"faq:content: "FAQ"- tracked:- content: "Tracked"- title: "All tracked topics"groups:content: "Groups"title: "All groups"