Skip to content

Commit

Permalink
Add callbacks to dashboard portlet rendering
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
richieri-bps committed Feb 27, 2024
1 parent 2f3797b commit 69d8c74
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions share/html/Dashboards/Elements/ShowPortlet/dashboard
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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>

0 comments on commit 69d8c74

Please sign in to comment.