From e3501a207fac8fd6cf2b62c2b36a5c58908184ad Mon Sep 17 00:00:00 2001 From: Alan Guo Xiang Tan Date: Tue, 23 Aug 2022 15:42:48 +0800 Subject: [PATCH] UX: Add badges section link to community section. (#18044) We have a link to /badges in the old hamburger dropdown so maintaining parity here. --- .../sidebar/user/community-section.js | 7 ++++++- .../community-section/badges-section-link.js | 21 +++++++++++++++++++ .../sidebar-user-community-section-test.js | 16 ++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 app/assets/javascripts/discourse/app/lib/sidebar/user/community-section/badges-section-link.js 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.js index 175ad40812f..c219723f585 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 @@ -14,6 +14,7 @@ import UsersSectionLink from "discourse/lib/sidebar/user/community-section/users import AboutSectionLink from "discourse/lib/sidebar/user/community-section/about-section-link"; import FAQSectionLink from "discourse/lib/sidebar/user/community-section/faq-section-link"; import AdminSectionLink from "discourse/lib/sidebar/user/community-section/admin-section-link"; +import BadgesSectionLink from "discourse/lib/sidebar/user/community-section/badges-section-link"; import { inject as service } from "@ember/service"; import { action } from "@ember/object"; @@ -27,7 +28,11 @@ const MAIN_SECTION_LINKS = [ const ADMIN_MAIN_SECTION_LINKS = [AdminSectionLink]; -const MORE_SECTION_LINKS = [GroupsSectionLink, UsersSectionLink]; +const MORE_SECTION_LINKS = [ + GroupsSectionLink, + UsersSectionLink, + BadgesSectionLink, +]; const MORE_SECONDARY_SECTION_LINKS = [AboutSectionLink, FAQSectionLink]; export default class SidebarUserCommunitySection extends Component { diff --git a/app/assets/javascripts/discourse/app/lib/sidebar/user/community-section/badges-section-link.js b/app/assets/javascripts/discourse/app/lib/sidebar/user/community-section/badges-section-link.js new file mode 100644 index 00000000000..2db8d3575b0 --- /dev/null +++ b/app/assets/javascripts/discourse/app/lib/sidebar/user/community-section/badges-section-link.js @@ -0,0 +1,21 @@ +import I18n from "I18n"; + +import BaseSectionLink from "discourse/lib/sidebar/user/community-section/base-section-link"; + +export default class BadgesSectionLink extends BaseSectionLink { + get name() { + return "badges"; + } + + get route() { + return "badges"; + } + + get title() { + return I18n.t("badges.title"); + } + + get text() { + return I18n.t("badges.title"); + } +} 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.js index a71ae4e68c9..9c6e58d4afa 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 @@ -229,6 +229,22 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { ); }); + test("clicking on badges link", async function (assert) { + await visit("/"); + + await click( + ".sidebar-section-community .sidebar-more-section-links-details-summary" + ); + + await click(".sidebar-section-community .sidebar-section-link-badges"); + + assert.strictEqual( + currentURL(), + "/badges", + "it should transition to the badges url" + ); + }); + test("clicking on groups link", async function (assert) { await visit("/t/280");