[Rt-commit] rtir branch, master, updated. 4.0.1rc1-140-geb6766a7

? sunnavy sunnavy at bestpractical.com
Fri May 22 16:12:04 EDT 2020


The branch, master has been updated
       via  eb6766a7faa2b6898008132ab3099a08d24ff4b0 (commit)
       via  98b5b595d794c7fb42a01231fb8cbd92cce49f2d (commit)
       via  a490e962ad5b43b5b1ff10b104fbe411e83ed259 (commit)
       via  91393c5973ba510d4429bfb6233aecdeb2630d0d (commit)
       via  fbc751cc5e509485f6c1f8872261c0fb34cf853e (commit)
      from  740736a02013297f7e8e5f3284501aaf37f9dcd6 (commit)

Summary of changes:
 MANIFEST                                           |   1 -
 etc/RTIR_Config.pm                                 |  51 ++++++++
 .../Elements/ShowLinkedQueues/MassageQueries       |  23 ++++
 .../Elements/ShowLinkedQueues/MassageTitleBox      |  52 ++++++++
 html/RTIR/Elements/ShowChildren                    |   2 +
 html/RTIR/Incident/Children/index.html             |   1 +
 html/RTIR/Incident/Display.html                    |   7 +-
 html/RTIR/Incident/Elements/ShowChildren           | 139 ---------------------
 t/020-incident-and-investigation.t                 |   1 -
 t/incident/linked_queue_portlets.t                 |  42 +++++++
 10 files changed, 173 insertions(+), 146 deletions(-)
 create mode 100644 html/Callbacks/RTIR/Ticket/Elements/ShowLinkedQueues/MassageQueries
 create mode 100644 html/Callbacks/RTIR/Ticket/Elements/ShowLinkedQueues/MassageTitleBox
 delete mode 100644 html/RTIR/Incident/Elements/ShowChildren
 create mode 100644 t/incident/linked_queue_portlets.t

- Log -----------------------------------------------------------------
commit fbc751cc5e509485f6c1f8872261c0fb34cf853e
Author: Maureen E. Mirville <maureen at bestpractical.com>
Date:   Fri Nov 9 13:22:22 2018 -0500

    Update RTIR Incidents to use a callback for displaying queue portlets
    
    RT was updated so users can now add portlets by queue on any ticket,
    like the RTIR Incident page that displays linked Incident Reports,
    Investigations, and Countermeasures. With this change to RT, RTIR code
    was updated accordingly.

diff --git a/MANIFEST b/MANIFEST
index e4ac3361..5f96ce7b 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -114,7 +114,6 @@ html/RTIR/Incident/Create.html
 html/RTIR/Incident/Display.html
 html/RTIR/Incident/Elements/Create
 html/RTIR/Incident/Elements/ReplyForm
-html/RTIR/Incident/Elements/ShowChildren
 html/RTIR/Incident/Reply/index.html
 html/RTIR/Incident/Reply/Refine.html
 html/RTIR/Incident/Split.html
diff --git a/etc/RTIR_Config.pm b/etc/RTIR_Config.pm
index b0534476..12913b88 100644
--- a/etc/RTIR_Config.pm
+++ b/etc/RTIR_Config.pm
@@ -230,6 +230,28 @@ Set(
     },
 );
 
+=item C<%LinkedQueuePortlets>
+
+C<%LinkedQueuePortlets> allows you to display links to tickets in
+another queue in a stand-alone portlet on the ticket display page.
+This makes it easier to highlight specific ticket links separate from
+the standard Links portlet.
+
+You can include multiple linked queues in each ticket and they are
+displayed in the order you define them in the configuration. The values
+are RT link types: 'DependsOn', 'DependedOnBy', 'HasMember'
+(children), 'MemberOf' (parents), 'RefersTo', and 'ReferredToBy'.
+'All' lists all linked tickets. You can include multiple link types.
+
+=cut
+
+Set( %LinkedQueuePortlets, (
+    Incidents   => [
+        { 'Incident Reports'  => [ 'All' ] },
+        { Investigations      => [ 'All' ] },
+        { Countermeasures     => [ 'All' ] },
+    ],
+));
 
 =item C<%RTIR_IncidentChildren>
 
