From 1ad8e85b37e0924afadbfb3629bbc8ed34ad67b9 Mon Sep 17 00:00:00 2001 From: Martin Brennan Date: Fri, 23 Feb 2024 09:56:17 +1000 Subject: [PATCH] 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. --- .../discourse/app/lib/sidebar/admin-nav-map.js | 3 +-- .../discourse/app/lib/sidebar/admin-sidebar.js | 12 +++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/discourse/app/lib/sidebar/admin-nav-map.js b/app/assets/javascripts/discourse/app/lib/sidebar/admin-nav-map.js index a27d0ceba73..aaa9aec67b7 100644 --- a/app/assets/javascripts/discourse/app/lib/sidebar/admin-nav-map.js +++ b/app/assets/javascripts/discourse/app/lib/sidebar/admin-nav-map.js @@ -3,12 +3,11 @@ import getURL from "discourse-common/lib/get-url"; export const ADMIN_NAV_MAP = [ { name: "plugins", - route: "adminPlugins.index", label: "admin.plugins.title", links: [ { name: "admin_installed_plugins", - route: "adminPlugins", + route: "adminPlugins.index", label: "admin.plugins.installed", icon: "puzzle-piece", }, diff --git a/app/assets/javascripts/discourse/app/lib/sidebar/admin-sidebar.js b/app/assets/javascripts/discourse/app/lib/sidebar/admin-sidebar.js index c575aea55ac..79d26d7e3b7 100644 --- a/app/assets/javascripts/discourse/app/lib/sidebar/admin-sidebar.js +++ b/app/assets/javascripts/discourse/app/lib/sidebar/admin-sidebar.js @@ -90,7 +90,9 @@ function defineAdminSection(adminNavSectionData) { get links() { return this.sectionLinks.map( (sectionLinkData) => - new SidebarAdminSectionLink({ adminSidebarNavLink: sectionLinkData }) + new SidebarAdminSectionLink({ + adminSidebarNavLink: sectionLinkData, + }) ); } @@ -216,8 +218,12 @@ export default class AdminSidebarPanel extends BaseCustomSidebarPanel { @cached get sections() { - const currentUser = getOwnerWithFallback().lookup("service:current-user"); - const siteSettings = getOwnerWithFallback().lookup("service:site-settings"); + const currentUser = getOwnerWithFallback(this).lookup( + "service:current-user" + ); + const siteSettings = getOwnerWithFallback(this).lookup( + "service:site-settings" + ); if (!currentUser.use_admin_sidebar) { return []; }