Skip to content

Commit b2e5e84

Browse files
committed
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.
1 parent cf34cad commit b2e5e84

File tree

1 file changed

+15
-0
lines changed
  • share/html/Dashboards/Elements/ShowPortlet

1 file changed

+15
-0
lines changed

share/html/Dashboards/Elements/ShowPortlet/dashboard

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,18 @@ Abort("Possible recursive dashboard detected.") if $Depth > 8;
7676

7777
<%perl>
7878
local $session{CurrentUser} = $session{ContextUser};
79+
80+
$m->callback(CallbackName => 'BeforePanes', Dashboard => $current_dashboard,
81+
HasResults => $HasResults, Portlet => $Portlet, ARGSRef => \%ARGS);
82+
7983
for my $portlet (@panes) {
84+
85+
my $skip_portlet = 0;
86+
$m->callback(CallbackName => 'BeforeComponent', Dashboard => $current_dashboard,
87+
HasResults => $HasResults, Portlet => $portlet, ARGSRef => \%ARGS,
88+
SkipPortlet => \$skip_portlet);
89+
next if $skip_portlet;
90+
8091
$m->comp($portlet->{portlet_type},
8192
Portlet => $portlet,
8293
Rows => $Rows,
@@ -86,6 +97,10 @@ for my $portlet (@panes) {
8697
Depth => $Depth + 1,
8798
HasResults => $HasResults
8899
);
100+
101+
$m->callback(CallbackName => 'AfterComponent', Dashboard => $current_dashboard,
102+
HasResults => $HasResults, Portlet => $portlet, ARGSRef => \%ARGS);
103+
89104
}
90105
</%perl>
91106

0 commit comments

Comments
 (0)