[Rt-commit] rt branch, 4.6/configurable-linked-queue-portlets, created. rt-4.4.3-64-g7729d8063

Maureen Mirville maureen at bestpractical.com
Wed Oct 24 10:21:05 EDT 2018


The branch, 4.6/configurable-linked-queue-portlets has been created
        at  7729d80634e841d17d6d07c05287b681e9cfd443 (commit)

- Log -----------------------------------------------------------------
commit 8e8463aac9f5e813dedf8fd12a135a11fc70a076
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
    
    RTIR Incident page displays links portlets by queue. Isolating
    these portlets allows a user to view linked tickets based on the
    queue and their relation (supports: Depends on, Depended on by,
    Parents, Children, Refers to, Referred to by, All) on any ticket
    display page.

diff --git a/lib/RT/Link.pm b/lib/RT/Link.pm
index 27e9f0efd..3c32398f7 100644
--- a/lib/RT/Link.pm
+++ b/lib/RT/Link.pm
@@ -134,6 +134,26 @@ sub DisplayTypes {
   values %DISPLAY_AS
 }
 
+=head2 LinkTypeConversion
+
+Returns a hash of the standard link types from %DIRMAP with each Base and Target as a key
+value pair. This is useful in cases where the link type should be interpreted in reverse.
+For example, when querying for all the 'RefersTo' links on a ticket, if the query is in reference
+to the linked ticket, this function is not needed. But, if the query is in reference to the
+ticket itself, then the link type will need to be reversed and 'ReferredToBy' will need to be
+used instead.
+
+=cut
+
+sub LinkTypeConversion {
+    my %links;
+    foreach my $link ( keys %DIRMAP ) {
+        $links{ $DIRMAP{ $link }->{ 'Base' } } = $DIRMAP{ $link }->{ 'Target' };
+        $links{ $DIRMAP{ $link }->{ 'Target' } } = $DIRMAP{ $link }->{ 'Base' };
+    }
+    return %links;
+}
+
 =head1 METHODS
 
 =head2 Create PARAMHASH
