summaryrefslogtreecommitdiffstats
path: root/extensions/BMO
diff options
context:
space:
mode:
authorByron Jones <glob@mozilla.com>2015-05-22 07:33:40 +0200
committerByron Jones <glob@mozilla.com>2015-05-22 07:33:40 +0200
commit0677733f0afbf6e4b5b414e8ae928dea34bff893 (patch)
tree8f836f9da7745f0bbc25f8ecd70cebe26d054cba /extensions/BMO
parentb09be15c170b39ec2c1553efcfd8f795e4847ad5 (diff)
downloadbugzilla-0677733f0afbf6e4b5b414e8ae928dea34bff893.tar.gz
bugzilla-0677733f0afbf6e4b5b414e8ae928dea34bff893.tar.xz
Bug 1135164: display a warning on show_bug when an unassigned bug has a patch attached
Diffstat (limited to 'extensions/BMO')
-rw-r--r--extensions/BMO/Extension.pm19
-rw-r--r--extensions/BMO/template/en/default/hook/attachment/list-warnings.html.tmpl18
-rw-r--r--extensions/BMO/template/en/default/hook/bug_modal/attachments-warnings.html.tmpl16
-rw-r--r--extensions/BMO/web/styles/bug_modal.css8
-rw-r--r--extensions/BMO/web/styles/edit_bug.css8
5 files changed, 69 insertions, 0 deletions
diff --git a/extensions/BMO/Extension.pm b/extensions/BMO/Extension.pm
index 02824f471..1c25da749 100644
--- a/extensions/BMO/Extension.pm
+++ b/extensions/BMO/Extension.pm
@@ -65,6 +65,8 @@ our $VERSION = '0.1';
BEGIN {
*Bugzilla::Bug::last_closed_date = \&_last_closed_date;
*Bugzilla::Bug::reporters_hw_os = \&_bug_reporters_hw_os;
+ *Bugzilla::Bug::is_unassigned = \&_bug_is_unassigned;
+ *Bugzilla::Bug::has_patch = \&_bug_has_patch;
*Bugzilla::Product::default_security_group = \&_default_security_group;
*Bugzilla::Product::default_security_group_obj = \&_default_security_group_obj;
*Bugzilla::Product::group_always_settable = \&_group_always_settable;
@@ -761,6 +763,23 @@ sub _bug_reporters_hw_os {
return $self->{ua_hw_os} = $hw_os;
}
+sub _bug_is_unassigned {
+ my ($self) = @_;
+ my $assignee = $self->assigned_to->login;
+ return $assignee eq 'nobody@mozilla.org' || $assignee =~ /\.bugs$/;
+}
+
+sub _bug_has_patch {
+ my ($self) = @_;
+ foreach my $attachment (@{ $self->attachments }) {
+ return 1 if
+ $attachment->ispatch
+ || $attachment->contenttype eq 'text/x-github-pull-request'
+ || $attachment->contenttype eq 'text/x-review-board-request';
+ }
+ return 0;
+}
+
sub _product_default_platform_id { $_[0]->{default_platform_id} }
sub _product_default_op_sys_id { $_[0]->{default_op_sys_id} }
diff --git a/extensions/BMO/template/en/default/hook/attachment/list-warnings.html.tmpl b/extensions/BMO/template/en/default/hook/attachment/list-warnings.html.tmpl
new file mode 100644
index 000000000..11998e12f
--- /dev/null
+++ b/extensions/BMO/template/en/default/hook/attachment/list-warnings.html.tmpl
@@ -0,0 +1,18 @@
+[%# 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 user.in_group('editbugs');
+ RETURN UNLESS bug.attachments.size && bug.is_unassigned && bug.has_patch;
+%]
+<tr class="bz_attach_footer">
+ <td colspan="[% show_attachment_flags ? 3 : 2 %]" id="unassigned_with_patches">
+ <img src="extensions/BMO/web/images/sign_warning.png" width="16" height="16">
+ Unassigned [% terms.bug %] with patches attached
+ </td>
+</tr>
diff --git a/extensions/BMO/template/en/default/hook/bug_modal/attachments-warnings.html.tmpl b/extensions/BMO/template/en/default/hook/bug_modal/attachments-warnings.html.tmpl
new file mode 100644
index 000000000..ca2a5a58c
--- /dev/null
+++ b/extensions/BMO/template/en/default/hook/bug_modal/attachments-warnings.html.tmpl
@@ -0,0 +1,16 @@
+[%# 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 user.in_group('editbugs');
+ RETURN UNLESS bug.attachments.size && bug.is_unassigned && bug.has_patch;
+%]
+<div id="unassigned_with_patches">
+ <img src="extensions/BMO/web/images/sign_warning.png" width="16" height="16">
+ Unassigned [% terms.bug %] with patches attached
+</div>
diff --git a/extensions/BMO/web/styles/bug_modal.css b/extensions/BMO/web/styles/bug_modal.css
index 0c54ce64a..3de7bde8b 100644
--- a/extensions/BMO/web/styles/bug_modal.css
+++ b/extensions/BMO/web/styles/bug_modal.css
@@ -12,3 +12,11 @@
border: 1px solid #ddd;
border-radius: 4px;
}
+
+#unassigned_with_patches {
+ padding-left: 4px;
+}
+
+#unassigned_with_patches img {
+ vertical-align: sub;
+}
diff --git a/extensions/BMO/web/styles/edit_bug.css b/extensions/BMO/web/styles/edit_bug.css
index a5dc72d0c..7da05a126 100644
--- a/extensions/BMO/web/styles/edit_bug.css
+++ b/extensions/BMO/web/styles/edit_bug.css
@@ -39,3 +39,11 @@ input#cf_rank {
text-align: right;
width: 3em;
}
+
+#unassigned_with_patches {
+ font-weight: normal;
+}
+
+#unassigned_with_patches img {
+ vertical-align: sub;
+}