diff --git a/html/Callbacks/RTIR/Ticket/Elements/ShowLinkedQueues/MassageQueries b/html/Callbacks/RTIR/Ticket/Elements/ShowLinkedQueues/MassageQueries
new file mode 100644
index 00000000..2f250982
--- /dev/null
+++ b/html/Callbacks/RTIR/Ticket/Elements/ShowLinkedQueues/MassageQueries
@@ -0,0 +1,23 @@
+<%INIT>
+# this callback provides a means to manipulate the queries and empty message strings for each linked queue
+# for ShowLinkedQueues before the queries are run or message strings displayed on the page.
+my $queue = RT::Queue->new($session{CurrentUser});
+$queue->Load($Queue);
+my $lifecycle = $queue->Lifecycle;
+return unless $lifecycle;
+
+return if $lifecycle eq RT::IR->lifecycle_countermeasure && RT->Config->Get('RTIR_DisableCountermeasures');
+
+my $friendly_lifecycle = RT::IR::FriendlyLifecycle($lifecycle);
+
+@$EmptyMessages
+    = ( loc( '(No active [_1])', loc($friendly_lifecycle) ), loc( '(No inactive [_1])', loc($friendly_lifecycle) ) );
+
+</%INIT>
+
+<%ARGS>
+$ARGSRef
+$Queue
+$Queries
+$EmptyMessages
+</%ARGS>
diff --git a/html/Callbacks/RTIR/Ticket/Elements/ShowLinkedQueues/MassageTitleBox b/html/Callbacks/RTIR/Ticket/Elements/ShowLinkedQueues/MassageTitleBox
new file mode 100644
index 00000000..45f74d84
--- /dev/null
+++ b/html/Callbacks/RTIR/Ticket/Elements/ShowLinkedQueues/MassageTitleBox
@@ -0,0 +1,52 @@
+<%INIT>
+# this callback provides a means to manipulate the values being sent to the TitleBox element
+# for ShowLinkedQueues before they are run and displayed on the page.
+my @queues = ( 'Incident Reports','Investigations', 'Countermeasures' );
+
+my %lifecycles = (
+    'Incident Reports'  => 'incident_reports',
+    'Investigations'    => 'investigations',
+    'Countermeasures'   => 'countermeasures',
+);
+
+my $id = $ARGSRef->{ TicketObj }->id;
+
+foreach my $queue ( @queues ) {
+    if ( $queue eq $$title ) {
+        my $lifecycle = $lifecycles{ $queue };
+        $$class = 'tickets-list-'. lc(RT::IR::TicketType( Lifecycle => $lifecycle ));
+        $$title_href = RT::IR->HREFTo("Incident/Children/?Lifecycle=$lifecycle&id=$id");
+
+        my @titleright_raw;
+        if ( $ARGSRef->{ TicketObj }->CurrentUserHasRight('ModifyTicket') ) {
+            my $QueueObj = RT::Queue->new($session{CurrentUser});
+            $QueueObj->Load($queue);
+
+            if ( $QueueObj->Id and $QueueObj->CurrentUserHasRight('CreateTicket') ) {
+                push @titleright_raw, {
+                    title => $lifecycle ne RT::IR->lifecycle_investigation? loc('Create') : loc('Launch'),
+                    class => 'create_child' . ($lifecycle ? '_'.$lifecycle : ''),
+                    path => RT::IR->HREFTo("Create.html?Incident=$id&Lifecycle=".$lifecycle),
+                };
+            }
+            push @titleright_raw, {
+                title => loc('Link'),
+                path  => RT::IR->HREFTo("Link/FromIncident/?id=$id&Lifecycle=".$lifecycle),
+            };
+        }
+
+        $$titleright_raw = join ' 'x3,
+            map q{<a href="} . $_->{'path'} . ( $_->{'class'} ? q{" class="} . $_->{'class'} : '' ) . q{">}
+                . $m->interp->apply_escapes( $_->{title}, 'h' ) . q{</a>},
+            @titleright_raw;
+    }
+}
+</%INIT>
+
+<%ARGS>
+$ARGSRef
+$title
+$class => undef
+$title_href => undef
+$titleright_raw => undef
+</%ARGS>
diff --git a/html/RTIR/Incident/Display.html b/html/RTIR/Incident/Display.html
index bf1a0489..fd4d7c65 100644
--- a/html/RTIR/Incident/Display.html
+++ b/html/RTIR/Incident/Display.html
@@ -160,12 +160,9 @@
   <div class="boxcontainer col-md-6">
 % $m->callback( %ARGS, Ticket => $TicketObj, CallbackName => 'RightColumnStart' );
 