diff --git a/share/html/Elements/ShowLinksCollectionList b/share/html/Elements/ShowLinksCollectionList
new file mode 100644
index 000000000..dc497d4b5
--- /dev/null
+++ b/share/html/Elements/ShowLinksCollectionList
@@ -0,0 +1,112 @@
+%# 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 }}}
+<& /Elements/CollectionList,
+   %ARGS,
+   Collection     => $linked_tickets,
+   DisplayFormat  => ($Delete? "__CheckBox__, $Format": $Format),
+   Format         => $Format,
+   Rows           => $Rows,
+   ShowHeader     => $ShowHeader,
+   OrderBy        => $OrderBy,
+   ShowNavigation => 0,
+   AllowSorting   => $AllowSorting,
+   PassArguments  => $PassArguments,
+&>
+% unless( $linked_tickets->Count ) {
+%   if ( $NoTicketsCaption ) {
+        <i>(<% $NoTicketsCaption %>)</i>
+%   }
+% }
+<br />
+
+% if( $FullList && $Rows > 0 && $linked_tickets->CountAll >= $Rows ) {
+<a href="<% $FullList %>"><i><% loc("More... ([_1] total)", $linked_tickets->CountAll) %></i></a><br />
+% }
+
+<%INIT>
+my $linked_tickets = RT::Tickets->new( $session{'CurrentUser'} );
+my $ticket_id = $TicketObj->id;
+
+my $query = "Queue = '" . $QueueName . "' AND ". $ExtraQuery;
+
+# As the query below used to find all the linked tickets is in reference to the
+# ticket itself, rather than the actual linked ticket, the link type in the query
+# will need to be reversed to the correct reference (ie ReferTo becomes ReferredToBy)
+
+my %converted_links = RT::Link->new( $session{'CurrentUser'} )->LinkTypeConversion;
+delete $converted_links{ 'MergedInto' };
+
+if ( grep /All/, @$LinkTypes ) {
+    @$LinkTypes = keys %converted_links;
+}
+@$LinkTypes = map { $converted_links{$_} } @$LinkTypes;
+my @link_relations = map { $_ . " = $ticket_id" } @$LinkTypes;
+
+my $link_query = join ( ' OR ', @link_relations ); #if scalar @link_relations;
+$query = $query . ' AND ( ' . $link_query . ' )' if $link_query;
+$linked_tickets->FromSQL( $query );
+
+$Format = RT->Config->Get( 'LinkedQueuesPortletFormat' );
+
+</%INIT>
+
+<%ARGS>
+$Format => undef
+$OrderBy => 'Due'
+$Rows => 0
+$Delete => 0
+$FullList => undef
+$NoTicketsCaption => undef,
+$ShowHeader => 0
+$AllowSorting => undef
+$PassArguments => undef
+$ExtraQuery
+$LinkTypes
+$QueueName
+$TicketObj
+</%ARGS>
diff --git a/share/html/Ticket/Elements/ShowLinkedQueues b/share/html/Ticket/Elements/ShowLinkedQueues
new file mode 100644
index 000000000..337169e10
--- /dev/null
+++ b/share/html/Ticket/Elements/ShowLinkedQueues
@@ -0,0 +1,92 @@
+%# 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 $queue_name ( @portlet_queues ) {
+    my $queue = RT::Queue->new($session{CurrentUser});
+    $queue->Load( $queue_name );
+    if ( !$queue->id ) {
+        RT->Logger->error( "Unable to load queue: $queue_name" );
+    } else {
+        my $link_types = $portlet_config->{ $queue_name };
+</%PERL>
+
+<&| /Widgets/TitleBox,
+    title       => $queue_name,
+&>
+<& /Elements/ShowLinksCollectionList, %ARGS,
+    TicketObj        => $TicketObj,
+    LinkTypes        => $link_types,
+    QueueName        => $queue_name,
+    Rows             => $Rows,
+    ExtraQuery       => "Status = '__Active__'",
+    NoTicketsCaption => loc('No active [_1] tickets', loc( $queue_name )),
+    FullList         => "/Ticket/ModifyLinks.html?id=" . $TicketObj->id . "&Queue=" . $queue->id,
+&>
+<& /Elements/ShowLinksCollectionList,
+    TicketObj        => $TicketObj,
+    LinkTypes        => $link_types,
+    QueueName        => $queue_name,
+    Rows             => $Rows,
+    ExtraQuery       => "Status = '__Inactive__'",
+    NoTicketsCaption => loc('No inactive [_1] tickets', loc( $queue_name )),
+&>
+</&>
+%}
+%}
+<%INIT>
+my $portlet_config = RT->Config->Get( 'LinkedQueuePortlets' );
+return unless $portlet_config;
+my @portlet_queues = sort keys %$portlet_config;
+</%INIT>
+
+
+<%ARGS>
+$TicketObj
+$OrderBy => 'Due'
+$Rows  => 8
+</%ARGS>
diff --git a/share/html/Ticket/Elements/ShowSummary b/share/html/Ticket/Elements/ShowSummary
index 1233b90b9..9cfd633bf 100644
--- a/share/html/Ticket/Elements/ShowSummary
+++ b/share/html/Ticket/Elements/ShowSummary
@@ -91,6 +91,11 @@
 % $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 &>
 % $m->callback( %ARGS, CallbackName => 'LinksExtra', extra => \@extra );
     <&| /Widgets/TitleBox, title => loc('Links'),

commit 7729d80634e841d17d6d07c05287b681e9cfd443
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 f6e7273f0..4911c09ab 100644
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -1681,6 +1681,37 @@ to the Article with that name.
 
 Set($WikiImplicitLinks, 0);
 
+=item C<%LinkedQueuePortlets>
+
+If %LinkedQueuePortlets is set, new portlets will display on tickets.
+Each portlet lists all the linked tickets grouped by queue, 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. See example below:
+
+Set( %LinkedQueuePortlets, (
+    General => [ 'HasMember', 'MemberOf', 'RefersTo' ],
+    TestQueue => [ 'All' ],
+));
+
+=cut
+
+Set( %LinkedQueuePortlets, () );
+
+=item C<$LinkedQueuesPortletFormat>
+
+$LinkedQueuesPortletFormat is the default format for displaying tickets
+in Linked queue portlets ( LinkedQueuePortlets must be enabled ).
+
+=cut
+
+Set( $LinkedQueuesPortletFormat,
+        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

-----------------------------------------------------------------------


More information about the rt-commit mailing list