From 4434d09061b49fd96fcdac4210edaab4a2d83722 Mon Sep 17 00:00:00 2001 From: Dylan Hardison Date: Tue, 24 May 2016 09:45:40 -0400 Subject: Bug 1268305 - Integrate Readable Bug Status in Bug Detail Page --- extensions/BugModal/Extension.pm | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'extensions/BugModal/Extension.pm') 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 -- cgit v1.2.3-24-g4f1b