Skip to content

Commit

Permalink
Merge branch 'hotfix-1.0.13' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
DominicWatson committed Dec 11, 2024
2 parents 2db5418 + 464af85 commit 4caddcc
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 20 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## v1.0.13

* ADMINTHEME-54 - Top navigation menu: increasingly slow to load on every request


## v1.0.12

* Fix issue with display of rules condition types in Rules engine admin area > Create new condition button
Expand Down
19 changes: 19 additions & 0 deletions assets/js/admin/specific/adminTopNav/adminTopNavActiveItem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
( function( $ ){

var $topNav = $( "#topLevelNav" );

if ( $topNav.length ) {
var activeItemId = $topNav.data( "activeItem" );

if ( typeof activeItemId !== "undefined" && activeItemId.length ) {
var item = $topNav.find( "[data-item-id=" + activeItemId + "]:first" );

if ( item.length ) {
item.addClass( "active" ).parents( "li" ).addClass( "active" ).each( function(){
$( this ).find( "a:first" ).addClass( "active" );
} );
}
}
}

} )( presideJQuery );
24 changes: 24 additions & 0 deletions handlers/admin/Layout.cfc
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
component {

property name="navItems" inject="coldbox:setting:admin.topNavItems";
property name="adminMenuItemService" inject="adminMenuItemService";

public string function renderAdminSidebar( event, rc, prc, args={} ) {
var adminSidebarItems = prc.adminSidebarItems ?: [];
var adminSidebarHeader = prc.adminSidebarHeader ?: "";
Expand All @@ -17,4 +20,25 @@ component {
return renderView( view="admin/layout/adminSidebar", args={ sidebarMenu=renderedSidebarMenu, header=adminSidebarHeader } );
}

private string function topNavItems( event, rc, prc, args={} ) {
var supportCache = StructKeyExists( adminMenuItemService, "getActiveItemForRequest" );
var suffix = supportCache ? ( args.cacheSuffix ?: event.getAdminUserId() ) : "";

args.menu = renderViewlet( event="admin.layout.adminMenu", cache=supportCache, cacheProvider="adminMenuCache", cacheSuffix=suffix, args={
menuItems = navItems
, legacyViewBase = "/admin/util/topNav/"
, itemRenderer = "/admin/util/topNav/_item"
, subItemRenderer = "/admin/layout/topnav/_subitem"
, runActiveChecks = false
} );

if ( Len( args.menu ) ) {
args.activeItem = supportCache ? adminMenuItemService.getActiveItemForRequest( navItems ) : "";

return renderView( view="/admin/util/topNavItems", args=args );
}

return "";
}

}
18 changes: 18 additions & 0 deletions interceptors/AltAdminThemeInterceptors.cfc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
component extends="coldbox.system.Interceptor" {

property name="adminNavMenuCache" inject="cachebox:adminMenuCache";

// PUBLIC
public void function configure() {}

Expand All @@ -25,4 +27,20 @@ component extends="coldbox.system.Interceptor" {
}
}
}

