A platform for community discussion. Free, open, simple.
FEATURE: Add users and groups links to community section in sidebar (#17609)
Alan Guo Xiang Tan49d4f7c0660e
diff --git a/app/assets/javascripts/discourse/app/components/sidebar/community-section.js b/app/assets/javascripts/discourse/app/components/sidebar/community-section.jsindex db718adcba3..c6cc1f59d67 100644--- a/app/assets/javascripts/discourse/app/components/sidebar/community-section.js+++ b/app/assets/javascripts/discourse/app/components/sidebar/community-section.js@@ -6,6 +6,8 @@ import { customSectionLinks } from "discourse/lib/sidebar/custom-community-sectiimport EverythingSectionLink from "discourse/lib/sidebar/community-section/everything-section-link";import TrackedSectionLink from "discourse/lib/sidebar/community-section/tracked-section-link";import MyPostsSectionLink from "discourse/lib/sidebar/community-section/my-posts-section-link";+import GroupsSectionLink from "discourse/lib/sidebar/community-section/groups-section-link";+import UsersSectionLink from "discourse/lib/sidebar/community-section/users-section-link";import { action } from "@ember/object";import { next } from "@ember/runloop";@@ -13,6 +15,8 @@ import { next } from "@ember/runloop";const DEFAULT_SECTION_LINKS = [EverythingSectionLink,TrackedSectionLink,+ GroupsSectionLink,+ UsersSectionLink,MyPostsSectionLink,];diff --git a/app/assets/javascripts/discourse/app/lib/sidebar/community-section/groups-section-link.js b/app/assets/javascripts/discourse/app/lib/sidebar/community-section/groups-section-link.jsnew file mode 100644index 00000000000..acd4e1f56d3--- /dev/null+++ b/app/assets/javascripts/discourse/app/lib/sidebar/community-section/groups-section-link.js@@ -0,0 +1,21 @@+import I18n from "I18n";++import BaseSectionLink from "discourse/lib/sidebar/community-section/base-section-link";++export default class GroupsSectionLink extends BaseSectionLink {+ get name() {+ return "groups";+ }++ get route() {+ return "groups";+ }++ get title() {+ return I18n.t("sidebar.sections.community.links.groups.title");+ }++ get text() {+ return I18n.t("sidebar.sections.community.links.groups.content");+ }+}diff --git a/app/assets/javascripts/discourse/app/lib/sidebar/community-section/users-section-link.js b/app/assets/javascripts/discourse/app/lib/sidebar/community-section/users-section-link.jsnew file mode 100644index 00000000000..696363c3e1b--- /dev/null+++ b/app/assets/javascripts/discourse/app/lib/sidebar/community-section/users-section-link.js@@ -0,0 +1,21 @@+import I18n from "I18n";++import BaseSectionLink from "discourse/lib/sidebar/community-section/base-section-link";++export default class UsersSectionLink extends BaseSectionLink {+ get name() {+ return "users";+ }++ get route() {+ return "users";+ }++ get title() {+ return I18n.t("sidebar.sections.community.links.users.title");+ }++ get text() {+ return I18n.t("sidebar.sections.community.links.users.content");+ }+}diff --git a/app/assets/javascripts/discourse/tests/acceptance/sidebar-community-section-test.js b/app/assets/javascripts/discourse/tests/acceptance/sidebar-community-section-test.jsindex 79619e42802..0b3df4789a1 100644--- a/app/assets/javascripts/discourse/tests/acceptance/sidebar-community-section-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/sidebar-community-section-test.js@@ -158,6 +158,50 @@ acceptance("Sidebar - Community Section", function (needs) {);});+ test("clicking on users link", async function (assert) {+ await visit("/t/280");+ await click(".sidebar-section-community .sidebar-section-link-users");++ assert.strictEqual(+ currentURL(),+ "/u?order=likes_received",+ "it should transition to the users 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-users.active"),+ "the users link is marked as active"+ );+ });++ test("clicking on groups link", async function (assert) {+ await visit("/t/280");+ await click(".sidebar-section-community .sidebar-section-link-groups");++ assert.strictEqual(+ currentURL(),+ "/g",+ "it should transition to the groups 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-groups.active"),+ "the groups link is marked as active"+ );+ });+test("clicking on my posts link", async function (assert) {await visit("/t/280");await click(".sidebar-section-community .sidebar-section-link-my-posts");diff --git a/config/locales/client.en.yml b/config/locales/client.en.ymlindex b5fb12d2061..43f663c3be8 100644--- a/config/locales/client.en.yml+++ b/config/locales/client.en.yml@@ -4107,6 +4107,12 @@ en:tracked:content: "Tracked"title: "All tracked topics"+ groups:+ content: "Groups"+ title: "All groups"+ users:+ content: "Users"+ title: "All users"my_posts:content: "My Posts"title: "My posts"