FIX: Do not double-highlight admin plugin links in sidebar (#25808)

I was using adminPlugins instead of adminPlugins.index for the Installed Plugins
link in admin sidebar, which was causing Ember to highlight the main link and a plugin
link at the same time.

We only want to highlight the top level Installed Plugins link if we are on that page,
not if we are on e.g. the chat plugin admin route.
This commit is contained in:
Martin Brennan 2024-02-23 09:56:17 +10:00 committed by GitHub
parent b64a58071d
commit 1ad8e85b37
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 5 deletions

View File

@ -3,12 +3,11 @@ import getURL from "discourse-common/lib/get-url";
export const ADMIN_NAV_MAP = [ export const ADMIN_NAV_MAP = [
{ {
name: "plugins", name: "plugins",
route: "adminPlugins.index",
label: "admin.plugins.title", label: "admin.plugins.title",
links: [ links: [
{ {
name: "admin_installed_plugins", name: "admin_installed_plugins",
route: "adminPlugins", route: "adminPlugins.index",
label: "admin.plugins.installed", label: "admin.plugins.installed",
icon: "puzzle-piece", icon: "puzzle-piece",
}, },

View File

@ -90,7 +90,9 @@ function defineAdminSection(adminNavSectionData) {
get links() { get links() {
return this.sectionLinks.map( return this.sectionLinks.map(
(sectionLinkData) => (sectionLinkData) =>
new SidebarAdminSectionLink({ adminSidebarNavLink: sectionLinkData }) new SidebarAdminSectionLink({
adminSidebarNavLink: sectionLinkData,
})
); );
} }
@ -216,8 +218,12 @@ export default class AdminSidebarPanel extends BaseCustomSidebarPanel {
@cached @cached
get sections() { get sections() {
const currentUser = getOwnerWithFallback().lookup("service:current-user"); const currentUser = getOwnerWithFallback(this).lookup(
const siteSettings = getOwnerWithFallback().lookup("service:site-settings"); "service:current-user"
);
const siteSettings = getOwnerWithFallback(this).lookup(
"service:site-settings"
);
if (!currentUser.use_admin_sidebar) { if (!currentUser.use_admin_sidebar) {
return []; return [];
} }