Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1892558: back out PR #74 because it broke show_bug #143

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 25 additions & 18 deletions extensions/BugModal/Extension.pm
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ use JSON::XS qw(encode_json);

our $VERSION = '1';

use constant READABLE_BUG_STATUS_PRODUCTS => (
'Core', 'Toolkit',
'Firefox', 'Firefox for Android',
'Firefox for iOS', 'Bugzilla',
'bugzilla.mozilla.org'
);

sub show_bug_format {
my ($self, $args) = @_;
$args->{format} = _alternative_show_bug_format();
Expand Down Expand Up @@ -194,24 +201,24 @@ sub template_before_process {
file => 'bug/edit.html.tmpl', vars => $vars,
});

# bugzilla-readable-status
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,
Bugzilla->has_extension('TrackingFlags')
? 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};
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
Expand Down
42 changes: 41 additions & 1 deletion extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,46 @@
END;
END;
END;

# build Firefox flags subtitle
firefox_flags = [];
firefox_fixed_versions = [];
# project flags
FOREACH row IN tracking_flags_table;
NEXT UNLESS row.type == "project";
status_value = row.status.bug_flag(bug.id).value;
NEXT IF status_value == "---";
firefox_flags.push(row.name _ ":" _ status_value);
END;
# tracking flags title and subtitle
FOREACH row IN tracking_flags_table;
NEXT UNLESS row.type == "tracking";
tracking_value = row.tracking ? row.tracking.bug_flag(bug.id).value : "---";
status_value = row.status.bug_flag(bug.id).value || "---";
NEXT IF tracking_value == "---" && status_value == "---";
blurb = row.name;
IF tracking_value != "---";
blurb = blurb _ tracking_value;
END;
IF status_value != "---";
blurb = blurb _ " " _ status_value;
IF status_value == "fixed" || status_value == "verified";
flag_name = row.name;
IF flag_name.substr(0, 7) == "firefox";
IF firefox_fixed_versions.0 == "";
firefox_fixed_versions.0 = "Firefox " _ flag_name.substr(7);
END;
END;
END;
END;
firefox_flags.push(blurb);
END;
firefox_fixed_version = firefox_fixed_versions.join(", ");
IF firefox_flags.size;
firefox_flags_subtitle = firefox_flags.join(", ");
ELSE;
firefox_flags_subtitle = "Not tracked";
END;
%]

[% IF user.id %]
Expand Down Expand Up @@ -510,7 +550,7 @@
[% END %]
[% sub = [{ unfiltered = readable_bug_status_span }] %]
[% ELSE %]
[% sub = ["Not tracked"] %]
[% sub = [firefox_flags_subtitle] %]
[% END %]
[% WRAPPER bug_modal/module.html.tmpl
title = "Tracking"
Expand Down
Loading