-% foreach my $lifecycle ( RT::IR->lifecycle_report, RT::IR->lifecycle_investigation, RT::IR->lifecycle_countermeasure ) {
-<& /RTIR/Incident/Elements/ShowChildren,
-    IncidentObj => $TicketObj,
-    Lifecycle   => $lifecycle
+<& /Ticket/Elements/ShowLinkedQueues,
+    TicketObj => $TicketObj,
 &>
-% }
 
 <& /RTIR/Elements/ShowArticles, Ticket => $TicketObj &>
 % $m->callback( %ARGS, Ticket => $TicketObj, CallbackName => 'RightColumnEnd' );
diff --git a/html/RTIR/Incident/Elements/ShowChildren b/html/RTIR/Incident/Elements/ShowChildren
deleted file mode 100644
index 64c09765..00000000
--- a/html/RTIR/Incident/Elements/ShowChildren
+++ /dev/null
@@ -1,139 +0,0 @@
-%# 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 }}}
-<&| /Widgets/TitleBox, 
-    title       => loc( $FriendlyLifecycle ), 
-    title_href  => RT::IR->HREFTo("Incident/Children/?Lifecycle=". $Lifecycle ."&id=".$id),
-    titleright_raw => $box_actions,
-    title_class    => 'inverse',
-    class => 'tickets-list-'. lc(RT::IR::TicketType( Lifecycle => $Lifecycle )),
-&>
-
-<& /RTIR/Elements/ShowChildren,
-    Ticket           => $IncidentObj, 
-    Lifecycle        => $Lifecycle,
-    Rows             => $Rows,
-    Statuses         => \@active_statuses,
-    NoTicketsCaption => loc('No active [_1]', loc( $FriendlyLifecycle )),
-&>
-% if ( $active->CountAll < $Rows ) {
-<& /RTIR/Elements/ShowChildren,
-    Ticket           => $IncidentObj,
-    Lifecycle        => $Lifecycle,
-    Rows             => $Rows - $active->CountAll,
-    Statuses         => \@inactive_statuses,
-    NoTicketsCaption => loc('No inactive [_1]', loc( $FriendlyLifecycle )),
-&>
-% }
-</&>
-
-<%ARGS>
-$IncidentObj
-$Lifecycle
-
-$OrderBy => 'Due'
-
-$Rows  => 8
-</%ARGS>
-<%INIT>
-
-
-return if $Lifecycle eq RT::IR->lifecycle_countermeasure && RT->Config->Get('RTIR_DisableCountermeasures');
-
-
-my $FriendlyLifecycle = RT::IR::FriendlyLifecycle($Lifecycle);
-
-my $id = $IncidentObj->id;
-
-my @active_statuses = RT::IR->Statuses( Lifecycle => $Lifecycle);
-my @inactive_statuses = RT::IR->Statuses( Lifecycle => $Lifecycle, Initial => 0, Active => 0, Inactive => 1 );
-
-my $active = RT::Tickets->new( $session{'CurrentUser'} );
-$active->FromSQL( RT::IR->Query(
-    Lifecycle => $Lifecycle,
-    MemberOf => $IncidentObj,
-    Status   => \@active_statuses,
-));
-
-my $inactive = RT::Tickets->new( $session{'CurrentUser'} );
-$inactive->FromSQL( RT::IR->Query(
-    Lifecycle => $Lifecycle,
-    MemberOf => $IncidentObj,
-    Status   => \@inactive_statuses,
-));
-
-my $total_count = $active->CountAll + $inactive->CountAll;
-
-
-my @box_actions;
-if ( $IncidentObj->CurrentUserHasRight('ModifyTicket') ) {
-    if (1) { # XXX TODO RESTORE THIS ACL CHECK
-    # $QueueObj->Id and $QueueObj->CurrentUserHasRight('CreateTicket') ) {
-        push @box_actions, {
-            title => $Lifecycle ne RT::IR->lifecycle_investigation? loc('Create') : loc('Launch'),
-            class => 'create_child' . ($Lifecycle ? '_'.$Lifecycle : ''),
-            path => RT::IR->HREFTo("Create.html?Incident=$id&Lifecycle=".$Lifecycle),
-        };
-    }
-    push @box_actions, {
-        title => loc('Link'),
-        path  => RT::IR->HREFTo("Link/FromIncident/?id=$id&Lifecycle=".$Lifecycle),
-    };
-}
-
-if ( $total_count > $Rows ) {
-    push @box_actions, {
-        title => loc("More... ([_1] total)", $total_count),
-        path => RT::IR->HREFTo('Incident/Children/?Lifecycle='. $Lifecycle .'&id='. $id)
-    };
-}
-my $box_actions = join ' 'x3,
-    map q{<a href="} . $_->{'path'} . ( $_->{'class'} ? q{" class="} . $_->{'class'} : '' ) . q{">}
-        . $m->interp->apply_escapes( $_->{title}, 'h' ) . q{</a>},
-    @box_actions;
-
-</%INIT>

