[Rt-commit] rt branch, 5.0/configurable-linked-queue-portlets, created. rt-5.0.0alpha1-33-g1dac46d192
Blaine Motsinger
blaine at bestpractical.com
Fri Mar 20 19:21:23 EDT 2020
The branch, 5.0/configurable-linked-queue-portlets has been created
at 1dac46d19246b464242eb25a50c0b5e67b7e54db (commit)
- Log -----------------------------------------------------------------
commit 53f5f995346eaf38e08970fab73ad78f11a901e6
Author: Maureen E. Mirville <maureen at bestpractical.com>
Date: Tue Aug 14 23:02:03 2018 -0400
Add a configurable queue portlet to ticket display page
RTIR Incident page displays links portlets by queue. Isolating
these portlets allows a user to view linked tickets based on the
queue and their relations on ticket display page.
diff --git a/share/html/Ticket/Elements/ShowLinkedQueues b/share/html/Ticket/Elements/ShowLinkedQueues
new file mode 100644
index 0000000000..1dc8a84a4a
--- /dev/null
+++ b/share/html/Ticket/Elements/ShowLinkedQueues
@@ -0,0 +1,165 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2018 Best Practical Solutions, LLC
+%# <sales at bestpractical.com>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+%# General Public License for more details.
+%#
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# END BPS TAGGED BLOCK }}}
+<%PERL>
+
+foreach my $queues ( @{ $portlet_config{ $queue } } ) {
+ foreach my $queue_name ( keys %{ $queues } ) {
+ my $queue_obj = RT::Queue->new( $session{ CurrentUser } );
+ my ( $ret ) = $queue_obj->Load( $queue_name );
+ unless ( $ret ) {
+ RT::Logger->error( "Couldn't load queue $queue_name" );
+ next;
+ }
+ my $link_types = $queues->{$queue_name};
+ my $query = "Queue = '$queue_name'";
+
+ my $ticket_id = $TicketObj->id;
+ if ( grep { lc $_ eq 'all' } @$link_types ) {
+ $query .= " AND ( LinkedTo = $ticket_id OR LinkedFrom = $ticket_id )";
+ }
+ else {
+ my @link_relations = map { $_ . " = $ticket_id" } @$link_types;
+ my $link_query = join( ' OR ', @link_relations );
+ if ($link_query) {
+ $query .= ' AND ( ' . $link_query . ' )';
+ }
+ else {
+ $query = 'id=0';
+ }
+ }
+
+ # create an identifiable class name for the linked queue portlet so
+ # we can specifically target it apart from ticket-info-links.
+ my $linked_queue_class = 'linked-queue';
+
+ my $query_string = $m->comp( '/Elements/QueryString', Query => $query );
+ my $title_href = RT->Config->Get( 'WebPath' ) . "/Search/Results.html?$query_string";
+ my $title_class = 'inverse';
+ my $class = 'ticket-info-links' . ' ' . $linked_queue_class;
+ my $titleright_raw = '';
+
+$m->callback( CallbackName => 'MassageTitleBox',
+ ARGSRef => \%ARGS,
+ title => \$queue_name,
+ title_href => \$title_href,
+ titleright_raw => \$titleright_raw,
+ title_class => \$title_class,
+ class => \$class,
+);
+
+</%PERL>
+
+<&| /Widgets/TitleBox,
+ title => $queue_name,
+ title_href => $title_href,
+ titleright_raw => $titleright_raw,
+ title_class => $title_class,
+ class => $class,
+&>
+
+<%PERL>
+my @queries = map { "$query AND $_" } q{Status = '__Active__'}, q{Status = '__Inactive__'};
+my @empty_messages
+ = ( loc( '(No active tickets)', $queue_name ), loc( '(No inactive tickets)', $queue_name ) );
+
+$m->callback( CallbackName => 'MassageQueries',
+ ARGSRef => \%ARGS,
+ Queue => $queue_name,
+ Queries => \@queries,
+ EmptyMessages => \@empty_messages,
+);
+
+for my $query ( @queries ) {
+ my $empty_message = shift @empty_messages;
+ my $format = $Format;
+ my $order_by = $OrderBy;
+ my $rows = $Rows;
+
+$m->callback( CallbackName => 'MassageSearchArgs',
+ ARGSRef => \%ARGS,
+ Queue => $queue_name,
+ Query => $query,
+ Format => \$format,
+ OrderBy => \$order_by,
+ Rows => \$rows,
+);
+ my $tickets = RT::Tickets->new($session{CurrentUser});
+ $tickets->FromSQL($query);
+ if ( $tickets->Count ) {
+</%PERL>
+<& /Elements/CollectionList, %ARGS,
+ Class => 'RT::Tickets',
+ Query => $query,
+ Format => $format,
+ OrderBy => $order_by,
+ Rows => $rows,
+ ShowHeader => 0,
+&>
+
+% } else {
+ <div class="empty-message"><% $empty_message %></div>
+% }
+% }
+
+</&>
+% }
+%}
+<%INIT>
+my %portlet_config = RT->Config->Get( 'LinkedQueuePortlets' );
+return unless %portlet_config;
+my $queue = $TicketObj->QueueObj->Name;
+return unless $portlet_config{ $queue };
+</%INIT>
+
+
+<%ARGS>
+$TicketObj
+$OrderBy => 'Due'
+$Rows => 8
+$Format => RT->Config->Get( 'LinkedQueuePortletFormat' )
+</%ARGS>
diff --git a/share/html/Ticket/Elements/ShowSummary b/share/html/Ticket/Elements/ShowSummary
index 0c5ffdab9b..7dbe6a2f7f 100644
--- a/share/html/Ticket/Elements/ShowSummary
+++ b/share/html/Ticket/Elements/ShowSummary
@@ -171,6 +171,13 @@ my $dates_behavior = $InlineEdit ? ($inline_edit_behavior{Dates} || $inline_edit
% }
</&>
% $m->callback( %ARGS, CallbackName => 'AfterDates' );
+% my (@extra);
+% push @extra, titleright_raw => '<a href="'. RT->Config->Get('WebPath'). '/Ticket/Graphs/index.html?id='.$Ticket->id.'">'.loc('Graph').'</a>' unless RT->Config->Get('DisableGraphViz');
+
+<& /Ticket/Elements/ShowLinkedQueues,
+ TicketObj => $Ticket,
+&>
+
<& /Ticket/Elements/ShowAssets, Ticket => $Ticket &>
<%PERL>
my $links_url = RT->Config->Get('WebPath')."/Ticket/ModifyLinks.html?id=".$Ticket->Id;
@@ -182,7 +189,6 @@ my $links_graph = '<a href="' . RT->Config->Get('WebPath') . '/Ticket/Graphs/ind
my $links_titleright = join ' ',
($links_behavior =~ /^(link|click)$/ ? ($links_inline) : ()),
(RT->Config->Get('DisableGraphViz') ? () : $links_graph);
-my @extra;
push @extra, (titleright_raw => $links_titleright) if $links_titleright;
</%PERL>
% $m->callback( %ARGS, CallbackName => 'LinksExtra', extra => \@extra );
commit 69278151487599cf3bf9d1cf8b12b905bc7818b5
Author: Maureen E. Mirville <maureen at bestpractical.com>
Date: Fri Aug 24 14:06:59 2018 -0400
Add docs for the new Linked Queue Portlets configs
diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index 9bed2dbd13..41d461fb58 100644
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -2642,6 +2642,45 @@ to the Article with that name.
Set($WikiImplicitLinks, 0);
+=item C<%LinkedQueuePortlets>
+
+If %LinkedQueuePortlets is set, new portlets will display on the ticket
+display page of each specified queue. Each portlet lists all the linked
+tickets grouped by queue name, and based on the indicated link type.
+Acceptable link types include, 'DependsOn', 'DependedOnBy', 'HasMember'
+(children), 'MemberOf' (parents), 'RefersTo', and 'ReferredToBy'.
+Additionally, the type, 'All', which lists all linked tickets by queue,
+is accepted. In the example below, portlets will be added to all tickets
+in both the General queue and the Support queue:
+
+Set( %LinkedQueuePortlets, (
+ General => [
+ { General => [ 'All' ] },
+ { Testing => [ 'HasMember', 'MemberOf', 'RefersTo' ] },
+ ],
+ Support => [
+ { General => [ 'All' ] },
+ ],
+));
+
+=cut
+
+Set( %LinkedQueuePortlets, () );
+
+=item C<$LinkedQueuePortletFormat>
+
+$LinkedQueuePortletFormat is the default format for displaying the
+list of tickets in each linked queue portlet ( %LinkedQueuePortlets
+must be enabled ).
+
+=cut
+
+Set( $LinkedQueuePortletFormat,
+ q{'<b><a href="__WebPath__/Ticket/Display.html?id=__id__">__id__</a></b>/TITLE:#',}.
+ q{'<b><a href="__WebPath__/Ticket/Display.html?id=__id__">__Subject__</a></b>/TITLE:Subject',}.
+ q{Status}
+);
+
=item C<$PreviewScripMessages>
Set C<$PreviewScripMessages> to 1 if the scrips preview on the ticket
commit 1dac46d19246b464242eb25a50c0b5e67b7e54db
Author: Blaine Motsinger <blaine at bestpractical.com>
Date: Fri Mar 20 13:46:32 2020 -0500
Add test for Linked Queue Portlets
diff --git a/t/web/linked_queue_portlets.t b/t/web/linked_queue_portlets.t
new file mode 100644
index 0000000000..6403202731
--- /dev/null
+++ b/t/web/linked_queue_portlets.t
@@ -0,0 +1,76 @@
+use strict;
+use warnings;
+
+use RT::Test tests => undef;
+use Test::Deep;
+
+my $default_linked_queue_portlets = RT->Config->Get( 'LinkedQueuePortlets' );
+cmp_deeply( $default_linked_queue_portlets, {}, 'LinkedQueuePortlets config setting is empty by default' );
+
+# create ticket in general queue
+# this ticket will display the portlet for the other queue, with the other ticket in it
+my $ticket_one = RT::Ticket->new( RT->SystemUser );
+my ( $ticket_one_id ) = $ticket_one->Create(
+ Subject => 'test ticket in General queue',
+ Queue => 'General',
+);
+ok( $ticket_one_id, 'created ticket in "General" queue' );
+
+# create test queue and test ticket in it
+my $queue_name = 'test queue';
+my $queue = RT::Queue->new( RT->SystemUser );
+my $queue_id = $queue->Create(
+ Name => $queue_name,
+ Description => $queue_name,
+);
+ok( $queue_id, 'created "test queue" queue' );
+
+my $ticket_two = RT::Ticket->new( RT->SystemUser );
+my ( $ticket_two_id ) = $ticket_two->Create(
+ Subject => 'test ticket in "' . $queue_name . '" queue',
+ Queue => $queue_name,
+);
+ok( $ticket_two_id, 'created ticket in "' . $queue_name . '" queue' );
+
+# change config to load new queue portlet in general
+# this isn't exercising limiting to a specific link relationship set such as 'HasMember', 'MemberOf', or 'RefersTo'; just 'All'
+my $expected_linked_queue_portlets = {
+ General => [
+ { $queue_name => [ 'All' ] },
+ ],
+};
+RT->Config->Set(
+ LinkedQueuePortlets => %{$expected_linked_queue_portlets},
+);
+
+my $updated_linked_queue_portlets = {
+ RT->Config->Get( 'LinkedQueuePortlets' )
+};
+cmp_deeply( $updated_linked_queue_portlets, $expected_linked_queue_portlets, 'LinkedQueuePortlets config setting updated to display "' . $queue_name . '" in "General" queue' );
+
+# verify new queue portlet is present in ticket in general
+my ( $baseurl, $m ) = RT::Test->started_ok;
+ok( $m->login(), 'logged in' );
+
+my $linked_queue_class = 'linked-queue';
+
+$m->get_ok( "/Ticket/Display.html?id=$ticket_one_id" );
+$m->content_contains( $linked_queue_class, 'ticket in "General" queue contains linked queue portlet for "' . $queue_name . '" queue' );
+
+# link tickets so the ticket shows up in the linked queue portlet
+my $link = RT::Link->new( RT->SystemUser );
+my ( $link_id, $msg ) = $link->Create( Base => $ticket_one->URI, Target => $ticket_two->URI, Type => 'RefersTo' );
+ok( $link_id, 'created "RefersTo" link between tickets' );
+
+# verify ticket in new queue is present in the linked queue portlet
+$m->get_ok( "/Ticket/Display.html?id=$ticket_one_id" );
+like(
+ $m->dom->at( 'div.ticket-info-links.' . $linked_queue_class )->content,
+ qr/Ticket\/Display\.html\?id=$ticket_two_id/,
+ 'linked queue portlet contains link to ticket in "' . $queue_name . '" queue'
+);
+
+# TODO:
+# limit the linked queue configuration to only specific link relationships to ensure only those tickets show up in the portlet
+
+done_testing();
-----------------------------------------------------------------------
More information about the rt-commit
mailing list