Skip to content

Commit 90b83ae

Browse files
authored
Bug 1892558: back out PR #74 because it broke show_bug (#143)
1 parent dc3b26c commit 90b83ae

File tree

2 files changed

+66
-19
lines changed

2 files changed

+66
-19
lines changed

extensions/BugModal/Extension.pm

+25-18
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ use JSON::XS qw(encode_json);
2525

2626
our $VERSION = '1';
2727

28+
use constant READABLE_BUG_STATUS_PRODUCTS => (
29+
'Core', 'Toolkit',
30+
'Firefox', 'Firefox for Android',
31+
'Firefox for iOS', 'Bugzilla',
32+
'bugzilla.mozilla.org'
33+
);
34+
2835
sub show_bug_format {
2936
my ($self, $args) = @_;
3037
$args->{format} = _alternative_show_bug_format();
@@ -194,24 +201,24 @@ sub template_before_process {
194201
file => 'bug/edit.html.tmpl', vars => $vars,
195202
});
196203

197-
# bugzilla-readable-status
198-
my @flags = map { {name => $_->name, status => $_->status} } @{$bug->flags};
199-
$vars->{readable_bug_status_json} = encode_json({
200-
dupe_of => $bug->dup_id,
201-
id => $bug->id,
202-
keywords => [map { $_->name } @{$bug->keyword_objects}],
203-
priority => $bug->priority,
204-
resolution => $bug->resolution,
205-
status => $bug->bug_status,
206-
flags => \@flags,
207-
target_milestone => $bug->target_milestone,
208-
Bugzilla->has_extension('TrackingFlags')
209-
? map { $_->name => $_->bug_flag($bug->id)->value } @{$vars->{tracking_flags}}
210-
: {},
211-
});
212-
# HTML4 attributes cannot be longer than this, so just skip it in this case.
213-
if (length($vars->{readable_bug_status_json}) > 65536) {
214-
delete $vars->{readable_bug_status_json};
204+
if (any { $bug->product eq $_ } READABLE_BUG_STATUS_PRODUCTS) {
205+
my @flags = map { {name => $_->name, status => $_->status} } @{$bug->flags};
206+
$vars->{readable_bug_status_json} = encode_json({
207+
dupe_of => $bug->dup_id,
208+
id => $bug->id,
209+
keywords => [map { $_->name } @{$bug->keyword_objects}],
210+
priority => $bug->priority,
211+
resolution => $bug->resolution,
212+
status => $bug->bug_status,
213+
flags => \@flags,
214+
target_milestone => $bug->target_milestone,
215+
map { $_->name => $_->bug_flag($bug->id)->value } @{$vars->{tracking_flags}},
216+
});
217+
218+
# HTML4 attributes cannot be longer than this, so just skip it in this case.
219+
if (length($vars->{readable_bug_status_json}) > 65536) {
220+
delete $vars->{readable_bug_status_json};
221+
}
215222
}
216223

217224
# bug->choices loads a lot of data that we want to lazy-load

extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl

+41-1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,46 @@
9292
END;
9393
END;
9494
END;
95+
96+
# build Firefox flags subtitle
97+
firefox_flags = [];
98+
firefox_fixed_versions = [];
99+
# project flags
100+
FOREACH row IN tracking_flags_table;
101+
NEXT UNLESS row.type == "project";
102+
status_value = row.status.bug_flag(bug.id).value;
103+
NEXT IF status_value == "---";
104+
firefox_flags.push(row.name _ ":" _ status_value);
105+
END;
106+
# tracking flags title and subtitle
107+
FOREACH row IN tracking_flags_table;
108+
NEXT UNLESS row.type == "tracking";
109+
tracking_value = row.tracking ? row.tracking.bug_flag(bug.id).value : "---";
110+
status_value = row.status.bug_flag(bug.id).value || "---";
111+
NEXT IF tracking_value == "---" && status_value == "---";
112+
blurb = row.name;
113+
IF tracking_value != "---";
114+
blurb = blurb _ tracking_value;
115+
END;
116+
IF status_value != "---";
117+
blurb = blurb _ " " _ status_value;
118+
IF status_value == "fixed" || status_value == "verified";
119+
flag_name = row.name;
120+
IF flag_name.substr(0, 7) == "firefox";
121+
IF firefox_fixed_versions.0 == "";
122+
firefox_fixed_versions.0 = "Firefox " _ flag_name.substr(7);
123+
END;
124+
END;
125+
END;
126+
END;
127+
firefox_flags.push(blurb);
128+
END;
129+
firefox_fixed_version = firefox_fixed_versions.join(", ");
130+
IF firefox_flags.size;
131+
firefox_flags_subtitle = firefox_flags.join(", ");
132+
ELSE;
133+
firefox_flags_subtitle = "Not tracked";
134+
END;
95135
%]
96136

97137
[% IF user.id %]
@@ -510,7 +550,7 @@
510550
[% END %]
511551
[% sub = [{ unfiltered = readable_bug_status_span }] %]
512552
[% ELSE %]
513-
[% sub = ["Not tracked"] %]
553+
[% sub = [firefox_flags_subtitle] %]
514554
[% END %]
515555
[% WRAPPER bug_modal/module.html.tmpl
516556
title = "Tracking"

0 commit comments

Comments
 (0)