[Rt-commit] rtir branch, 5.0/rtir-default-queue, created. 4.0.1rc1-117-ga608e6b3
Jim Brandt
jbrandt at bestpractical.com
Tue Apr 28 17:53:30 EDT 2020
The branch, 5.0/rtir-default-queue has been created
at a608e6b36435a1902dbb6346c322794998313f5b (commit)
- Log -----------------------------------------------------------------
commit a608e6b36435a1902dbb6346c322794998313f5b
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..ef4e1f92 100644
--- a/etc/RTIR_Config.pm
+++ b/etc/RTIR_Config.pm
@@ -312,9 +312,24 @@ If you prefer another Queue, you should specify it in RT_SiteConfig.pm
my $default_queue = RT->Config->Get('DefaultQueue');
unless (defined $default_queue) {
+ push @RT::Config::PreInitLoggerMessages, 'Setting default queue to Incident Reports from the RTIR configuration. Set a different $DefaultQueue value in RT to override.';
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..ef1165d0 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 = GetRTIRDefaultQueue();
}
# pick first in list in normal order unless queue provided from form/url/defaults
diff --git a/html/RTIR/Incident/Create.html b/html/RTIR/Incident/Create.html
index 186c9e08..66513ca5 100644
--- a/html/RTIR/Incident/Create.html
+++ b/html/RTIR/Incident/Create.html
@@ -363,12 +363,19 @@ for my $related_ticket ($ChildObj, $SplitObj) {
last;
}
+my $queue;
+if ( $ARGS{'Queue'} ) {
+ $queue = $ARGS{'Queue'};
+}
+else {
+ $queue = 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',
},
-----------------------------------------------------------------------
More information about the rt-commit
mailing list