From 36c3a2422b9e52361e3310440e8c977d1663d8d5 Mon Sep 17 00:00:00 2001 From: Kris Date: Wed, 3 May 2023 19:26:00 -0400 Subject: [PATCH] UX: in sidebar dropdown mode expose 'more' items (#21372) --- .../sidebar/common/community-section.hbs | 17 +++++++++++++---- .../sidebar/common/community-section.js | 8 ++++++++ .../tests/acceptance/sidebar-user-test.js | 15 +++++++++++++++ 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/discourse/app/components/sidebar/common/community-section.hbs b/app/assets/javascripts/discourse/app/components/sidebar/common/community-section.hbs index 0419787e963..a67e9322731 100644 --- a/app/assets/javascripts/discourse/app/components/sidebar/common/community-section.hbs +++ b/app/assets/javascripts/discourse/app/components/sidebar/common/community-section.hbs @@ -33,8 +33,17 @@ /> {{/each}} - + {{#if this.isDesktopDropdownMode}} + {{#each this.moreSectionLinks as |sectionLink|}} + + {{/each}} + {{#each this.moreSecondarySectionLinks as |sectionLink|}} + + {{/each}} + {{else}} + + {{/if}} \ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/components/sidebar/common/community-section.js b/app/assets/javascripts/discourse/app/components/sidebar/common/community-section.js index 3def2b04809..968b991b358 100644 --- a/app/assets/javascripts/discourse/app/components/sidebar/common/community-section.js +++ b/app/assets/javascripts/discourse/app/components/sidebar/common/community-section.js @@ -12,6 +12,7 @@ export default class SidebarCommunitySection extends Component { @service topicTrackingState; @service currentUser; @service appEvents; + @service site; @service siteSettings; @tracked sectionLinks; @@ -77,6 +78,13 @@ export default class SidebarCommunitySection extends Component { return []; } + get isDesktopDropdownMode() { + const headerDropdownMode = + this.siteSettings.navigation_menu === "header dropdown"; + + return !this.site.mobileView && headerDropdownMode; + } + #initializeSectionLinks(sectionLinkClasses, { inMoreDrawer } = {}) { return sectionLinkClasses.map((sectionLinkClass) => { return this.#initializeSectionLink(sectionLinkClass, inMoreDrawer); diff --git a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-test.js b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-test.js index 0367c0a47a6..1e57f780c42 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-test.js @@ -51,6 +51,21 @@ acceptance( "hides the sidebar dropdown" ); }); + + test("'more' dropdown should display as regular list items in header dropdown mode", async function (assert) { + await visit("/"); + await click(".hamburger-dropdown"); + + assert.ok( + exists("[data-link-name='admin']"), + "the admin link is not within the 'more' dropdown" + ); + + assert.notOk( + exists(".sidebar-more-section-links-details-summary"), + "the 'more' dropdown should not be present in header dropdown mode" + ); + }); } );