commit 91393c5973ba510d4429bfb6233aecdeb2630d0d
Author: Blaine Motsinger <blaine at bestpractical.com>
Date:   Fri Mar 20 18:20:47 2020 -0500

    Add test for Linked Queue Portlets

diff --git a/t/020-incident-and-investigation.t b/t/020-incident-and-investigation.t
index eabd3bf7..95a64d54 100755
--- a/t/020-incident-and-investigation.t
+++ b/t/020-incident-and-investigation.t
@@ -131,5 +131,4 @@ like( $agent->uri, qr/RTIR\/Create.html/, 'still in the create page' );
 $agent->content_contains('Creation failed', 'failed to create');
 $agent->content_contains('You must enter an Incident ID');
 
-undef $agent;
 done_testing;
diff --git a/t/incident/linked_queue_portlets.t b/t/incident/linked_queue_portlets.t
new file mode 100644
index 00000000..dde000cd
--- /dev/null
+++ b/t/incident/linked_queue_portlets.t
@@ -0,0 +1,42 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use RT::IR::Test tests => undef;
+
+RT::Test->started_ok;
+my $agent     = default_agent();
+my $rtir_user = rtir_user();
+
+# create incident, incident report, investigation, and countermeasure
+my $incident_id        = $agent->create_rtir_ticket_ok( 'Incidents',        { Subject => 'test incident' } );
+my $incident_report_id = $agent->create_rtir_ticket_ok( 'Incident Reports', { Subject => 'test incident report' } );
+my $investigation_id   = $agent->create_rtir_ticket_ok( 'Investigations',   { Subject => 'test investigation',  Requestors => $rtir_user->EmailAddress } );
+my $countermeasure_id  = $agent->create_rtir_ticket_ok( 'Countermeasures',  { Subject => 'test countermeasure', Incident   => $incident_id } );
+
+# link them as members of the incident
+my $incident = RT::Ticket->new( RT->SystemUser );
+$incident->Load( $incident_id );
+ok( $incident->AddLink( Type => 'MemberOf', Base => $incident_report_id ), 'Linked Incident Report to Incident' );
+ok( $incident->AddLink( Type => 'MemberOf', Base => $investigation_id   ), 'Linked Investigation to Incident'   );
+
+# ensure the default portlets are visible in the incident ticket
+$agent->display_ticket( $incident_id );
+$agent->content_contains( 'tickets-list-report',         'Incident Reports portlet is visible on the Incident' );
+$agent->content_contains( 'tickets-list-investigation',  'Investigations portlet is visible on the Incident'   );
+$agent->content_contains( 'tickets-list-countermeasure', 'Countermeasures portlet is visible on the Incident'  );
+
+# ensure they all show up on the incident page in their specific portlet
+$agent->display_ticket( $incident_id );
+is( $agent->dom->find( 'div.tickets-list-report .collection-as-table a' )->first->attr('href'),
+    "/Ticket/Display.html?id=$incident_report_id",
+    'Incident Report portlet contains link to Incident Report' );
+is( $agent->dom->find( 'div.tickets-list-investigation .collection-as-table a' )->first->attr('href'),
+    "/Ticket/Display.html?id=$investigation_id",
+    'Investigation portlet contains link to Investigation' );
+is( $agent->dom->find( 'div.tickets-list-countermeasure .collection-as-table a' )->first->attr('href'),
+    "/Ticket/Display.html?id=$countermeasure_id",
+    'Countermeasure portlet contains link to Countermeasure' );
+
+done_testing();

