[Rt-commit] rt branch 5.0/improve-menu-active-check created. rt-5.0.2-36-g38b51c4acd
BPS Git Server
git at git.bestpractical.com
Fri Nov 5 20:09:51 UTC 2021
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".
The branch, 5.0/improve-menu-active-check has been created
at 38b51c4acd9e36d31de319702766c3ccdfc75974 (commit)
- Log -----------------------------------------------------------------
commit 38b51c4acd9e36d31de319702766c3ccdfc75974
Author: sunnavy <sunnavy at bestpractical.com>
Date: Sat Nov 6 02:07:53 2021 +0800
Test active search page menus
diff --git a/t/web/search_tabs.t b/t/web/search_tabs.t
index b679eafcac..17620bbe6f 100644
--- a/t/web/search_tabs.t
+++ b/t/web/search_tabs.t
@@ -2,7 +2,7 @@ use strict;
use warnings;
-use RT::Test tests => 21;
+use RT::Test tests => undef;
my ($baseurl, $agent) = RT::Test->started_ok;
my $ticket = RT::Ticket->new(RT->SystemUser);
@@ -84,3 +84,22 @@ $agent->text_contains('id = 1 OR id = 2 OR id = 3');
$agent->form_name('SaveSearch');
is($agent->value('SavedSearchDescription'), 'this is my saved chart');
+for my $tab ( qw/edit_search advanced results bulk chart/ ) {
+ $agent->follow_link_ok( { id => "page-$tab" } );
+ ok( $agent->dom->at("#li-page-$tab.active"), "Tab $tab is active" );
+}
+
+$agent->follow_link_ok( { id => 'search-assets-assetsql' } );
+$agent->submit_form_ok(
+ { form_name => 'BuildQuery',
+ fields => { ValueOfCatalog => 'General assets' }
+ },
+ 'Create an asset search'
+);
+
+for my $tab ( qw/edit_search advanced results bulk/ ) {
+ $agent->follow_link_ok( { id => "page-$tab" } );
+ ok( $agent->dom->at("#li-page-$tab.active"), "Tab $tab is active" );
+}
+
+done_testing;
commit 59adb9844342a83041a04e41fe54516447d2b1b6
Author: sunnavy <sunnavy at bestpractical.com>
Date: Sat Nov 6 02:46:50 2021 +0800
Add more fields to asset bulk to make generated menu links more consistently
This is to mark "Bulk Update" menu active when navigating from other
asset search pages.
diff --git a/lib/RT/Interface/Web/MenuBuilder.pm b/lib/RT/Interface/Web/MenuBuilder.pm
index 0e4e00cc92..8ebb11399c 100644
--- a/lib/RT/Interface/Web/MenuBuilder.pm
+++ b/lib/RT/Interface/Web/MenuBuilder.pm
@@ -844,7 +844,7 @@ sub BuildMainNav {
map {
my $p = $_;
$p => $HTML::Mason::Commands::DECODED_ARGS->{$p} || $current_search->{$p}
- } qw(Query Format OrderBy Order Page)
+ } qw(Query Format OrderBy Order Page ObjectType SavedChartSearchId ResultPage ExtraQueryParams)
),
);
commit 12dbcd3765b509edebeb677af9dab35b61764bc9
Author: sunnavy <sunnavy at bestpractical.com>
Date: Sat Nov 6 01:12:33 2021 +0800
Set default Page parameter to make generated menu links more consistently
Search menu links have Page setting to 1 on search results page by
default, which is empty on other search pages.
This commit sets it to 1, so the "Show Results" page menu could be
marked active if you navigate to it from other search pages like "Edit
Search", "Advanced", etc.
diff --git a/lib/RT/Interface/Web/MenuBuilder.pm b/lib/RT/Interface/Web/MenuBuilder.pm
index 6d42200acb..0e4e00cc92 100644
--- a/lib/RT/Interface/Web/MenuBuilder.pm
+++ b/lib/RT/Interface/Web/MenuBuilder.pm
@@ -634,6 +634,7 @@ sub BuildMainNav {
$fallback_query_args{Class} ||= $class;
$fallback_query_args{ObjectType} ||= 'RT::Ticket' if $class eq 'RT::Transactions';
+ $fallback_query_args{Page} ||= 1;
if ($query_string) {
$args = '?' . $query_string;
commit 5074925db52fcf3698680a85e5000aa7fd8fe3f2
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri Nov 5 23:03:59 2021 +0800
Check URI equality a bit more loosely for menu's active check
This is initally to fix active page menus like "Edit Search" on search
pages. Previously even if the URL in browser is the same as the page
menu, the page menu wouldn't be active(shown as bold).
There are 3 different ways to genearte URI: CGI, URI and manually. URI
strings they generate could be different in character perspective but
actually identical in URI perspective, and the difference is mainly in
the query part.
E.g.
* Delimiter
CGI uses ";" and URI uses "&"
We can customize it via $URI::DEFAULT_QUERY_FORM_DELIMITER in URI, but
sadly delimiter is not the only difference.
* Space in query value
CGI uses "%20" and URI uses "+"
We are comparing difference resources(the one from CGI and the other
from URI or manual) when determining if one menu is active or not. This
commit compares them using clean URI objects, to eliminate the chaos
above.
See also 07c22ca552, which is an earlier attempt but not complete.
diff --git a/lib/RT/Interface/Web/Menu.pm b/lib/RT/Interface/Web/Menu.pm
index 2bbba75e13..2d34ac6a06 100644
--- a/lib/RT/Interface/Web/Menu.pm
+++ b/lib/RT/Interface/Web/Menu.pm
@@ -238,17 +238,9 @@ sub child {
if ( defined $path and length $path ) {
my $base_path = $HTML::Mason::Commands::r->path_info;
my $query = $HTML::Mason::Commands::m->cgi_object->query_string;
- $base_path =~ s!/+!/!g;
$base_path .= "?$query" if defined $query and length $query;
- $base_path =~ s/index\.html$//;
- $base_path =~ s/\/+$//;
- $path =~ s/index\.html$//;
- $path =~ s/\/+$//;
-
- require URI::Escape;
- $base_path = URI::Escape::uri_unescape($base_path);
- if ( $path eq $base_path ) {
+ if ( RT::Util::uri_eq($base_path, $path) ) {
$self->{children}{$key}->active(1);
}
}
diff --git a/lib/RT/Util.pm b/lib/RT/Util.pm
index 2b2d2650fb..ed5ccdd322 100644
--- a/lib/RT/Util.pm
+++ b/lib/RT/Util.pm
@@ -215,6 +215,43 @@ sub constant_time_eq {
return 0 + not $result;
}
+=head2 uri_eq STRING1 STRING2
+
+Compares two strings for equality in the perspective of URI.
+
+=cut
+
+sub uri_eq {
+ return 0 unless @_ >= 2;
+
+ require URI;
+ my $first_uri;
+ for my $item (@_) {
+
+ # Clean up
+ $item =~ s!/{2,}!/!g;
+ $item =~ s/index\.html$//;
+ $item =~ s/\/+$//;
+
+ # Get query data
+ my $base = URI->new($item);
+ my @query_form = $base->query_form;
+
+ # Initialize a new object to not inherit query convention of original
+ # string, like ";" VS "&" and "+" VS " ".
+ $base->query_form( {} );
+ my $uri = URI->new($base);
+ $uri->query_form(@query_form);
+ if (defined $first_uri) {
+ return $first_uri eq $uri;
+ }
+ else {
+ $first_uri = $uri;
+ }
+ }
+ return 1;
+}
+
=head2 EntityLooksLikeEmailMessage( MIME::Entity )
Check MIME type headers for entities that look like email.
-----------------------------------------------------------------------
hooks/post-receive
--
rt
More information about the rt-commit
mailing list