public void function postUpdateObjectData( event, interceptData ) {
if ( ( arguments.interceptData.objectName == "security_user" && StructKeyExists( interceptData.data, "groups" ) ) || arguments.interceptData.objectName == "security_group" ) {
adminNavMenuCache.clearAll();
}
}
public void function postInsertObjectData( event, interceptData ) {
if ( arguments.interceptData.objectName == "security_group" ) {
adminNavMenuCache.clearAll();
}
}
public void function postDeleteObjectData( event, interceptData ) {
if ( arguments.interceptData.objectName == "security_group" ) {
adminNavMenuCache.clearAll();
}
}
}
8 changes: 4 additions & 4 deletions views/admin/util/topNav.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
cacheSuffix = cacheSuffix( event, args );
}
topLevelNav = renderView( view="/admin/util/topNavItems" );
userMenu = renderView( view="/admin/util/userMenu", cache=true, cacheSuffix=cacheSuffix );
applicationNav = renderViewlet( event="admin.layout.applicationNav", cache=true, cacheSuffix=cacheSuffix );
systemMenu = renderView( view="/admin/util/topnav/system", cache=true, cacheSuffix=cacheSuffix );
topLevelNav = renderViewlet( event="admin.layout.topNavItems", args={ cacheSuffix=cacheSuffix } );
userMenu = renderView( view="/admin/util/userMenu", cache=true, cacheSuffix=cacheSuffix, cacheProvider="adminMenuCache" );
applicationNav = renderViewlet( event="admin.layout.applicationNav", cache=true, cacheSuffix=cacheSuffix, cacheProvider="adminMenuCache" );
systemMenu = renderView( view="/admin/util/topnav/system", cache=true, cacheSuffix=cacheSuffix, cacheProvider="adminMenuCache");
notificationsMenu = renderViewlet( "admin.notifications.notificationNavPromo" );
systemAlertsMenu = renderViewlet( "admin.systemAlerts.systemAlertsMenuItem" );
sitePicker = isFeatureEnabled( "siteSwitcher" ) ? renderViewlet( "admin.sites.sitePicker" ) : "";
Expand Down
7 changes: 4 additions & 3 deletions views/admin/util/topNav/_item.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
itemIcon = args.itemIcon ?: ( args.icon ?: "" );
itemLink = args.itemLink ?: ( args.link ?: "" );
itemTitle = args.itemTitle ?: ( args.title ?: "" );
itemid = args.itemId ?: ( args.id ?: "" );
subMenu = args.subMenu ?: "";
subitems = args.subitems ?: ( args.subMenuItems ?: [] );
showMenuIcons = IsTrue( getSetting( "admin.topNavMenuIcons" ) );
Expand All @@ -14,7 +15,7 @@
<cfif !separator>
<cfif !hasSubmenu>
<cfif len( trim( itemLink ) )>
<li class="#itemClass#">
<li class="#itemClass#" data-item-id="#EncodeForHtmlAttribute( itemid )#">
<a href="#itemLink#"<cfif active> class="active"</cfif>>
<cfif showMenuIcons && Len( Trim( itemIcon ) )>
<i class="fa fa-fw #itemIcon#"></i>&nbsp;
Expand All @@ -24,7 +25,7 @@
</li>
</cfif>
<cfelse>
<li class="#itemClass#">
<li class="#itemClass#" data-item-id="#itemid#">
<a href="##" data-toggle="preside-dropdown" class="dropdown-toggle<cfif active> active</cfif>">
<cfif showMenuIcons && Len( Trim( itemIcon ) )>
<i class="fa fa-fw #itemIcon#"></i>&nbsp;
Expand All @@ -41,7 +42,7 @@
<li class="spacer"><hr></li>
<cfelse>
<li>
<a href="#item.link#">
<a href="#item.link#" data-item-id="#EncodeForHtmlAttribute( item.id ?: '' )#">
<cfif Len( Trim( item.icon ?: "" ) )>
<i class="fa fa-fw #item.icon#"></i>&nbsp;
</cfif>
Expand Down
24 changes: 11 additions & 13 deletions views/admin/util/topNavItems.cfm
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
<cfscript>
settingsMenu = renderViewlet( event="admin.layout.adminMenu", args={
menuItems = getSetting( "admin.topNavItems" )
, legacyViewBase = "/admin/util/topNav/"
, itemRenderer = "/admin/util/topNav/_item"
, subItemRenderer = "/admin/layout/topnav/_subitem"
} );
menu = args.menu ?: "";
activeItem = args.activeItem ?: "";
if ( Len( activeItem ) ) {
event.include( "/js/admin/specific/adminTopNav/" );
}
</cfscript>


<cfoutput>
<cfif Len( Trim( settingsMenu ) )>
<div id="topLevelNav" class="navbar-header pull-left btn-group mobile-nav">
<ul class="nav ace-nav">
#settingsMenu#
</ul>
</div>
</cfif>
<div id="topLevelNav" class="navbar-header pull-left btn-group mobile-nav" data-active-item="#activeItem#">
<ul class="nav ace-nav">
#menu#
</ul>
</div>
</cfoutput>

0 comments on commit 4caddcc

Please sign in to comment.