[Rt-commit] rt branch 5.0/add-callbacks-to-dashboard-component-call created. rt-5.0.5-161-g4f5bba608f

BPS Git Server git at git.bestpractical.com
Fri Feb 23 18:58:49 UTC 2024


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".

The branch, 5.0/add-callbacks-to-dashboard-component-call has been created
        at  4f5bba608f96d45893398043fe67ecf897c3350d (commit)

- Log -----------------------------------------------------------------
commit 4f5bba608f96d45893398043fe67ecf897c3350d
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date:   Fri Feb 23 15:56:52 2024 -0300

    Add callbacks to dashboard portlet rendering
    
    In some cases, we might want to change portlet attributes
    before rendering it, skip it, or even update HasResults
    attribute after the portlet has been rendered.
    
    This patch adds callbacks before and after rendering
    portlets.

diff --git a/share/html/Dashboards/Elements/ShowPortlet/dashboard b/share/html/Dashboards/Elements/ShowPortlet/dashboard
index 14b343bb28..a15be262bb 100644
--- a/share/html/Dashboards/Elements/ShowPortlet/dashboard
+++ b/share/html/Dashboards/Elements/ShowPortlet/dashboard
@@ -77,6 +77,13 @@ Abort("Possible recursive dashboard detected.") if $Depth > 8;
 <%perl>
 local $session{CurrentUser} = $session{ContextUser};
 for my $portlet (@panes) {
+
+    my $skip_portlet = 0;
+    $m->callback(CallbackName => 'BeforeComponent', Dashboard => $Dashboard,
+        HasResults => $HasResults, Portlet => $portlet, ARGSRef => \%ARGS,
+        SkipPortlet => \$skip_portlet);
+    next if $skip_portlet;
+
     $m->comp($portlet->{portlet_type},
         Portlet    => $portlet,
         Rows       => $Rows,
@@ -86,6 +93,10 @@ for my $portlet (@panes) {
         Depth      => $Depth + 1,
         HasResults => $HasResults
     );
+
+    $m->callback(CallbackName => 'AfterComponent', Dashboard => $Dashboard,
+        HasResults => $HasResults, Portlet => $portlet, ARGSRef => \%ARGS);
+
 }
 </%perl>
 

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


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list