Skip to content

Commit 158005e

Browse files
Merge branch '6.0/render-dashboard-charts-via-dump-dom' into 6.0-trunk
2 parents cba7a01 + 0f8d840 commit 158005e

7 files changed

Lines changed: 325 additions & 140 deletions

File tree

docs/UPGRADING-6.0

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,8 @@ While it has been possible to use JSChart to generate chart images in the RT UI,
187187
because these images are generated client-side it hasn't been possible to include
188188
them in dashboard emails.
189189

190-
It is now possible to use the optional Perl module L<WWW::Mechanize::Chrome> and
191-
a compatible server-side web browser to create images of the JSChart graphs for
192-
inclusion in emails.
190+
It is now possible to use a compatible server-side Chrome-based browser to
191+
create images of the JSChart graphs for inclusion in emails.
193192

194193
This is accomplished by setting C<$EmailDashboardIncludeCharts> to '1' and
195194
maybe also setting C<$ChromePath> to the path of the executable for your

etc/RT_Config.pm.in

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,11 +1041,12 @@ Set($EmailDashboardInlineCSS, 0);
10411041

10421042
=item C<$EmailDashboardIncludeCharts>
10431043

1044-
To use the JSChart-generated images in emailed dashboards, install the
1045-
optional module L<WWW::Mechanize::Chrome> and enable this option.
1044+
To include the JSChart-generated images in emailed dashboards, enable this
1045+
option.
10461046

1047-
You will also need a chrome-based browser installed on the RT server.
1048-
See also C<$ChromePath> and C<@ChromeLaunchArguments>.
1047+
You will need a Chrome-based browser (such as Chromium) installed on the RT
1048+
server; RT renders the charts by running it headless. See also C<$ChromePath>
1049+
and C<@ChromeLaunchArguments>.
10491050

10501051
=cut
10511052

@@ -1055,25 +1056,22 @@ Set($EmailDashboardIncludeCharts, @RT_DASHBOARD_CHART_EMAILS@);
10551056

10561057
This option contains the path for a compatible Chrome-based browser
10571058
executable that will be used to generate static images for JSChart
1058-
graphs for dashboard emails.
1059-
1060-
See also L<WWW::Mechanize::Chrome/launch_exe>
1059+
graphs for dashboard emails. A bare command name (the default,
1060+
C<chromium>) is looked up in C<PATH>.
10611061

10621062
=cut
10631063

10641064
Set($ChromePath, 'chromium');
10651065

10661066
=item C<@ChromeLaunchArguments>
10671067

1068-
This option contains the launch arguments when initializing
1069-
L<WWW::Mechanize::Chrome>.
1070-
1071-
If you need to run L<rt-email-dashboards> as root, you probably need to add
1072-
C<--no-sandbox> to get around Chrome's restriction:
1068+
This option contains extra command-line arguments passed to the
1069+
Chrome-based browser when rendering dashboard charts, for example:
10731070

10741071
Set(@ChromeLaunchArguments, '--no-sandbox');
10751072

1076-
See also L<WWW::Mechanize::Chrome/launch_arg>
1073+
When L<rt-email-dashboards> runs as root, C<--no-sandbox> is added
1074+
automatically, since Chrome refuses to run as root otherwise.
10771075

10781076
=cut
10791077

etc/cpanfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ feature 'externalauth' => sub {
221221
};
222222

223223
feature 'dashboard-chart-emails' => sub {
224-
requires 'WWW::Mechanize::Chrome';
224+
requires 'File::Which';
225225
};
226226

227227
# External attachment storage

lib/RT/Config.pm

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,15 +2087,22 @@ our %META;
20872087
my $self = shift;
20882088
return unless $self->Get('EmailDashboardIncludeCharts');
20892089

2090-
if ( RT::StaticUtil::RequireModule('WWW::Mechanize::Chrome') ) {
2091-
my $chrome = RT->Config->Get('ChromePath') || 'chromium';
2092-
if ( !WWW::Mechanize::Chrome->find_executable( $chrome ) ) {
2093-
RT->Logger->warning("Can't find chrome executable from \$ChromePath value '$chrome', disabling \$EmailDashboardIncludeCharts");
2094-
$self->Set( 'EmailDashboardIncludeCharts', 0 );
2095-
}
2090+
my $chrome = $self->Get('ChromePath') || 'chromium';
2091+
unless ( RT::StaticUtil::RequireModule('File::Which') ) {
2092+
RT->Logger->warning('File::Which is not installed, disabling $EmailDashboardIncludeCharts');
2093+
$self->Set( 'EmailDashboardIncludeCharts', 0 );
2094+
return;
2095+
}
2096+
2097+
if ( my $path = File::Which::which($chrome) ) {
2098+
2099+
# Cache the resolved path for the mailer.
2100+
$self->Set( 'ChromePath', $path );
20962101
}
20972102
else {
2098-
RT->Logger->warning('WWW::Mechanize::Chrome is not installed, disabling $EmailDashboardIncludeCharts');
2103+
RT->Logger->warning(
2104+
"Can't find a Chrome-based browser from \$ChromePath value '$chrome', disabling \$EmailDashboardIncludeCharts"
2105+
);
20992106
$self->Set( 'EmailDashboardIncludeCharts', 0 );
21002107
}
21012108
},

0 commit comments

Comments
 (0)