[Rt-commit] rt branch, 5.0/self-service-homepage-dashboard, updated. rt-5.0.0-11-ga4ffc08fd3
Dianne Skoll
dianne at bestpractical.com
Fri Sep 4 13:39:47 EDT 2020
The branch, 5.0/self-service-homepage-dashboard has been updated
via a4ffc08fd319acdd6fd7e9ef4ddd31a097a92b4c (commit)
from 302c1daaeba370c9c48ddfa3440cfa279f8d387c (commit)
Summary of changes:
etc/RT_Config.pm.in | 16 +++++++-
lib/RT/Interface/Web/MenuBuilder.pm | 7 +++-
.../html/Dashboards/Elements/ShowPortlet/component | 9 ++++-
share/html/Dashboards/Queries.html | 8 +++-
.../SelfServiceTopArticles} | 46 ++++++++++++++--------
5 files changed, 65 insertions(+), 21 deletions(-)
copy share/html/{Approvals/Display.html => Elements/SelfServiceTopArticles} (69%)
- Log -----------------------------------------------------------------
commit a4ffc08fd319acdd6fd7e9ef4ddd31a097a92b4c
Author: Dianne Skoll <dianne at bestpractical.com>
Date: Fri Sep 4 13:15:32 2020 -0400
Add a "SelfServiceTopArticles" portlet that can (only) be placed on the self-service dashboard.
This shows the top N (currently 10) articles sorder by SortOrder (ascending)
and LastUpdated (descending). For the portlet to work, you must configure
$SelfServiceArticleClass in RT_SiteConfig.pm. For example:
Set( $SelfServiceArticleClass, 'General' );
diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index a7301b3436..c6cb3c2103 100644
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -2067,8 +2067,22 @@ Set(
]
);
-=back
+=item C<$SelfServicePageComponents>
+
+C<$SelfServicePageComponents> is an arrayref of allowed components on
+the SelfService page, if you have set $SelfServiceUseDashboard to true.
+If this is not set at all, then $HomepageComponents is used instead.
+
+=cut
+
+Set(
+ $SelfServicePageComponents,
+ [
+ qw(QuickCreate QueueList MyAdminQueues MySupportQueues MyReminders RefreshHomepage Dashboards SavedSearches FindUser MyAssets FindAsset FindGroup SelfServiceTopArticles ) # loc_qw
+ ]
+);
+=back
diff --git a/lib/RT/Interface/Web/MenuBuilder.pm b/lib/RT/Interface/Web/MenuBuilder.pm
index b6651b6363..65ce0ee7ce 100644
--- a/lib/RT/Interface/Web/MenuBuilder.pm
+++ b/lib/RT/Interface/Web/MenuBuilder.pm
@@ -1620,7 +1620,12 @@ sub BuildSelfServiceNav {
} elsif ( $queue_id ) {
$top->child( new => title => loc('New ticket'), path => '/SelfService/Create.html?Queue=' . $queue_id );
}
- my $tickets = $top->child( tickets => title => loc('Tickets'), path => '/SelfService/' );
+
+ my $menu_label = loc('Tickets');
+ if (RT->Config->Get('SelfServiceUseDashboard')) {
+ $menu_label = loc('Self-Service');
+ }
+ my $tickets = $top->child( tickets => title => $menu_label, path => '/SelfService/' );
$tickets->child( open => title => loc('Open tickets'), path => '/SelfService/Open.html' );
$tickets->child( closed => title => loc('Closed tickets'), path => '/SelfService/Closed.html' );
diff --git a/share/html/Dashboards/Elements/ShowPortlet/component b/share/html/Dashboards/Elements/ShowPortlet/component
index cead432fb2..b3258fe706 100644
--- a/share/html/Dashboards/Elements/ShowPortlet/component
+++ b/share/html/Dashboards/Elements/ShowPortlet/component
@@ -56,7 +56,14 @@ $HasResults
my $full_path = $Portlet->{path};
(my $path = $full_path) =~ s{^/Elements/}{};
-my $allowed = grep { $_ eq $path } @{RT->Config->Get('HomepageComponents')};
+my $allowed;
+
+if ($m->request_path =~ m{/SelfService}) {
+ $allowed = grep { $_ eq $path } @{RT->Config->Get('SelfServicePageComponents') || RT->Config->Get('HomepageComponents')};
+} else {
+ $allowed = grep { $_ eq $path } @{RT->Config->Get('HomepageComponents')};
+}
+
</%init>
% if (!$allowed) {
% $m->out( $m->interp->apply_escapes( loc("Invalid portlet [_1]", $path), "h" ) );
diff --git a/share/html/Dashboards/Queries.html b/share/html/Dashboards/Queries.html
index 87b5941b28..c0b47d1ed2 100644
--- a/share/html/Dashboards/Queries.html
+++ b/share/html/Dashboards/Queries.html
@@ -86,7 +86,13 @@ if ($self_service_dashboard) {
my @sections;
my %item_for;
-my @components = map { type => "component", name => $_, label => loc($_) }, @{RT->Config->Get('HomepageComponents')};
+my @components;
+
+if ($self_service_dashboard) {
+ @components = map { type => "component", name => $_, label => loc($_) }, @{RT->Config->Get('SelfServicePageComponents') || RT->Config->Get('HomepageComponents')};
+} else {
+ @components = map { type => "component", name => $_, label => loc($_) }, @{RT->Config->Get('HomepageComponents')};
+}
$item_for{ $_->{type} }{ $_->{name} } = $_ for @components;
diff --git a/share/html/Dashboards/Elements/ShowPortlet/component b/share/html/Elements/SelfServiceTopArticles
similarity index 66%
copy from share/html/Dashboards/Elements/ShowPortlet/component
copy to share/html/Elements/SelfServiceTopArticles
index cead432fb2..f015e77c47 100644
--- a/share/html/Dashboards/Elements/ShowPortlet/component
+++ b/share/html/Elements/SelfServiceTopArticles
@@ -45,25 +45,41 @@
%# those contributions and any derivatives thereof.
%#
%# END BPS TAGGED BLOCK }}}
-<%args>
-$Dashboard
-$Portlet
-$Rows => 20
-$Preview => 0
-$HasResults
-</%args>
-<%init>
-my $full_path = $Portlet->{path};
-(my $path = $full_path) =~ s{^/Elements/}{};
-my $allowed = grep { $_ eq $path } @{RT->Config->Get('HomepageComponents')};
-</%init>
-% if (!$allowed) {
-% $m->out( $m->interp->apply_escapes( loc("Invalid portlet [_1]", $path), "h" ) );
-% RT->Logger->info("Invalid portlet $path found on dashboard #" . $Dashboard->Id);
-% if ($path eq 'QueueList' && grep { $_ eq 'Quicksearch' } @{RT->Config->Get('HomepageComponents')}) {
-% RT->Logger->warning("You may need to replace the component 'Quicksearch' in the HomepageComponents config with 'QueueList'. See the UPGRADING-4.4 document.");
-% }
-% } else {
-% $m->comp($full_path, HasResults => $HasResults);
+<&| /Widgets/TitleBox, title => $title &>
+
+% while (my $article = $articles->Next) {
+ <div class="form-row">
+ <span class="value col-auto">
+ <a href="<% RT->Config->Get('WebPath') %>/SelfService/Article/Display.html?id=<%$article->Id%>"><%$article->Name || loc('(no name)')%>: <%$article->Summary%></a>
+ </span>
+ </div>
% }
+</&>
+
+<%INIT>
+$title = loc('Articles');
+# Figure out which class of articles applies to self-service users
+my $class = RT::Class->new( $session{'CurrentUser'} );
+my ($ok, $msg) = $class->LoadByCols( Name => RT->Config->Get('SelfServiceArticleClass') );
+if (!$ok || !$class->Id) {
+ # Could not find the class... bail?
+ return;
+}
+
+# Get the articles
+my $articles = RT::Articles->new( $session{'CurrentUser'} );
+
+# TODO: Make this configurable
+$articles->RowsPerPage(10);
+
+$articles->Search(Class => $class->Id,
+ OrderBy => ['SortOrder', 'LastUpdated'],
+ Order => ['ASC', 'DESC' ]);
+
+
+</%INIT>
+
+<%ARGS>
+$title => undef
+</%ARGS>
-----------------------------------------------------------------------
More information about the rt-commit
mailing list