[Rt-commit] rtir branch, 5.0/rtir-default-queue, created. 4.0.1rc1-118-g34bd4f10

Jim Brandt jbrandt at bestpractical.com
Wed Apr 29 14:47:57 EDT 2020


The branch, 5.0/rtir-default-queue has been created
        at  34bd4f10df0085a4e9bea2bbb2c0da25b9920727 (commit)

- Log -----------------------------------------------------------------
commit e7cea72f6369c804cabb18191a40bd1e2f1fad97
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Tue Apr 28 17:39:15 2020 -0400

    Add RTIR_DefaultQueue option
    
    Queue is now selected on the ticket create page, so add a
    new DefaultQueue option for RTIR create pages. This allows the
    RT create page to have a separate default queue if desired.
    
    As part of this change, convert the direct META setting to
    use the AddOption method and provide these options on the
    user preferences page.

diff --git a/etc/RTIR_Config.pm b/etc/RTIR_Config.pm
index b0534476..858485ec 100644
--- a/etc/RTIR_Config.pm
+++ b/etc/RTIR_Config.pm
@@ -315,6 +315,20 @@ unless (defined $default_queue) {
     RT->Config->Set('DefaultQueue','Incident Reports');
 }
 
+=item RTIR_DefaultQueue
+
+Starting in RT/RTIR 5.0, the queue selection dropdown is on the ticket create
+page. RTIR has separate create pages from RT, so this allows you to set
+a default queue for RT and a different one for RTIR.
+
+If you set RT's DefaultQueue option to a non-RTIR queue, you can set RTIR_DefaultQueue
+to the queue that should be the default on RTIR create pages.
+
+This option defaults to Incident Reports.
+
+=cut
+
+Set($RTIR_DefaultQueue, 'Incident Reports');
 
 =back
 
