Skip to content

Commit

Permalink
Added debug option to see the graph text; Added mermaid_quote functio…
Browse files Browse the repository at this point in the history
…n for quoting special characters
  • Loading branch information
dklawren committed Jun 24, 2024
1 parent e4c0de8 commit ec8ddc7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
12 changes: 11 additions & 1 deletion Bugzilla/Util.pm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use base qw(Exporter);
get_text template_var disable_utf8
enable_utf8 detect_encoding email_filter
round extract_nicks fetch_product_versions mojo_user_agent
is_fake_recipient_address);
is_fake_recipient_address mermaid_quote);
use Bugzilla::Logging;
use Bugzilla::Constants;
use Bugzilla::RNG qw(irand);
Expand Down Expand Up @@ -1052,6 +1052,16 @@ sub is_fake_recipient_address {
return 0;
}

# We need to escape ([ and ]) characters for the mermaid summaries
sub mermaid_quote {
my $text = shift;
$text =~ s/[(]/#40;/g;
$text =~ s/[)]/#41;/g;
$text =~ s/\[/#91;/g;
$text =~ s/\]/#93;/g;
return $text;
}

1;

__END__
Expand Down
5 changes: 4 additions & 1 deletion showdependencygraph.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use Bugzilla;
use Bugzilla::Bug;
use Bugzilla::Constants;
use Bugzilla::Error;
use Bugzilla::Util qw(detaint_natural);
use Bugzilla::Util qw(detaint_natural mermaid_quote);

use List::Util qw(none);

Expand Down Expand Up @@ -79,6 +79,7 @@ my $add_link = sub {
$link_text .= "$dependson";

if ($show_summary && $user->can_see_bug($dependson)) {
$dependson_summary = mermaid_quote($dependson_summary);
$link_text .= "<br>$dependson_status $dependson_resolution $dependson_summary";
}

Expand All @@ -91,6 +92,7 @@ my $add_link = sub {
$link_text .= "$blocked";

if ($show_summary && $user->can_see_bug($blocked)) {
$blocked_summary = mermaid_quote($blocked_summary);
$link_text .= "<br>$blocked_status $blocked_resolution $blocked_summary";
}

Expand Down Expand Up @@ -197,6 +199,7 @@ $vars->{'multiple_bugs'} = ($cgi->param('id') =~ /[ ,]/);
$vars->{'display'} = $display;
$vars->{'rankdir'} = $rankdir;
$vars->{'showsummary'} = $cgi->param('showsummary');
$vars->{'debug'} = ($cgi->param('debug') ? 1 : 0);

# Generate and return the UI (HTML page) from the appropriate template.
print $cgi->header();
Expand Down
8 changes: 7 additions & 1 deletion template/en/default/bug/dependency-graph.html.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,14 @@
Green circles represent open [% terms.bugs %].
</p>

[% IF debug %]
<pre>
[% graph_data FILTER html %]
</pre>
[% END %]

<pre class="mermaid">
[% graph_data FILTER none %]
[% graph_data FILTER html %]
</pre>

<script [% script_nonce FILTER none %]>
Expand Down

0 comments on commit ec8ddc7

Please sign in to comment.