Skip to content

Commit

Permalink
Merge branch '6.0/main-menu-callback'
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnavy committed Jan 13, 2025
2 parents ae78d9e + b9ae0bb commit d13d0e0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
15 changes: 15 additions & 0 deletions devel/docs/UPGRADING-6.0
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,21 @@ In addition to the above, the following callbacks changed or moved in RT 6.

=over

=item /Elements/Tabs Privileged and and SelfService

These callbacks are used to modify RT's top menu and page menu, usually to
add new things to the menus. The previous callbacks are still available,
but RT no longer rebuilds the top navigation menu on every request. If you
previously used one of these callbacks to modify the top navigation menu
via C<Menu()>, that will no longer be defined or updated consistently in
the existing callbacks.

To add items to the main page menu, you can use two new callbacks added
for this purpose:

/Elements/Header PrivilegedMainNav
/Elements/Header SelfServiceMainNav

=item /Prefs/Other.html BeforeOption

This callback is still in the same location on the rendered page, but it has
Expand Down
11 changes: 9 additions & 2 deletions lib/RT/Interface/Web/MenuBuilder.pm
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ sub QueryString { HTML::Mason::Commands::QueryString( @_ ); }
sub ShortenSearchQuery { HTML::Mason::Commands::ShortenSearchQuery( @_ ); }

sub BuildMainNav {
my $top = shift;
my $top = shift;
my %args = @_;

my $current_user = $HTML::Mason::Commands::session{CurrentUser};

Expand Down Expand Up @@ -347,6 +348,9 @@ sub BuildMainNav {
if ( $current_user->Name ) {
$about_me->child( logout => title => loc('Logout'), path => '/NoAuth/Logout.html' );
}

# Added in RT6 to handle main menu changes
$HTML::Mason::Commands::m->callback( CallbackName => 'PrivilegedMainNav', ARGSRef => \%args, CallbackPage => '/Elements/Header' );
}

sub BuildPageNav {
Expand Down Expand Up @@ -1962,7 +1966,8 @@ sub _BuildAdminPageMenu {
}

sub BuildSelfServiceMainNav {
my $top = shift;
my $top = shift;
my %args = @_;

my $current_user = $HTML::Mason::Commands::session{CurrentUser};

Expand Down Expand Up @@ -2023,6 +2028,8 @@ sub BuildSelfServiceMainNav {
$about_me->child( logout => title => loc('Logout'), path => '/NoAuth/Logout.html' );
}

# Added in RT6 to handle main menu changes
$HTML::Mason::Commands::m->callback( CallbackName => 'SelfServiceMainNav', ARGSRef => \%args, CallbackPage => '/Elements/Header' );
}

sub BuildSelfServicePageNav {
Expand Down
4 changes: 2 additions & 2 deletions share/html/Elements/Header
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,10 @@ if ( $session{CurrentUser} && $session{CurrentUser}->Id ) {

require RT::Interface::Web::MenuBuilder;
if ( $request_path =~ m{^/SelfService/} ) {
RT::Interface::Web::MenuBuilder::BuildSelfServiceMainNav( Menu() );
RT::Interface::Web::MenuBuilder::BuildSelfServiceMainNav( Menu(), %ARGS );
}
else {
RT::Interface::Web::MenuBuilder::BuildMainNav( Menu() );
RT::Interface::Web::MenuBuilder::BuildMainNav( Menu(), %ARGS );
}

my $app_overflow = Menu()->child( overflow => title => loc('More'), sort_order => 99999);
Expand Down

0 comments on commit d13d0e0

Please sign in to comment.