mirror of
https://github.com/discourse/discourse.git
synced 2025-03-23 08:39:26 +08:00
FIX: Do not show edit sections button on admin sidebar (#26547)
Sections cannot be created or edited or deleted in the admin sidebar. Also move the footer component into a gjs file.
This commit is contained in:
parent
fbfeb5d6d0
commit
fb5ae16630
@ -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);
|
||||
}
|
||||
|
||||
<template>
|
||||
<div class="sidebar-footer-wrapper">
|
||||
<div class="sidebar-footer-container">
|
||||
<div class="sidebar-footer-actions">
|
||||
<PluginOutlet @name="sidebar-footer-actions" />
|
||||
|
||||
{{#if this.showManageSectionsButton}}
|
||||
<DButton
|
||||
@icon="plus"
|
||||
@action={{this.manageSections}}
|
||||
@title="sidebar.sections.custom.add"
|
||||
class="btn-flat sidebar-footer-actions-button add-section"
|
||||
/>
|
||||
{{/if}}
|
||||
|
||||
{{#if this.showToggleMobileButton}}
|
||||
<DButton
|
||||
@action={{routeAction "toggleMobileView"}}
|
||||
@title={{if this.site.mobileView "desktop_view" "mobile_view"}}
|
||||
@icon={{if this.site.mobileView "desktop" "mobile-alt"}}
|
||||
class="btn-flat sidebar-footer-actions-button sidebar-footer-actions-toggle-mobile-view"
|
||||
/>
|
||||
{{/if}}
|
||||
|
||||
{{#if this.showKeyboardShortcutsButton}}
|
||||
<DButton
|
||||
@action={{routeAction "showKeyboardShortcutsHelp"}}
|
||||
@title="keyboard_shortcuts_help.title"
|
||||
@icon="keyboard"
|
||||
class="btn-flat sidebar-footer-actions-button sidebar-footer-actions-keyboard-shortcuts"
|
||||
/>
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
<div class="sidebar-footer-wrapper">
|
||||
<div class="sidebar-footer-container">
|
||||
<div class="sidebar-footer-actions">
|
||||
<PluginOutlet @name="sidebar-footer-actions" />
|
||||
|
||||
{{#if this.currentUser}}
|
||||
<DButton
|
||||
@icon="plus"
|
||||
@action={{this.addSection}}
|
||||
@title="sidebar.sections.custom.add"
|
||||
class="btn-flat sidebar-footer-actions-button add-section"
|
||||
/>
|
||||
{{/if}}
|
||||
|
||||
{{#if
|
||||
(or
|
||||
this.site.mobileView
|
||||
(and this.siteSettings.enable_mobile_theme this.capabilities.touch)
|
||||
)
|
||||
}}
|
||||
<DButton
|
||||
@action={{route-action "toggleMobileView"}}
|
||||
@title={{if this.site.mobileView "desktop_view" "mobile_view"}}
|
||||
@icon={{if this.site.mobileView "desktop" "mobile-alt"}}
|
||||
class="btn-flat sidebar-footer-actions-button sidebar-footer-actions-toggle-mobile-view"
|
||||
/>
|
||||
{{/if}}
|
||||
|
||||
{{#if this.site.desktopView}}
|
||||
<DButton
|
||||
@action={{route-action "showKeyboardShortcutsHelp"}}
|
||||
@title="keyboard_shortcuts_help.title"
|
||||
@icon="keyboard"
|
||||
class="btn-flat sidebar-footer-actions-button sidebar-footer-actions-keyboard-shortcuts"
|
||||
/>
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -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);
|
||||
}
|
||||
}
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user