From 3e8a6b2bdcd591af4e67002489a71753c7920c7a Mon Sep 17 00:00:00 2001
From: Byron Jones
Date: Tue, 15 Jul 2014 13:25:05 +0800
Subject: Bug 1036303: add a list of tracking/project/etc tracking flags to the
bugmail filtering prefs page
---
extensions/BugmailFilter/Extension.pm | 27 ++-
.../default/account/prefs/bugmail_filter.html.tmpl | 202 +++++++++++++--------
extensions/BugmailFilter/web/js/bugmail-filter.js | 5 +
extensions/TrackingFlags/Extension.pm | 5 +-
extensions/TrackingFlags/lib/Constants.pm | 6 -
5 files changed, 160 insertions(+), 85 deletions(-)
(limited to 'extensions')
diff --git a/extensions/BugmailFilter/Extension.pm b/extensions/BugmailFilter/Extension.pm
index 6bcfe70d6..60c180ca7 100644
--- a/extensions/BugmailFilter/Extension.pm
+++ b/extensions/BugmailFilter/Extension.pm
@@ -116,7 +116,7 @@ sub user_preferences {
# remove all tracking flag fields. these change too frequently to be of
# value, so they only add noise to the list.
- foreach my $field (@{ Bugzilla->tracking_flag_names }) {
+ foreach my $field (Bugzilla->tracking_flag_names) {
delete $fields{$field};
}
@@ -159,6 +159,27 @@ sub user_preferences {
}) }
];
+ # build a list of tracking-flags, grouped by type
+ require Bugzilla::Extension::TrackingFlags::Constants;
+ require Bugzilla::Extension::TrackingFlags::Flag;
+ my %flag_types =
+ map { $_->{name} => $_->{description} }
+ @{ Bugzilla::Extension::TrackingFlags::Constants::FLAG_TYPES() };
+ my %tracking_flags_by_type;
+ foreach my $flag (Bugzilla::Extension::TrackingFlags::Flag->get_all) {
+ my $type = $flag_types{$flag->flag_type};
+ $tracking_flags_by_type{$type} //= [];
+ push @{ $tracking_flags_by_type{$type} }, $flag;
+ }
+ my @tracking_flags_by_type;
+ foreach my $type (sort keys %tracking_flags_by_type) {
+ push @tracking_flags_by_type, {
+ name => $type,
+ flags => $tracking_flags_by_type{$type},
+ };
+ }
+ $vars->{tracking_flags_by_type} = \@tracking_flags_by_type;
+
${ $args->{handled} } = 1;
}
@@ -197,7 +218,7 @@ sub user_wants_mail {
require Bugzilla::Extension::TrackingFlags::Flag;
my %count;
my @tracking_flags;
- foreach my $field (@$fields, @{ Bugzilla->tracking_flag_names }) {
+ foreach my $field (@$fields, Bugzilla->tracking_flag_names) {
$count{$field}++;
}
foreach my $field (keys %count) {
@@ -212,7 +233,7 @@ sub user_wants_mail {
foreach my $type (keys %tracking_types) {
push @$fields, 'tracking.' . $type;
}
- foreach my $field (@{ Bugzilla->tracking_flag_names }) {
+ foreach my $field (Bugzilla->tracking_flag_names) {
$fields = [ grep { $_ ne $field } @$fields ];
}
diff --git a/extensions/BugmailFilter/template/en/default/account/prefs/bugmail_filter.html.tmpl b/extensions/BugmailFilter/template/en/default/account/prefs/bugmail_filter.html.tmpl
index 83c8d729a..1bcbd35ae 100644
--- a/extensions/BugmailFilter/template/en/default/account/prefs/bugmail_filter.html.tmpl
+++ b/extensions/BugmailFilter/template/en/default/account/prefs/bugmail_filter.html.tmpl
@@ -173,84 +173,142 @@ var cpts = new Array();
If multiple filters are applicable to the same [% terms.bug %] change,
include filters override exclude filters.
+
+
+Field Groups
+
- Examples:
+ Some fields are grouped into a single entry in the "field" list.
+ Following is a list of the groups and all the fields they contain:
+
+[% FOREACH type = tracking_flags_by_type %]
+ [% type.name FILTER html %]:
+
+ [% flag_count = type.flags.size %]
+ [% FOREACH flag = type.flags %]
+ [% IF flag_count > 10 && loop.count == 10 %]
+
+ …
+ (show all)
+
+
+ [% END %]
+ [% flag.description FILTER html FILTER no_break %]
+ [% ", " UNLESS loop.last %]
+ [% IF loop.last && flag_count > 10 %]
+
+ [% END %]
+ [% END %]
+
+[% END %]
+
+
+Examples
To never receive changes made to the "QA Whiteboard" field for [% terms.bugs %]
where you are not the assignee:
-
-
- Field: |
- QA Whiteboard |
-
-
- Product: |
- __Any__ |
-
-
- Component: |
- __Any__ |
-
-
- Relationship: |
- Not Assignee |
-
-
- Action: |
- Exclude |
-
-
+
+
+ Field: |
+ QA Whiteboard |
+
+
+ Product: |
+ __Any__ |
+
+
+ Component: |
+ __Any__ |
+
+
+ Relationship: |
+ Not Assignee |
+
+
+ Action: |
+ Exclude |
+
+
+
+
+ To receive notifications of new [% terms.bugs %] in Firefox's "New Tab Page"
+ component, and no other changes, you require three filters. First an
+ exclude filter to drop all changes made to [% terms.bugs %] in that
+ component:
+
+
+
+ Field: |
+ __Any__ |
+
+
+ Product: |
+ Firefox |
+
+
+ Component: |
+ New Tab Page |
+
+
+ Relationship: |
+ __Any__ |
+
+
+ Action: |
+ Exclude |
+
+
- To receive just comments made to Firefox [% terms.bugs %], and no other
- changes, you require two filters. First an exclude filter to drop all
- changes made to [% terms.bugs %] in that product:
-
-
- Field: |
- __Any__ |
-
-
- Product: |
- Firefox |
-
-
- Component: |
- __Any__ |
-
-
- Relationship: |
- __Any__ |
-
-
- Action: |
- Exclude |
-
-
-
Then an include filter to indicate that you want to receive
- comments:
-
-
- Field: |
- Comment Created |
-
-
- Product: |
- Firefox |
-
-
- Component: |
- __Any__ |
-
-
- Relationship: |
- __Any__ |
-
-
- Action: |
- Include |
-
-
+ notifications when a [% terms.bug %] is created:
+
+
+
+ Field: |
+ [% terms.Bug %] Created |
+
+
+ Product: |
+ Firefox |
+
+
+ Component: |
+ New Tab Page |
+
+
+ Relationship: |
+ __Any__ |
+
+
+ Action: |
+ Include |
+
+
+
+ And finally another include filter to catch when a [% terms.bug %] is
+ moved into the "New Tab Page" component.
+
+
+ Field: |
+ Component |
+
+
+ Product: |
+ Firefox |
+
+
+ Component: |
+ New Tab Page |
+
+
+ Relationship: |
+ __Any__ |
+
+
+ Action: |
+ Include |
+
+
diff --git a/extensions/BugmailFilter/web/js/bugmail-filter.js b/extensions/BugmailFilter/web/js/bugmail-filter.js
index e298a60f1..2b320bbbb 100644
--- a/extensions/BugmailFilter/web/js/bugmail-filter.js
+++ b/extensions/BugmailFilter/web/js/bugmail-filter.js
@@ -29,6 +29,11 @@ function onRemoveChange() {
Dom.get('remove').disabled = true;
}
+function showAllFlags() {
+ Dom.addClass('show_all', 'bz_default_hidden');
+ Dom.removeClass('all_flags', 'bz_default_hidden');
+}
+
Event.onDOMReady(function() {
Event.on('action', 'change', onFilterActionChange);
onFilterProductChange();
diff --git a/extensions/TrackingFlags/Extension.pm b/extensions/TrackingFlags/Extension.pm
index 9b3d46ad2..301c10245 100644
--- a/extensions/TrackingFlags/Extension.pm
+++ b/extensions/TrackingFlags/Extension.pm
@@ -32,10 +32,7 @@ BEGIN {
}
sub _tracking_flag_names {
- # return just a list of names, hitting the database directly to avoid the
- # overhead of object creation
- return Bugzilla->request_cache->{tracking_flag_names} ||=
- Bugzilla->dbh->selectcol_arrayref("SELECT name FROM tracking_flags");
+ return Bugzilla::Extension::TrackingFlags::Flag->get_all_names();
}
sub page_before_template {
diff --git a/extensions/TrackingFlags/lib/Constants.pm b/extensions/TrackingFlags/lib/Constants.pm
index b6813c3c2..0b1ae3a1a 100644
--- a/extensions/TrackingFlags/lib/Constants.pm
+++ b/extensions/TrackingFlags/lib/Constants.pm
@@ -34,12 +34,6 @@ sub FLAG_TYPES {
collapsed => 1,
sortkey => 2
},
- {
- name => 'b2g',
- description => 'B2G Flags',
- collapsed => 1,
- sortkey => 3
- },
);
return [ sort { $a->{'sortkey'} <=> $b->{'sortkey'} } @flag_types ];
}
--
cgit v1.2.3-24-g4f1b