diff options
Diffstat (limited to 'extensions')
6 files changed, 88 insertions, 14 deletions
diff --git a/extensions/BMO/Extension.pm b/extensions/BMO/Extension.pm index 717f347de..40a00a625 100644 --- a/extensions/BMO/Extension.pm +++ b/extensions/BMO/Extension.pm @@ -73,7 +73,8 @@ BEGIN { *Bugzilla::Product::default_platform = \&_product_default_platform; *Bugzilla::Product::default_op_sys = \&_product_default_op_sys; *Bugzilla::check_default_product_security_group = \&_check_default_product_security_group; - *Bugzilla::Attachment::is_bounty_attachment = \&_is_bounty_attachment; + *Bugzilla::Attachment::is_bounty_attachment = \&_attachment_is_bounty_attachment; + *Bugzilla::Attachment::bounty_details = \&_attachment_bounty_details; } sub template_before_process { @@ -224,7 +225,7 @@ sub bounty_attachment { my $input = Bugzilla->input_params; my $dbh = Bugzilla->dbh; my $bug = Bugzilla::Bug->check({ id => $input->{bug_id}, cache => 1 }); - my $attachment = first { $_ && _is_bounty_attachment($_) } @{$bug->attachments}; + my $attachment = first { $_ && _attachment_is_bounty_attachment($_) } @{$bug->attachments}; $vars->{bug} = $bug; if ($input->{submit}) { @@ -261,12 +262,11 @@ sub bounty_attachment { } if ($attachment) { - my $form = parse_bounty_attachment_description($attachment->description); - $vars->{form} = $form; + $vars->{form} = $attachment->bounty_details; } } -sub _is_bounty_attachment { +sub _attachment_is_bounty_attachment { my ($attachment) = @_; return 0 unless $attachment->filename eq 'bugbounty.data'; @@ -275,6 +275,19 @@ sub _is_bounty_attachment { return $attachment->description =~ /^(?:[^,]*,)+[^,]*$/; } +sub _attachment_bounty_details { + my ($attachment) = @_; + if (!exists $attachment->{bounty_details}) { + if ($attachment->is_bounty_attachment) { + $attachment->{bounty_details} = parse_bounty_attachment_description($attachment->description); + } + else { + $attachment->{bounty_details} = undef; + } + } + return $attachment->{bounty_details}; +} + sub format_bounty_attachment_description { my ($form) = @_; my @fields = ( diff --git a/extensions/BMO/template/en/default/hook/bug_modal/attachments-actions.html.tmpl b/extensions/BMO/template/en/default/hook/bug_modal/attachments-actions.html.tmpl new file mode 100644 index 000000000..97d0ed739 --- /dev/null +++ b/extensions/BMO/template/en/default/hook/bug_modal/attachments-actions.html.tmpl @@ -0,0 +1,13 @@ +[%# This Source Code Form is subject to the terms of the Mozilla Public + # License, v. 2.0. If a copy of the MPL was not distributed with this + # file, You can obtain one at http://mozilla.org/MPL/2.0/. + # + # This Source Code Form is "Incompatible With Secondary Licenses", as + # defined by the Mozilla Public License, v. 2.0. + #%] + +[% RETURN IF !user.in_group("bounty-team") || has_bounty_attachment %] +<button type="button" class="minor" + onclick="document.location='page.cgi?id=attachment_bounty_form.html&bug_id=[% bug.id FILTER none %]'"> + Add Bounty Tracking Attachment +</button> diff --git a/extensions/BMO/template/en/default/hook/bug_modal/attachments-row.html.tmpl b/extensions/BMO/template/en/default/hook/bug_modal/attachments-row.html.tmpl new file mode 100644 index 000000000..67ab62f5a --- /dev/null +++ b/extensions/BMO/template/en/default/hook/bug_modal/attachments-row.html.tmpl @@ -0,0 +1,32 @@ +[%# This Source Code Form is subject to the terms of the Mozilla Public + # License, v. 2.0. If a copy of the MPL was not distributed with this + # file, You can obtain one at http://mozilla.org/MPL/2.0/. + # + # This Source Code Form is "Incompatible With Secondary Licenses", as + # defined by the Mozilla Public License, v. 2.0. + #%] + +[% + RETURN UNLESS attachment.is_bounty_attachment; + has_bounty_attachment = 1; + attachment_rendered = 1; + bounty = attachment.bounty_details; +%] +<tr class="bz_private"> + <td colspan="2"> + Bounty: [% bounty.reporter_email FILTER html %] + $[% bounty.amount_paid || '-' FILTER html %]<br> + Reported: [% bounty.reported_date || '-' FILTER html %] + Fixed: [% bounty.fixed_date || '-' FILTER html %] + Awarded: [% bounty.awarded_date || '-' FILTER html %] + Publish: [% bounty.publish ? "Yes" : "No" FILTER none %]<br> + [% IF bounty.credit.size %] + Credit: [% bounty.credit.join(", ") FILTER html %] + [% END %] + </td> + <td class="attach-actions"> + <a href="page.cgi?id=attachment_bounty_form.html&bug_id=[% bug.id FILTER none %]"> + Edit Bounty + </a> + </td> +</tr> diff --git a/extensions/BugModal/template/en/default/bug_modal/attachments.html.tmpl b/extensions/BugModal/template/en/default/bug_modal/attachments.html.tmpl index f9209d3bf..8e04392d8 100644 --- a/extensions/BugModal/template/en/default/bug_modal/attachments.html.tmpl +++ b/extensions/BugModal/template/en/default/bug_modal/attachments.html.tmpl @@ -8,11 +8,18 @@ [%# # bug: (bug object) the main bug object + # active_attachments: array of active attachment objects + # obsolete_attachments: array of obsolete attachment objects #%] <table class="layout-table" id="attachments"> [% FOREACH attachment IN bug.attachments %] - [% NEXT IF attachment.isprivate && !(user.is_insider || attachment.attacher.id == user.id) %] + [% + NEXT IF attachment.isprivate && !(user.is_insider || attachment.attacher.id == user.id); + attachment_rendered = 0; + Hook.process("row"); + NEXT IF attachment_rendered; + %] <tr class=" [%~ " bz_private" IF attachment.isprivate %] [%~ " attach-obsolete" IF attachment.isobsolete %] @@ -67,3 +74,10 @@ </tr> [% END %] </table> + +<div id="attachments-actions"> + [% IF obsolete_attachments %] + <button type="button" id="attachments-obsolete-btn" class="minor">Show Obsolete Attachments</button> + [% END %] + [% Hook.process('actions') %] +</div> diff --git a/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl b/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl index f9c93efd1..54ae9bec0 100644 --- a/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl +++ b/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl @@ -922,12 +922,10 @@ subtitle = sub.join(", ") collapsed = active_attachments == 0 %] - [% INCLUDE bug_modal/attachments.html.tmpl %] - [% IF obsolete_attachments %] - <div id="attachments-actions"> - <button type="button" id="attachments-obsolete-btn" class="minor">Show Obsolete Attachments</button> - </div> - [% END %] + [% INCLUDE bug_modal/attachments.html.tmpl + active_attachments = active_attachments + obsolete_attachments = obsolete_attachments + %] [% END %] [% END %] diff --git a/extensions/BugModal/web/bug_modal.css b/extensions/BugModal/web/bug_modal.css index b9e6817fc..f35ac415d 100644 --- a/extensions/BugModal/web/bug_modal.css +++ b/extensions/BugModal/web/bug_modal.css @@ -319,6 +319,10 @@ input[type="number"] { /* attachments */ +#module-attachments .module-content { + padding: 0; +} + #attachments { width: 100%; } @@ -379,8 +383,8 @@ input[type="number"] { display: inline; } -#attachments-actions { - padding: 2px; +#attachments-actions button { + margin: 2px; } #attachments .attach-flag .vcard { |