[Bps-public-commit] RT-Extension-QuickCalls branch allow-multiple-custom-quickcall-portlets-via-config created. 1.03-7-g5281a37
BPS Git Server
git at git.bestpractical.com
Fri Oct 6 17:07:30 UTC 2023
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "RT-Extension-QuickCalls".
The branch, allow-multiple-custom-quickcall-portlets-via-config has been created
at 5281a373a33b594ba32545a3f5358912c145a8d8 (commit)
- Log -----------------------------------------------------------------
commit 5281a373a33b594ba32545a3f5358912c145a8d8
Author: Brad Embree <brad at bestpractical.com>
Date: Thu Sep 28 15:31:25 2023 -0700
Update POD
diff --git a/lib/RT/Extension/QuickCalls.pm b/lib/RT/Extension/QuickCalls.pm
index a0740d7..b354668 100644
--- a/lib/RT/Extension/QuickCalls.pm
+++ b/lib/RT/Extension/QuickCalls.pm
@@ -12,43 +12,15 @@ RT::Extension::QuickCalls - Quickly create tickets in specific queues with defau
Works with RT 4.4, 5.0
-=head1 SYNOPSIS
+To use the QuickCreate option RT must be newer than 4.4.1
-You will need to enable the new QuickCalls portlet with a line
-like this in your F<RT_SiteConfig.pm> file:
-
- Set($HomepageComponents, [qw(QuickCreate Quicksearch MyAdminQueues MySupportQueues MyReminders
- RefreshHomepage QuickCalls)]);
-
-This is the default portlet list with QuickCalls added to the end
-People can then choose to add the portlet to their homepage
-in Preferences -> RT at a glance
-
-To set up your Quick Calls, you will want to specify a C<Name> and a
-C<Queue> in the config file. The C<Name> will become the C<Subject> of
-the task unless you specify a C<Subject> option. You can add other
-Ticket options as needed, such as C<Status>. Additionally, if the
-C<SetOwnerToCurrentUser> option is set, the ticket will be owned by the
-current user.
+=head1 DESCRIPTION
- Set($QuickCalls,[{Name => "Foo", Queue => 'General', Status => 'resolved'},
- {Name => "Bar", Queue => 'Queue2', Status => 'resolved'}]);
+This RT extension allows you to add a QuickCalls portlet to your RT
+dashboards.
-If a value is an anonymous subref, it will be called when the QuickCall
-is selected, and its return value filled in for the appropriate key:
-
- Set($QuickCalls,[ {
- Queue => 'General',
- Name => 'This will have the current time on the server in its content',
- Content => sub {
- my $date = localtime;
- return "When: $date\n\n";
- },
- }]);
-
-After you have added QuickCalls to your home page, you will be able to select
-one, click Create and be brought to the ticket creation page with multiple
-fields pre-filled.
+You can configure the portlet to show the same Quick Calls on every
+dashboard or customize the Quick Calls per dashboard.
=head1 INSTALLATION
@@ -62,6 +34,10 @@ fields pre-filled.
May need root permissions
+=item To use the QuickCreate option apply this patch for RT earlier than 5.0.6
+
+ patch -d /opt/rt5 -p1 < patches/0001-Support-QuickCreate-to-pass-arguments-to-redirect-UR.patch
+
=item Edit your F</opt/rt4/etc/RT_SiteConfig.pm>
If you are using RT 4.2 or greater, add this line:
@@ -82,6 +58,99 @@ or add C<RT::Extension::QuickCalls> to your existing C<@Plugins> line.
=back
+=head1 CONFIGURATION
+
+You will need to enable the new QuickCalls portlet with a line
+like this in your F<RT_SiteConfig.pm> file:
+
+ Set($HomepageComponents, [qw(QuickCreate Quicksearch MyAdminQueues MySupportQueues MyReminders
+ RefreshHomepage QuickCalls)]);
+
+This is the default portlet list with QuickCalls added to the end
+People can then choose to add the portlet to their homepage
+in Preferences -> RT at a glance
+
+=head2 BASIC CONFIGURATION
+
+To set up your Quick Calls, you will want to specify a C<Name> and a
+C<Queue> in the config file. The C<Name> will become the C<Subject> of
+the task unless you specify a C<Subject> option. You can add other
+Ticket options as needed, such as C<Status>. Additionally, if the
+C<SetOwnerToCurrentUser> option is set, the ticket will be owned by the
+current user.
+
+The following configuration will show the same Quick Calls on all
+dashboards:
+
+ Set(
+ $QuickCalls, [
+ { Name => "Foo", Queue => 'General', Status => 'resolved' },
+ { Name => "Bar", Queue => 'Queue2', Status => 'resolved' },
+ ]
+ );
+
+=head2 CUSTOM CONFIGURATION PER DASHBOARD
+
+If you would like different dashboards to show different Quick Calls you
+can use a different configuration format:
+
+ Set(
+ $QuickCalls, {
+ Default => {
+ Actions => [
+ { Name => "Default Foo", Queue => 'General', Status => 'resolved' },
+ { Name => "Default Bar", Queue => 'Queue2', Status => 'resolved' }
+ ],
+ },
+ 1 => { # use the ID of the Dashboard as the hash key
+ Title => 'Optional Title',
+ Actions => [
+ { Name => "Dashboard ID 1 Foo", Queue => 'General', Status => 'resolved' },
+ { Name => "Dashboard ID 1 Bar", Queue => 'Queue2', Status => 'resolved' }
+ ],
+ },
+ ...
+ }
+ );
+
+The above configuration would show different Quick Calls when the
+portlet is loaded on the Dashboard with ID 1. If there is not a custom
+configuration for a Dashboard ID it will use the 'Default' value.
+
+=head2 SUBREF VALUES
+
+If a value is an anonymous subref, it will be called when the Quick Call
+is selected, and its return value filled in for the appropriate key:
+
+ Set(
+ $QuickCalls, [
+ {
+ Queue => 'General',
+ Name => 'This will have the current time on the server in its content',
+ Content => sub {
+ my $date = localtime;
+ return "When: $date\n\n";
+ },
+ },
+ ]
+ );
+
+=head2 QUICK CREATE
+
+After you have added the QuickCalls portlet to your home page, you will
+be able to select one, click Create and be brought to the ticket
+creation page with multiple fields pre-filled.
+
+If you would like the Quick Call to automatically create the ticket and
+stay on the dashboard you can use the QuickCreate option:
+
+ Set(
+ $QuickCalls, [
+ { Name => "Foo", Queue => 'General', Status => 'resolved', QuickCreate => 1 },
+ { Name => "Bar", Queue => 'Queue2', Status => 'resolved' },
+ ]
+ );
+
=head1 AUTHOR
Best Practical Solutions, LLC E<lt>modules at bestpractical.comE<gt>
commit c26fa71032c0bba06a0e58e2aa37454e0afef80b
Author: Brad Embree <brad at bestpractical.com>
Date: Fri Oct 6 08:44:01 2023 -0700
Check Quick Call for QuickCreate option
If the Quick Call config has the QuickCreate option set call
ProcessQuickCreate, passing in the PassArguments if there are any.
diff --git a/html/Helpers/QuickCalls b/html/Helpers/QuickCalls
index 084298b..1871ca4 100644
--- a/html/Helpers/QuickCalls
+++ b/html/Helpers/QuickCalls
@@ -75,8 +75,23 @@ if ( $QuickCall ) {
$QuickCall->{$_} = $QuickCall->{$_}->()
for grep { ref $QuickCall->{$_} eq "CODE" } keys %{$QuickCall};
- my $query = $m->comp( '/Elements/QueryString', %$QuickCall );
- RT::Interface::Web::Redirect( $RT::WebURL . "Ticket/Create.html?$query" );
+ if ( $QuickCall->{QuickCreate} ) {
+ ProcessQuickCreate(
+ Path => $ARGS{QuickCallsPath},
+ ARGSRef => $QuickCall,
+ $ARGS{PassArguments}
+ ? (
+ PassArguments => {
+ map { $_ => $ARGS{$_} } ref $ARGS{PassArguments} eq 'ARRAY' ? @{ $ARGS{PassArguments} } : $ARGS{PassArguments}
+ },
+ )
+ : (),
+ );
+ }
+ else {
+ my $query = $m->comp( '/Elements/QueryString', %$QuickCall );
+ RT::Interface::Web::Redirect( $RT::WebURL . "Ticket/Create.html?$query" );
+ }
}
}
</%init>
commit b5541a841bc7c40b4c15f950181cfbf9bc094cdc
Author: Brad Embree <brad at bestpractical.com>
Date: Fri Oct 6 08:47:21 2023 -0700
Add hidden inputs for pass args for QuickCreate
QuickCreate calls ProcessQuickCreate which needs some pass args to
ensure the path is correct when redirecting for results.
Add hidden inputs to the form to ensure the pass args are submitted.
diff --git a/html/Elements/QuickCalls b/html/Elements/QuickCalls
index 85ec778..ffe0f01 100644
--- a/html/Elements/QuickCalls
+++ b/html/Elements/QuickCalls
@@ -54,6 +54,12 @@
<form method="post" action="<%$RT::WebPath%>/Helpers/QuickCalls">
% if ( $quickcall_dashboard_id ) {
<input type="hidden" class="hidden" name="QuickCallsDashboard" value="<% $quickcall_dashboard_id %>">
+% }
+% for my $pass_argument ( keys %$DECODED_ARGS ) {
+ <input type="hidden" class="hidden" name="PassArguments" value="<% $pass_argument %>">
+% for my $value ( ref $DECODED_ARGS->{$pass_argument} eq 'ARRAY' ? @{ $DECODED_ARGS->{$pass_argument} } : $DECODED_ARGS->{$pass_argument} ) {
+ <input type="hidden" class="hidden" name="<% $pass_argument %>" value="<% $value // '' %>">
+% }
% }
<input type="hidden" class="hidden" name="QuickCallsPath" value="<%RT->Config->Get('WebPath')%><% $r->path_info %>">
<select name="QuickCall" class="selectpicker form-control">
commit b9a2cf731d76d3bc5e8d0bc650e123827ec1ed72
Author: Brad Embree <brad at bestpractical.com>
Date: Fri Oct 6 09:54:41 2023 -0700
Add patch for pass arguments
diff --git a/patches/0001-Support-QuickCreate-to-pass-arguments-to-redirect-UR.patch b/patches/0001-Support-QuickCreate-to-pass-arguments-to-redirect-UR.patch
new file mode 100644
index 0000000..502b90e
--- /dev/null
+++ b/patches/0001-Support-QuickCreate-to-pass-arguments-to-redirect-UR.patch
@@ -0,0 +1,27 @@
+From 2ded707673d13706a6dad0769ecfa514fe204f62 Mon Sep 17 00:00:00 2001
+From: sunnavy <sunnavy at bestpractical.com>
+Date: Wed, 4 Oct 2023 14:38:46 -0400
+Subject: [PATCH] Support QuickCreate to pass arguments to redirect URL after
+ ticket creation
+
+This is initially for QuickCalls extension, where we need to pass user
+id on user summary page, to "QuickCreate" a ticket there.
+---
+ lib/RT/Interface/Web.pm | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
+index 64ce8dc64..5b4722428 100644
+--- a/lib/RT/Interface/Web.pm
++++ b/lib/RT/Interface/Web.pm
+@@ -4329,6 +4329,7 @@ sub ProcessQuickCreate {
+ MaybeRedirectForResults(
+ Actions => \@results,
+ Path => $path,
++ $params{PassArguments} ? ( Arguments => $params{PassArguments} ) : (),
+ );
+ }
+
+--
+2.25.1
+
commit 67492ba6902cdb07de67dd630d30a1d2505914a0
Author: Brad Embree <brad at bestpractical.com>
Date: Fri Oct 6 08:42:46 2023 -0700
Check for custom dashboard config
Support both the old and new format for QuickCalls config.
If using the new config format and passed in a Dashboard id check for a
custom dashboard config. Fallback to the Default config setting if no
custom config.
diff --git a/html/Helpers/QuickCalls b/html/Helpers/QuickCalls
index f15f6c4..084298b 100644
--- a/html/Helpers/QuickCalls
+++ b/html/Helpers/QuickCalls
@@ -46,21 +46,38 @@
%#
%# END BPS TAGGED BLOCK }}}
<%init>
-if ($QuickCall) {
- my ($QuickCall) = grep { $_->{Name} eq $QuickCall} @{$RT::QuickCalls||[]};
- # copy so we don't nuke the config variable
- $QuickCall = { map { $_ => $QuickCall->{$_} } keys %$QuickCall };
- $QuickCall->{Subject} ||= $QuickCall->{Name};
- $QuickCall->{Owner} = $session{CurrentUser}->Id if ($QuickCall->{SetOwnerToCurrentUser});
- delete $QuickCall->{SetOwnerToCurrentUser};
- delete $QuickCall->{Name};
+if ( $QuickCall ) {
+ my $config = RT->Config->Get('QuickCalls');
+ my $quickcalls;
- # Anon subrefs can be used to generate dynamic values
- $QuickCall->{$_} = $QuickCall->{$_}->()
- for grep {ref $QuickCall->{$_} eq "CODE"} keys %{$QuickCall};
+ if ( ref $config eq 'ARRAY' ) {
+ # old behavior
+ $quickcalls = $config;
+ }
+ elsif ( ref $config eq 'HASH' ) {
+ # new behavior
+ my $quickcall_dashboard_id = $ARGS{QuickCallsDashboard} || '';
+ my $quickcall_config = $config->{$quickcall_dashboard_id} || $config->{Default} || {};
+ $quickcalls = $quickcall_config->{Actions} || [];
+ }
- my $query = $m->comp( '/Elements/QueryString', %$QuickCall);
- RT::Interface::Web::Redirect($RT::WebURL."Ticket/Create.html?$query");
+ if ( my ( $QuickCall ) = grep { $_->{Name} eq $QuickCall } @$quickcalls ) {
+ # copy so we don't nuke the config variable
+ $QuickCall = { map { $_ => $QuickCall->{$_} } keys %$QuickCall };
+ $QuickCall->{Subject} ||= $QuickCall->{Name};
+ $QuickCall->{Owner} = $session{CurrentUser}->Id
+ if ( $QuickCall->{SetOwnerToCurrentUser} );
+
+ delete $QuickCall->{SetOwnerToCurrentUser};
+ delete $QuickCall->{Name};
+
+ # Anon subrefs can be used to generate dynamic values
+ $QuickCall->{$_} = $QuickCall->{$_}->()
+ for grep { ref $QuickCall->{$_} eq "CODE" } keys %{$QuickCall};
+
+ my $query = $m->comp( '/Elements/QueryString', %$QuickCall );
+ RT::Interface::Web::Redirect( $RT::WebURL . "Ticket/Create.html?$query" );
+ }
}
</%init>
<%args>
commit 66975d750668d9a39d3f1bef7266db113537fcbb
Author: Brad Embree <brad at bestpractical.com>
Date: Fri Oct 6 08:46:12 2023 -0700
Check for custom dashboard config
Support both the old and new format for QuickCalls config.
If using the new config format determine the Dashboard loading the
portlet and check for a custom dashboard config. Fallback to the Default
config setting if no custom config.
If there is a dashboard id add hidden input to the form so it gets
passed on when submitted.
diff --git a/html/Elements/QuickCalls b/html/Elements/QuickCalls
index 6ed493a..85ec778 100644
--- a/html/Elements/QuickCalls
+++ b/html/Elements/QuickCalls
@@ -48,13 +48,16 @@
% if ( RT::Handle::cmp_version($RT::VERSION, '5.0.0') >= 0 ) {
% # RT 5 version
-<&| /Widgets/TitleBox, title => loc('Quick Calls') &>
+<&| /Widgets/TitleBox, title => $title &>
<div class="form-row">
<div class="col-auto">
- <form method="post"
- action="<%$RT::WebPath%>/Helpers/QuickCalls">
+ <form method="post" action="<%$RT::WebPath%>/Helpers/QuickCalls">
+% if ( $quickcall_dashboard_id ) {
+ <input type="hidden" class="hidden" name="QuickCallsDashboard" value="<% $quickcall_dashboard_id %>">
+% }
+ <input type="hidden" class="hidden" name="QuickCallsPath" value="<%RT->Config->Get('WebPath')%><% $r->path_info %>">
<select name="QuickCall" class="selectpicker form-control">
-% foreach my $QuickCall (@{$RT::QuickCalls||[]}) {
+% foreach my $QuickCall (@$quickcalls) {
<option value="<%$QuickCall->{Name}%>"><%$QuickCall->{Name}%>
% }
</select>
@@ -71,7 +74,7 @@
<&| /Widgets/TitleBox, title => loc('Quick Calls') &>
<form action="<%$RT::WebPath%>/Helpers/QuickCalls">
<select name="QuickCall">
-% foreach my $QuickCall (@{$RT::QuickCalls||[]}) {
+% foreach my $QuickCall (@$quickcalls) {
<option value="<%$QuickCall->{Name}%>"><%$QuickCall->{Name}%>
% }
</select>
@@ -79,3 +82,46 @@
</form>
</&>
% }
+<%INIT>
+my $title = loc('Quick Calls');
+my $config = RT->Config->Get('QuickCalls') || [];
+my $quickcalls;
+
+my $arg = $m->dhandler_arg || '';
+my ( $dashboard_id, $dashboard_name ) = split '/', $arg;
+my $system_default_id = 0;
+
+unless ( $dashboard_id ) {
+ # if there is no dhandler_arg we are on the default homepage dashboard
+ # following logic copied from share/html/Elements/MyRT to find user's default dashboard
+ my $user = $session{'CurrentUser'}->UserObj;
+ my ( $system_default ) = RT::System->new( $session{'CurrentUser'} )->Attributes->Named('DefaultDashboard');
+ $system_default_id = $system_default ? $system_default->Content : 0;
+ $dashboard_id = $user->Preferences( DefaultDashboard => $system_default_id );
+}
+
+# Allow any user to read system default dashboard
+my $Dashboard = RT::Dashboard->new( $system_default_id == $dashboard_id ? RT->SystemUser : $session{'CurrentUser'} );
+my ( $ok, $msg ) = $Dashboard->LoadById( $dashboard_id );
+if ( !$ok ) {
+ RT->Logger->error("Unable to load Dashboard '$dashboard_id': $msg");
+}
+
+my $quickcall_dashboard_id;
+if ( ref $config eq 'ARRAY' ) {
+ # old behavior
+ $quickcalls = $config;
+}
+elsif ( ref $config eq 'HASH' ) {
+ # new behavior
+ $quickcall_dashboard_id = $Dashboard ? $Dashboard->id : '';
+
+ my $quickcall_config = $config->{$quickcall_dashboard_id} || $config->{Default} || {};
+
+ if ( my $quickcall_title = $quickcall_config->{Title} ) {
+ $title .= " - $quickcall_title";
+ }
+ $quickcalls = $quickcall_config->{Actions};
+}
+
+</%INIT>
\ No newline at end of file
commit 446786a20f36a05a6be0ad3ba5140f5820e2ec9d
Author: Brad Embree <brad at bestpractical.com>
Date: Thu Sep 28 08:50:58 2023 -0700
Delete unnecessary file
diff --git a/html/Elements/.#QuickCalls b/html/Elements/.#QuickCalls
deleted file mode 120000
index b0228d0..0000000
--- a/html/Elements/.#QuickCalls
+++ /dev/null
@@ -1 +0,0 @@
-chmrr at umgah.localdomain.14071:1403105031
\ No newline at end of file
-----------------------------------------------------------------------
hooks/post-receive
--
RT-Extension-QuickCalls
More information about the Bps-public-commit
mailing list