summaryrefslogtreecommitdiffstats
path: root/extensions/BugModal/Extension.pm
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/BugModal/Extension.pm')
-rw-r--r--extensions/BugModal/Extension.pm31
1 files changed, 31 insertions, 0 deletions
diff --git a/extensions/BugModal/Extension.pm b/extensions/BugModal/Extension.pm
index b1356bc34..f1f7fb5f0 100644
--- a/extensions/BugModal/Extension.pm
+++ b/extensions/BugModal/Extension.pm
@@ -20,9 +20,21 @@ use Bugzilla::User::Setting;
use Bugzilla::Util qw(trick_taint datetime_from html_quote time_ago);
use List::MoreUtils qw(any);
use Template::Stash;
+use JSON::XS qw(encode_json);
+use Scalar::Util qw(blessed);
our $VERSION = '1';
+use constant READABLE_BUG_STATUS_PRODUCTS => (
+ 'Core',
+ 'Toolkit',
+ 'Firefox',
+ 'Firefox for Android',
+ 'Firefox for iOS',
+ 'Bugzilla',
+ 'bugzilla.mozilla.org'
+);
+
# force skin to mozilla
sub settings_after_update {
my ($self, $args) = @_;
@@ -190,6 +202,25 @@ sub template_before_process {
vars => $vars,
});
+ if (any { $bug->product eq $_ } READABLE_BUG_STATUS_PRODUCTS) {
+ my @flags = map { { name => $_->name, status => $_->status } } @{$bug->flags};
+ $vars->{readable_bug_status_json} = encode_json({
+ dupe_of => $bug->dup_id,
+ id => $bug->id,
+ keywords => [ map { $_->name } @{$bug->keyword_objects} ],
+ priority => $bug->priority,
+ resolution => $bug->resolution,
+ status => $bug->bug_status,
+ flags => \@flags,
+ target_milestone => $bug->target_milestone,
+ map { $_->name => $_->bug_flag($bug->id)->value } @{$vars->{tracking_flags}},
+ });
+ # HTML4 attributes cannot be longer than this, so just skip it in this case.
+ if (length($vars->{readable_bug_status_json}) > 65536) {
+ delete $vars->{readable_bug_status_json};
+ }
+ }
+
# bug->choices loads a lot of data that we want to lazy-load
# just load the status and resolutions and perform extra checks here
# upstream does these checks in the bug/fields template