[Rt-commit] rtir branch, 5.0/rtir-default-queue-2, created. 4.0.1rc1-142-gc1f9f6e3

? sunnavy sunnavy at bestpractical.com
Wed May 27 18:42:58 EDT 2020


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

- Log -----------------------------------------------------------------
commit 2e1a956813cbc1f795a5234d4df33dcfc76f657c
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 1f02cdcf..548bbe88 100644
--- a/etc/RTIR_Config.pm
+++ b/etc/RTIR_Config.pm
@@ -366,6 +366,17 @@ unless (defined $default_queue) {
     RT->Config->Set('DefaultQueue','Incident Reports');
 }
 
+=item C<$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.
+
+This option defaults to C<Incident Reports>.
+
+=cut
+
+Set($RTIR_DefaultQueue, 'Incident Reports');
 
 =back
 
diff --git a/html/Callbacks/RTIR/Elements/Tabs/Privileged b/html/Callbacks/RTIR/Elements/Tabs/Privileged
index 2349d71a..7532e80d 100644
--- a/html/Callbacks/RTIR/Elements/Tabs/Privileged
+++ b/html/Callbacks/RTIR/Elements/Tabs/Privileged
@@ -542,5 +542,5 @@ PageWidgets()->child('simple_search')->raw_html( $m->scomp(
     SendTo => RT::IR->HREFTo('index.html', IncludeWebPath => 0),
     Placeholder => 'Search Incidents'
 ) );
-PageWidgets()->child( create_ticket => raw_html => $HTML::Mason::Commands::m->scomp('/Elements/CreateTicket', SendTo => '/RTIR/Incident/Create.html?Lifecycle='.RT::IR->lifecycle_incident) );
+PageWidgets()->child( create_ticket => raw_html => $HTML::Mason::Commands::m->scomp('/Elements/CreateTicket', SendTo => '/RTIR/Create.html?Queue=' . RT::IR::GetRTIRDefaultQueue()) );
 </%INIT>
diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index 415dbb4e..ac869791 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -265,6 +265,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 c1f9f6e39fc39004c34b20e5d815f041c9714ebc
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 top action of "Create new ticket".

diff --git a/docs/UPGRADING-5.0 b/docs/UPGRADING-5.0
index 90c9991c..8469d10c 100644
--- a/docs/UPGRADING-5.0
+++ b/docs/UPGRADING-5.0
@@ -29,6 +29,17 @@ CreateInQueue.html will be removed in a future version of RTIR.
 Please update any links directly accessing CreateInQueue.html to
 instead link to RTIR/Create.html or RTIR/Incident/Create.html.
 
+=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 action, 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 548bbe88..bb507a89 100644
--- a/etc/RTIR_Config.pm
+++ b/etc/RTIR_Config.pm
@@ -350,22 +350,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 C<$RTIR_DefaultQueue>
 
 Starting in RT/RTIR 5.0, the queue selection dropdown is on the ticket

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


More information about the rt-commit mailing list