FEATURE: Add users and groups links to community section in sidebar (#17609)

This commit is contained in:
Alan Guo Xiang Tan 2022-07-22 16:00:06 +08:00 committed by GitHub
parent b4b339b059
commit 49d4f7c066
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 96 additions and 0 deletions

View File

@ -6,6 +6,8 @@ import { customSectionLinks } from "discourse/lib/sidebar/custom-community-secti
import 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,
];

View File

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

View File

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

View File

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

View File

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