diff --git a/app/assets/javascripts/discourse/app/components/sidebar/footer.gjs b/app/assets/javascripts/discourse/app/components/sidebar/footer.gjs new file mode 100644 index 00000000000..eddcb7fb13d --- /dev/null +++ b/app/assets/javascripts/discourse/app/components/sidebar/footer.gjs @@ -0,0 +1,74 @@ +import Component from "@glimmer/component"; +import { action } from "@ember/object"; +import { service } from "@ember/service"; +import DButton from "discourse/components/d-button"; +import SidebarSectionForm from "discourse/components/modal/sidebar-section-form"; +import PluginOutlet from "discourse/components/plugin-outlet"; +import routeAction from "discourse/helpers/route-action"; +import { ADMIN_PANEL } from "discourse/lib/sidebar/panels"; + +export default class SidebarFooter extends Component { + @service capabilities; + @service currentUser; + @service modal; + @service site; + @service siteSettings; + @service sidebarState; + + get showManageSectionsButton() { + return this.currentUser && !this.sidebarState.isCurrentPanel(ADMIN_PANEL); + } + + get showToggleMobileButton() { + return ( + this.site.mobileView || + (this.siteSettings.enable_mobile_theme && this.capabilities.touch) + ); + } + + get showKeyboardShortcutsButton() { + return this.site.desktopView; + } + + @action + manageSections() { + this.modal.show(SidebarSectionForm); + } + + +
+ +} diff --git a/app/assets/javascripts/discourse/app/components/sidebar/footer.hbs b/app/assets/javascripts/discourse/app/components/sidebar/footer.hbs deleted file mode 100644 index dc8da794f90..00000000000 --- a/app/assets/javascripts/discourse/app/components/sidebar/footer.hbs +++ /dev/null @@ -1,39 +0,0 @@ - \ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/components/sidebar/footer.js b/app/assets/javascripts/discourse/app/components/sidebar/footer.js deleted file mode 100644 index eebc014bd80..00000000000 --- a/app/assets/javascripts/discourse/app/components/sidebar/footer.js +++ /dev/null @@ -1,17 +0,0 @@ -import Component from "@glimmer/component"; -import { action } from "@ember/object"; -import { service } from "@ember/service"; -import SidebarSectionForm from "discourse/components/modal/sidebar-section-form"; - -export default class SidebarFooter extends Component { - @service capabilities; - @service currentUser; - @service modal; - @service site; - @service siteSettings; - - @action - addSection() { - this.modal.show(SidebarSectionForm); - } -} diff --git a/spec/system/admin_sidebar_navigation_spec.rb b/spec/system/admin_sidebar_navigation_spec.rb index 4ef77dc38f1..5ea676f599f 100644 --- a/spec/system/admin_sidebar_navigation_spec.rb +++ b/spec/system/admin_sidebar_navigation_spec.rb @@ -129,4 +129,11 @@ describe "Admin Revamp | Sidebar Navigation", type: :system do expect(links.count).to eq(1) expect(links.map(&:text)).to eq(["Installed"]) end + + it "does not show the button to customize sidebar sections, that is only supported in the main panel" do + visit("/") + expect(sidebar).to have_add_section_button + visit("/admin") + expect(sidebar).to have_no_add_section_button + end end diff --git a/spec/system/page_objects/components/navigation_menu/base.rb b/spec/system/page_objects/components/navigation_menu/base.rb index 943153f2283..5d72edeb375 100644 --- a/spec/system/page_objects/components/navigation_menu/base.rb +++ b/spec/system/page_objects/components/navigation_menu/base.rb @@ -143,7 +143,11 @@ module PageObjects end def has_no_add_section_button? - page.has_no_button?(add_section_button_text) + has_no_css?(add_section_button_css) + end + + def has_add_section_button? + has_css?(add_section_button_css) end def click_edit_categories_button @@ -195,6 +199,10 @@ module PageObjects def add_link_button_text I18n.t("js.sidebar.sections.custom.links.add") end + + def add_section_button_css + ".sidebar-footer-actions-button.add-section" + end end end end