Skip to content

Commit

Permalink
Bug 1268305 - Integrate Readable Bug Status in Bug Detail Page
Browse files Browse the repository at this point in the history
  • Loading branch information
Dylan Hardison committed May 24, 2016
1 parent 915f99d commit 4434d09
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 3 deletions.
31 changes: 31 additions & 0 deletions extensions/BugModal/Extension.pm
Expand Up @@ -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) = @_;
Expand Down Expand Up @@ -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
Expand Down
13 changes: 10 additions & 3 deletions extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl
Expand Up @@ -312,6 +312,13 @@
[% END %]

[%# === status === %]
[% IF readable_bug_status_json %]
[% readable_bug_status_span = BLOCK -%]
[%- %]<span id="readable-bug-status" data-readable-bug-status="[% readable_bug_status_json FILTER html %]"></span>
[% END %]

[% subtitle = [{ unfiltered = readable_bug_status_span }] %]
[% END %]

[% WRAPPER bug_modal/module.html.tmpl
title = "Status"
Expand All @@ -321,10 +328,10 @@
[%# product %]
[% can_edit_product = bug.check_can_change_field("product", 0, 1) %]
[% WRAPPER bug_modal/field.html.tmpl
field = bug_fields.product
field_type = constants.FIELD_TYPE_SINGLE_SELECT
field = bug_fields.product
field_type = constants.FIELD_TYPE_SINGLE_SELECT
hide_on_edit = can_edit_product
help = "describecomponents.cgi"
help = "describecomponents.cgi"
%]
<span class="spin-latch" id="product-latch" data-latch="#product-latch" data-for="#product-info">&#9656;</span>
<div class="spin-toggle" data-latch="#product-latch" data-for="#product-info">
Expand Down
Expand Up @@ -53,6 +53,7 @@
"extensions/BugModal/web/bug_modal.js",
"extensions/BugModal/web/comments.js",
"extensions/BugModal/web/ZeroClipboard/ZeroClipboard.min.js",
"js/bugzilla-readable-status-min.js",
"js/field.js",
"js/comments.js",
"js/util.js"
Expand Down
3 changes: 3 additions & 0 deletions extensions/BugModal/web/bug_modal.js
Expand Up @@ -735,6 +735,9 @@ $(function() {
var other = $(that.attr('id') == 'dup_id' ? '#bottom-dup_id' : '#dup_id');
other.val(that.val());
});
var rbs = $("#readable-bug-status");
var rbs_text = bugzillaReadableStatus.readable(rbs.data('readable-bug-status'));
rbs.text(rbs_text);

// add see-also button
$('.bug-urls-btn')
Expand Down
7 changes: 7 additions & 0 deletions js/bugzilla-readable-status-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4434d09

Please sign in to comment.