commit a490e962ad5b43b5b1ff10b104fbe411e83ed259
Author: Blaine Motsinger <blaine at bestpractical.com>
Date:   Tue Apr 28 12:40:56 2020 -0500

    Disable InlineEdit for Incident/Children list

diff --git a/html/RTIR/Elements/ShowChildren b/html/RTIR/Elements/ShowChildren
index 0f773cb0..fd16e206 100644
--- a/html/RTIR/Elements/ShowChildren
+++ b/html/RTIR/Elements/ShowChildren
@@ -67,6 +67,7 @@
    ShowNavigation => 0,
    AllowSorting   => $AllowSorting,
    PassArguments  => $PassArguments,
+   InlineEdit     => $InlineEdit,
 &>
 % unless( $children->Count ) {
 %   if ( $NoTicketsCaption ) {
@@ -120,4 +121,5 @@ $ShowStatusesSelector => 0
 
 $AllowSorting => undef
 $PassArguments => undef
+$InlineEdit => RT->Config->Get('InlineEdit', $session{CurrentUser})
 </%ARGS>
diff --git a/html/RTIR/Incident/Children/index.html b/html/RTIR/Incident/Children/index.html
index d3ee9bcf..187818e2 100644
--- a/html/RTIR/Incident/Children/index.html
+++ b/html/RTIR/Incident/Children/index.html
@@ -71,6 +71,7 @@
     ShowStatusesSelector => 1,
     AllowSorting         => 1,
     PassArguments        => [qw(Query Format Rows Page Order OrderBy Queue id SelectedTicekts Statuses)],
+    InlineEdit           => 0,
 &>
 
 <& /Elements/Submit, Name => 'Unlink', Label => loc('Unlink Report') &>

commit 98b5b595d794c7fb42a01231fb8cbd92cce49f2d
Author: Blaine Motsinger <blaine at bestpractical.com>
Date:   Thu Apr 30 11:15:10 2020 -0500

    Add LinkedQueuePortletFormats documentation

diff --git a/etc/RTIR_Config.pm b/etc/RTIR_Config.pm
index 12913b88..1f02cdcf 100644
--- a/etc/RTIR_Config.pm
+++ b/etc/RTIR_Config.pm
@@ -253,6 +253,35 @@ Set( %LinkedQueuePortlets, (
     ],
 ));
 
+=item C<%LinkedQueuePortletFormats>
+
+C<%LinkedQueuePortletFormats> defines the format for displaying
+linked tickets in each linked queue portlet defined by C<%LinkedQueuePortlets>.
+
+The 'Default' format will be used by default.
+
+To change the format for all 3 RTIR default linked queues, for
+example:
+
+    Set( %LinkedQueuePortletFormats,
+        'Incident Reports' =>
+            q{'<b><a href="__RTIRTicketURI__">__id__</a></b>/TITLE:#',}.
+            q{'<b><a href="__RTIRTicketURI__">__Subject__</a></b>/TITLE:Subject',}.
+            q{Status,OwnerName,LastUpdatedRelative},
+
+        Investigations =>
+            q{'<b><a href="__RTIRTicketURI__">__id__</a></b>/TITLE:#',}.
+            q{'<b><a href="__RTIRTicketURI__">__Subject__</a></b>/TITLE:Subject',}.
+            q{Status,OwnerName,LastUpdatedRelative},
+
+        Countermeasures =>
+            q{'<b><a href="__RTIRTicketURI__">__id__</a></b>/TITLE:#',}.
+            q{'<b><a href="__RTIRTicketURI__">__Subject__</a></b>/TITLE:Subject',}.
+            q{Status,OwnerName,LastUpdatedRelative},
+    );
+
+=cut
+
 =item C<%RTIR_IncidentChildren>
 
 Option controls relations between an incident and

commit eb6766a7faa2b6898008132ab3099a08d24ff4b0
Merge: 740736a0 98b5b595
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Sat May 23 04:06:16 2020 +0800

    Merge branch '4.2/configurable-linked-queue-portlets'


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


More information about the rt-commit mailing list