[Bps-public-commit] RT-Extension-QuickCalls branch allow-multiple-custom-quickcall-portlets-via-config created. 1.03-11-g9a489af
BPS Git Server
git at git.bestpractical.com
Sun Oct 1 22:16:10 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 9a489af1aa18fb7864a439b7334a478fc2711f6d (commit)
- Log -----------------------------------------------------------------
commit 9a489af1aa18fb7864a439b7334a478fc2711f6d
Author: Brad Embree <brad at bestpractical.com>
Date: Sun Oct 1 15:15:05 2023 -0700
Change logic to check for custom config based on Dashboard ID
diff --git a/html/Helpers/QuickCalls b/html/Helpers/QuickCalls
index 6834e6e..2fe4470 100644
--- a/html/Helpers/QuickCalls
+++ b/html/Helpers/QuickCalls
@@ -62,16 +62,21 @@
my ( $quick_create, $quick_create_path, $quick_create_values );
-if ($QuickCall) {
- my $custom = RT->Config->Get('QuickCallsPages');
+if ( $QuickCall ) {
+ my $config = RT->Config->Get('QuickCalls');
my $quickcalls;
- my $page;
- if ( $page = $ARGS{QuickCallsPage} ) {
- $quickcalls = $custom->{$page} || [];
+
+ if ( ref $config eq 'ARRAY' ) {
+ # old behavior
+ $quickcalls = $config;
}
- else {
- $quickcalls = $RT::QuickCalls || [];
+ 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 ( $QuickCall ) = grep { $_->{Name} eq $QuickCall } @$quickcalls;
# copy so we don't nuke the config variable
$QuickCall = { map { $_ => $QuickCall->{$_} } keys %$QuickCall };
commit dd6bfb9a4bc24b86cfe9a3ae88c5b620a48175ae
Author: Brad Embree <brad at bestpractical.com>
Date: Sun Oct 1 15:14:23 2023 -0700
Change logic to check for custom config based on Dashboard ID
diff --git a/html/Elements/QuickCalls b/html/Elements/QuickCalls
index 9a0f413..05e83c6 100644
--- a/html/Elements/QuickCalls
+++ b/html/Elements/QuickCalls
@@ -53,8 +53,8 @@
<div class="col-auto">
<form method="post"
action="<%$RT::WebPath%>/Helpers/QuickCalls">
-% if ( $page ) {
- <input type="hidden" class="hidden" name="QuickCallsPage" value="<% $page %>">
+% 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">
@@ -85,15 +85,45 @@
% }
<%INIT>
my $title = loc('Quick Calls');
-my $custom = RT->Config->Get('QuickCallsPages');
+my $config = RT->Config->Get('QuickCalls') || [];
my $quickcalls;
-my $page;
-if ( $page = $ARGS{QuickCallsPage} ) {
- $quickcalls = $custom->{$page} || [];
- $title .= " - $page";
+
+unless ( $Dashboard ) {
+ # if we were not explicitly passed a $Dashboard 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');
+ my $system_default_id = $system_default ? $system_default->Content : 0;
+ my $dashboard_id = $user->Preferences( DefaultDashboard => $system_default_id );
+
+ if ( $dashboard_id ) {
+ # Allow any user to read system default dashboard
+ $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;
}
-else {
- $quickcalls = $RT::QuickCalls || [];
+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>
+<%ARGS>
+$Dashboard => undef
+</%ARGS>
\ No newline at end of file
commit df8e52e8a9565b8efb77206134763d067288836a
Author: Brad Embree <brad at bestpractical.com>
Date: Sun Oct 1 15:13:38 2023 -0700
Update POD
diff --git a/lib/RT/Extension/QuickCalls.pm b/lib/RT/Extension/QuickCalls.pm
index 2c07d01..0435bc1 100644
--- a/lib/RT/Extension/QuickCalls.pm
+++ b/lib/RT/Extension/QuickCalls.pm
@@ -53,6 +53,8 @@ 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.
+If you would like to have different versions of the QuickCalls portlet on different dashboards see C<CUSTOM PORTLET PER DASHBOARD> below;
+
=head1 INSTALLATION
=over
@@ -87,24 +89,28 @@ or add C<RT::Extension::QuickCalls> to your existing C<@Plugins> line.
=head1 CONFIGURATION
-=head2 MULTIPLE PORTLETS
-
-If you would like to have multiple different versions of the QuickCalls
-portlet you can use the C<QuickCallsPages> configuration option.
-
- Set($QuickCallsPages,{
- One => [
- {Name => "One Foo", Queue => 'General', Status => 'resolved'},
- {Name => "One Bar", Queue => 'Queue2', Status => 'resolved'}
- ],
- Two => [
- {Name => "Two Foo", Queue => 'General', Status => 'resolved'},
- {Name => "Two Bar", Queue => 'Queue2', Status => 'resolved'}
- ],
+=head2 CUSTOM PORTLET PER DASHBOARD
+
+If you would like to have different versions of the QuickCalls portlet for different dashboards you can use a different config format:
+
+ Set($QuickCalls,{
+ Default => {
+ Actions => [
+ {Name => "Default Foo", Queue => 'General', Status => 'resolved'},
+ {Name => "Default Bar", Queue => 'Queue2', Status => 'resolved'}
+ ],
+ },
+ 9 => { # use the ID of the Dashboard as the hash key
+ Title => 'Optional Title',
+ Actions => [
+ {Name => "Dashboard ID 9 Foo", Queue => 'General', Status => 'resolved'},
+ {Name => "Dashboard ID 9 Bar", Queue => 'Queue2', Status => 'resolved'}
+ ],
+ },
+ ...
});
-The above configuration would give you two new portlet options to add to
-your dashboards: C<QuickCalls-One> and C<QuickCalls-Two>.
+The above configuration would load different actions when the QuickCalls portlet is loaded on the Dashboard with ID 9. If there is not custom configuration for a Dashboard ID it will use the 'Default' value.
=head2 QUICK CREATE
commit b27605ada8cadeea0d27441188226eb69f361397
Author: Brad Embree <brad at bestpractical.com>
Date: Sun Oct 1 15:05:13 2023 -0700
Remove code auto generating element files from QuickCalls.pm
diff --git a/lib/RT/Extension/QuickCalls.pm b/lib/RT/Extension/QuickCalls.pm
index 603ffec..2c07d01 100644
--- a/lib/RT/Extension/QuickCalls.pm
+++ b/lib/RT/Extension/QuickCalls.pm
@@ -7,32 +7,6 @@ require Cwd;
our $VERSION = '1.03';
-my $path = Cwd::abs_path(__FILE__);
-$path =~ s{lib/RT/Extension/QuickCalls.pm$}{};
-$path = File::Spec->catfile( $path, 'html', 'Elements' );
-
-my $HomepageComponents = RT->Config->Get('HomepageComponents');
-my $custom = RT->Config->Get('QuickCallsPages') || {};
-foreach my $page ( keys %$custom ) {
- # the component name cannot have special characters
- my $component = $page;
- $component =~ s/ /_/g;
- $component =~ s/'|"|//g;
-
- # the page name needs to map to the entry in the config but must escape single quotes
- $page =~ s/'/\\'/g;
-
- push @$HomepageComponents, "QuickCalls-$component";
-
- my $filename = File::Spec->catfile( $path, "QuickCalls-$component" );
- my $content = '% $m->comp( \'/Elements/QuickCalls\', QuickCallsPage => \'' . $page . '\' );' . "\n";
- open my $fh, '>', $filename
- or RT->Logger->error("Could not open file '$filename' to write custom portlet: $!");
- print $fh $content;
- close $fh;
-}
-RT->Config->Set( 'HomepageComponents', $HomepageComponents );
-
=head1 NAME
RT::Extension::QuickCalls - Quickly create tickets in specific queues with default values
commit ce6e0f42ab825a5f6a5b8daf77bd9ca4a4f9600a
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 37c95f7..603ffec 100644
--- a/lib/RT/Extension/QuickCalls.pm
+++ b/lib/RT/Extension/QuickCalls.pm
@@ -111,6 +111,49 @@ or add C<RT::Extension::QuickCalls> to your existing C<@Plugins> line.
=back
+=head1 CONFIGURATION
+
+=head2 MULTIPLE PORTLETS
+
+If you would like to have multiple different versions of the QuickCalls
+portlet you can use the C<QuickCallsPages> configuration option.
+
+ Set($QuickCallsPages,{
+ One => [
+ {Name => "One Foo", Queue => 'General', Status => 'resolved'},
+ {Name => "One Bar", Queue => 'Queue2', Status => 'resolved'}
+ ],
+ Two => [
+ {Name => "Two Foo", Queue => 'General', Status => 'resolved'},
+ {Name => "Two Bar", Queue => 'Queue2', Status => 'resolved'}
+ ],
+ });
+
+The above configuration would give you two new portlet options to add to
+your dashboards: C<QuickCalls-One> and C<QuickCalls-Two>.
+
+=head2 QUICK CREATE
+
+If you would like a QuickCalls action to automatically create a ticket
+instead of taking the user to the Ticket Create page you can set the
+option QuickCreate to a true value:
+
+ Set($QuickCalls,[{Name => "Foo", Queue => 'General', Status => 'resolved', 'QuickCreate' => 1},
+ {Name => "Bar", Queue => 'Queue2', Status => 'resolved'}]);
+
+or
+
+ Set($QuickCallsPages,{
+ One => [
+ {Name => "One Foo", Queue => 'General', Status => 'resolved', 'QuickCreate' => 1},
+ {Name => "One Bar", Queue => 'Queue2', Status => 'resolved'}
+ ],
+ Two => [
+ {Name => "Two Foo", Queue => 'General', Status => 'resolved'},
+ {Name => "Two Bar", Queue => 'Queue2', Status => 'resolved'}
+ ],
+ });
+
=head1 AUTHOR
Best Practical Solutions, LLC E<lt>modules at bestpractical.comE<gt>
commit 2749b9e6944185dabf73b0068476e973edb1fa1a
Author: Brad Embree <brad at bestpractical.com>
Date: Thu Sep 28 14:42:21 2023 -0700
Add QuickCreate QuickCalls config option
If QuickCreate is set then create the ticket immediately and refresh the
page the QuickCalls portlet was on.
diff --git a/html/Helpers/QuickCalls b/html/Helpers/QuickCalls
index a56ca69..6834e6e 100644
--- a/html/Helpers/QuickCalls
+++ b/html/Helpers/QuickCalls
@@ -45,7 +45,23 @@
%# those contributions and any derivatives thereof.
%#
%# END BPS TAGGED BLOCK }}}
+% if ( $quick_create ) {
+<form id="quick-calls-quick-create-form" method="post" action="<% $quick_create_path %>">
+ <input type="hidden" class="hidden" name="QuickCreate" value="1" />
+% foreach my $key ( keys %$quick_create_values ) {
+ <input type="hidden" class="hidden" name="<% $key %>" value="<% $quick_create_values->{$key} %>" />
+% }
+</form>
+<script type="text/javascript">
+ window.self.onload = function() {
+ document.getElementById("quick-calls-quick-create-form").submit();
+ };
+</script>
+% }
<%init>
+
+my ( $quick_create, $quick_create_path, $quick_create_values );
+
if ($QuickCall) {
my $custom = RT->Config->Get('QuickCallsPages');
my $quickcalls;
@@ -64,12 +80,19 @@ if ($QuickCall) {
delete $QuickCall->{SetOwnerToCurrentUser};
delete $QuickCall->{Name};
+ $quick_create = delete $QuickCall->{QuickCreate};
+ $quick_create_path = $ARGS{QuickCallsPath};
+
# 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");
+ if ( $quick_create ) {
+ $quick_create_values = { %$QuickCall };
+ } else {
+ my $query = $m->comp( '/Elements/QueryString', %$QuickCall);
+ RT::Interface::Web::Redirect($RT::WebURL."Ticket/Create.html?$query");
+ }
}
</%init>
<%args>
commit c6d687f4773a20d88f8f8e28e351692d3ece31de
Author: Brad Embree <brad at bestpractical.com>
Date: Thu Sep 28 14:31:44 2023 -0700
Add QuickCallsPath hidden input for quick create
/Helpers/QuickCalls needs the path the QuickCalls portlet is on for the
new quick create option so it can reload the page after the ticket is
created.
diff --git a/html/Elements/QuickCalls b/html/Elements/QuickCalls
index 62b6a21..9a0f413 100644
--- a/html/Elements/QuickCalls
+++ b/html/Elements/QuickCalls
@@ -56,6 +56,7 @@
% if ( $page ) {
<input type="hidden" class="hidden" name="QuickCallsPage" value="<% $page %>">
% }
+ <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 (@$quickcalls) {
<option value="<%$QuickCall->{Name}%>"><%$QuickCall->{Name}%>
commit 5b414e7a1b0f447bde083301d3b7aafffdb8212a
Author: Brad Embree <brad at bestpractical.com>
Date: Thu Sep 28 14:41:19 2023 -0700
Check for QuickCallsPage arg for custom QuickCalls config
If passed a QuickCallsPage argument use the config from the
QuickCallsPages config.
diff --git a/html/Helpers/QuickCalls b/html/Helpers/QuickCalls
index f15f6c4..a56ca69 100644
--- a/html/Helpers/QuickCalls
+++ b/html/Helpers/QuickCalls
@@ -47,7 +47,16 @@
%# END BPS TAGGED BLOCK }}}
<%init>
if ($QuickCall) {
- my ($QuickCall) = grep { $_->{Name} eq $QuickCall} @{$RT::QuickCalls||[]};
+ my $custom = RT->Config->Get('QuickCallsPages');
+ my $quickcalls;
+ my $page;
+ if ( $page = $ARGS{QuickCallsPage} ) {
+ $quickcalls = $custom->{$page} || [];
+ }
+ else {
+ $quickcalls = $RT::QuickCalls || [];
+ }
+ 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};
commit a30575bf406a7afef065336969d42075166b7ee3
Author: Brad Embree <brad at bestpractical.com>
Date: Thu Sep 28 08:54:46 2023 -0700
Check for QuickCallsPage argument to show custom portlet
Check if passed a QuickCallsPage argument and if so show actions for
that Page from the new QuickCallsPages config option.
If not passed a QuickCallsPage argument behave as before and show
actions from the QuickCalls config option.
diff --git a/html/Elements/QuickCalls b/html/Elements/QuickCalls
index 6ed493a..62b6a21 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">
+% if ( $page ) {
+ <input type="hidden" class="hidden" name="QuickCallsPage" value="<% $page %>">
+% }
<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,17 @@
</form>
</&>
% }
+<%INIT>
+my $title = loc('Quick Calls');
+my $custom = RT->Config->Get('QuickCallsPages');
+my $quickcalls;
+my $page;
+if ( $page = $ARGS{QuickCallsPage} ) {
+ $quickcalls = $custom->{$page} || [];
+ $title .= " - $page";
+}
+else {
+ $quickcalls = $RT::QuickCalls || [];
+}
+
+</%INIT>
commit c5b87ffb0cde282acd6a005566465f8c3e7f8d6c
Author: Brad Embree <brad at bestpractical.com>
Date: Thu Sep 28 08:52:19 2023 -0700
Dynamically create custom portlets based on config
Add a new config QuickCallsPages that lets users configure multiple
custom QuickCalls portlets with different actions on each one.
This lets users group actions together and create different portlets for
different users/groups.
diff --git a/lib/RT/Extension/QuickCalls.pm b/lib/RT/Extension/QuickCalls.pm
index a0740d7..37c95f7 100644
--- a/lib/RT/Extension/QuickCalls.pm
+++ b/lib/RT/Extension/QuickCalls.pm
@@ -2,8 +2,37 @@ package RT::Extension::QuickCalls;
use warnings;
use strict;
+require File::Spec;
+require Cwd;
+
our $VERSION = '1.03';
+my $path = Cwd::abs_path(__FILE__);
+$path =~ s{lib/RT/Extension/QuickCalls.pm$}{};
+$path = File::Spec->catfile( $path, 'html', 'Elements' );
+
+my $HomepageComponents = RT->Config->Get('HomepageComponents');
+my $custom = RT->Config->Get('QuickCallsPages') || {};
+foreach my $page ( keys %$custom ) {
+ # the component name cannot have special characters
+ my $component = $page;
+ $component =~ s/ /_/g;
+ $component =~ s/'|"|//g;
+
+ # the page name needs to map to the entry in the config but must escape single quotes
+ $page =~ s/'/\\'/g;
+
+ push @$HomepageComponents, "QuickCalls-$component";
+
+ my $filename = File::Spec->catfile( $path, "QuickCalls-$component" );
+ my $content = '% $m->comp( \'/Elements/QuickCalls\', QuickCallsPage => \'' . $page . '\' );' . "\n";
+ open my $fh, '>', $filename
+ or RT->Logger->error("Could not open file '$filename' to write custom portlet: $!");
+ print $fh $content;
+ close $fh;
+}
+RT->Config->Set( 'HomepageComponents', $HomepageComponents );
+
=head1 NAME
RT::Extension::QuickCalls - Quickly create tickets in specific queues with default values
commit 072844b133979544bb5e53f1224fdf2dabddcabb
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