diff --git a/html/RTIR/Create.html b/html/RTIR/Create.html
index 19e246d8..b992542f 100644
--- a/html/RTIR/Create.html
+++ b/html/RTIR/Create.html
@@ -410,7 +410,7 @@ $m->callback(
 
 # Use default queue from config site or user prefs if none provided
 unless ($Queue) {
-    $Queue = GetDefaultQueue();
+    $Queue = RT::IR::GetRTIRDefaultQueue();
 }
 
 # pick first in list in normal order unless queue provided from form/url/defaults
diff --git a/html/RTIR/Elements/SelectNewTicketQueue b/html/RTIR/Elements/SelectNewTicketQueue
index e64665bf..1b83355f 100644
--- a/html/RTIR/Elements/SelectNewTicketQueue
+++ b/html/RTIR/Elements/SelectNewTicketQueue
@@ -57,13 +57,7 @@
  &>
 </label>
 <%INIT>
-my $queue = RT->Config->Get("DefaultQueue", $session{'CurrentUser'});
-
-if (RT->Config->Get("RememberDefaultQueue", $session{'CurrentUser'})) {
-    if (my $session_default = $session{'DefaultQueue'}) {
-        $queue = $session_default;
-    }
-}
+my $queue = RT::IR::GetRTIRDefaultQueue();
 
 $m->callback(Queue => \$queue, CallbackName => 'DefaultQueue');
 </%INIT>
diff --git a/html/RTIR/Incident/Create.html b/html/RTIR/Incident/Create.html
index 186c9e08..eb0f2226 100644
--- a/html/RTIR/Incident/Create.html
+++ b/html/RTIR/Incident/Create.html
@@ -130,7 +130,7 @@ if ( $ChildObj && $ChildObj->id && !$ChildObj->CurrentUserHasRight('ModifyTicket
       <&|/l&>Queue</&>:
     </div>
     <div class="value col-md-9">
-      <& /RTIR/Elements/SelectRTIRQueue, Name => "Queue", Default => $ARGS{Queue}, AutoSubmit => 1, ShowNullOption => 0 &>
+      <& /RTIR/Elements/SelectRTIRQueue, Name => "Queue", Default => $queue, AutoSubmit => 1, ShowNullOption => 0 &>
     </div>
   </div>
   <div class="form-row">
@@ -363,12 +363,19 @@ for my $related_ticket ($ChildObj, $SplitObj) {
         last;
 }
 
+my $queue;
+if ( exists $ARGS{'Queue'} ) {
+    $queue = $ARGS{'Queue'};
+}
+else {
+    $queue = RT::IR::GetRTIRDefaultQueue();
+}
 
 my $QueueObj = RT::Queue->new($session{'CurrentUser'});
-$QueueObj->Load( $ARGS{Queue} );
+$QueueObj->Load( $queue );
 
 if (!$QueueObj->Name) {
-Abort( loc("Queue '[_1]' could not be loaded.", $ARGS{Queue}) );
+Abort( loc("Queue '[_1]' could not be loaded.", $queue) );
  }
 
 if( !RT::IR->IsIncidentQueue($QueueObj) ) {
diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index 7459e6e8..409888b4 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -266,6 +266,24 @@ sub FlushQueuesCache {
     return 1;
 } }
 
+=head2 GetRTIRDefaultQueue
+
+Processes global and user-level configuration options to find the default
+queue for the current user.
+
+Accepts no arguments, returns the ID of the default RTIR queue, if found, or undef.
+
+Mirrors GetDefaultQueue from RT.
+
+=cut
+
+sub GetRTIRDefaultQueue {
+    my $queue;
+
+    $queue = RT->Config->Get( "RTIR_DefaultQueue", $HTML::Mason::Commands::session{'CurrentUser'} );
+
+    return $queue;
+}
 
 =head2 Lifecycles
 
diff --git a/lib/RT/IR/Config.pm b/lib/RT/IR/Config.pm
index 4bc3f779..845d8db4 100644
--- a/lib/RT/IR/Config.pm
+++ b/lib/RT/IR/Config.pm
@@ -55,15 +55,42 @@ use warnings;
 
 sub Init {
     use RT::Config;
-    my %meta = (
-        DisplayAfterEdit => {
-            Section         => 'Tickets view',
-            Overridable     => 1,
-            Widget          => '/Widgets/Form/Boolean',
-            WidgetArguments => {
-                Description => 'Display ticket after edit (don\'t stay on the edit page)',
+
+    RT->Config->AddOption(
+        Name            => 'DisplayAfterEdit',
+        Section         => 'Ticket display',
+        Overridable     => 1,
+        Widget          => '/Widgets/Form/Boolean',
+        WidgetArguments => {
+            Description => 'Display RTIR ticket after edit (don\'t stay on the edit page)',
+        }
+    );
+
+    RT->Config->AddOption(
+        Name            => 'RTIR_DefaultQueue',
+        Section         => 'General',
+        Overridable     => 1,
+        SortOrder       => 1.5,
+        Widget          => '/Widgets/Form/Select',
+        WidgetArguments => {
+            Description => 'Default RTIR queue',    #loc
+            Default     => 1,
+            Callback    => sub {
+                my $ret = { Values => [], ValuesLabel => {}};
+                my @queues = RT::IR->Queues;
+                foreach my $queue_name ( @queues ) {
+                    my $queue = RT::Queue->new($HTML::Mason::Commands::session{'CurrentUser'});
+                    $queue->Load($queue_name);
+                    next unless $queue->CurrentUserHasRight("CreateTicket");
+                    push @{$ret->{Values}}, $queue->Id;
+                    $ret->{ValuesLabel}{$queue->Id} = $queue->Name;
+                }
+                return $ret;
             },
-        },
+        }
+    );
+
+    my %meta = (
         'RTIR_HomepageComponents' => {
             Type => 'ARRAY',
         },

commit 34bd4f10df0085a4e9bea2bbb2c0da25b9920727
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Wed Apr 29 14:38:09 2020 -0400

    Remove default setting of DefaultQueue for RT
    
    With RT's DefaultQueue set to an RTIR queue, users have
    no way of getting to the regular RT ticket create page because
    clicking on the Create new ticket button will allows redirect
    to the RTIR create page.
    
    Remove this default setting and note it in the UPGRADING file.
    The new RTIR_DefaultQueue option is now available to provide
    similar functionality for RTIR create pages.

diff --git a/docs/UPGRADING-5.0 b/docs/UPGRADING-5.0
new file mode 100644
index 00000000..a10119e9
--- /dev/null
+++ b/docs/UPGRADING-5.0
@@ -0,0 +1,27 @@
+=head1 Upgrading to RTIR 5.0
+
+The following describes some of the key components of the upgrade
+to RTIR 5.0 from RTIR 4.0.  The other UPGRADING documents contain
+details for previous versions.
+
+As with other versions of RTIR, you first need to upgrade RT itself
+to a supported version. For RTIR 5.0, this is RT 5.0.
+
+=head2 Notable Changes
+
+=over
+
+=item *
+
+Previous versions of RTIR, set RT's DefaultQueue option to Incident Reports.
+The new versions of RT and RTIR move the queue selection to the create page
+from the top menu, so a new RTIR_DefaultQueue option is now available to set
+the default queue for RTIR create ticket pages.
+
+With this new RTIR-specific option, RTIR no longer automatically sets RT's
+DefaultQueue. You can still set it manually for your system via the RT
+configuration.
+
+=back
+
+=cut
diff --git a/etc/RTIR_Config.pm b/etc/RTIR_Config.pm
index 858485ec..a8f87643 100644
--- a/etc/RTIR_Config.pm
+++ b/etc/RTIR_Config.pm
@@ -299,22 +299,6 @@ page. The default is true.
 
 Set($RTIR_RedirectOnSearch, 1);
 
-=item DefaultQueue
-
-By default, RT does not specify a Default Queue.
-If you set one in your RT_SiteConfig.pm, RTIR will honor that setting.
-Otherwise, RTIR will set Incident Reports to be the default Queue
-for the New Ticket In dropdown.
-
-If you prefer another Queue, you should specify it in RT_SiteConfig.pm
-
-=cut
-
-my $default_queue = RT->Config->Get('DefaultQueue');
-unless (defined $default_queue) {
-    RT->Config->Set('DefaultQueue','Incident Reports');
-}
-
 =item RTIR_DefaultQueue
 
 Starting in RT/RTIR 5.0, the queue selection dropdown is on the ticket create

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


More information about the rt-commit mailing list