summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
authorByron Jones <glob@mozilla.com>2015-06-15 06:49:59 +0200
committerByron Jones <glob@mozilla.com>2015-06-15 06:49:59 +0200
commitc290f3ecabec75b741d375e6130af9060255c274 (patch)
tree7f52627f41229c6d52a7b2115429c2ac408f438e /extensions
parentac09f71cfd3e84a01a157a8cba21aec5513a0b14 (diff)
downloadbugzilla-c290f3ecabec75b741d375e6130af9060255c274.tar.gz
bugzilla-c290f3ecabec75b741d375e6130af9060255c274.tar.xz
Bug 1146774: treeherder/tbpl comments are not automatically collapsed
Diffstat (limited to 'extensions')
-rw-r--r--extensions/BugModal/Extension.pm3
-rw-r--r--extensions/BugModal/lib/ActivityStream.pm11
-rw-r--r--extensions/BugModal/lib/MonkeyPatches.pm13
-rw-r--r--extensions/BugModal/template/en/default/bug_modal/activity_stream.html.tmpl9
-rw-r--r--extensions/BugModal/web/comments.js28
5 files changed, 54 insertions, 10 deletions
diff --git a/extensions/BugModal/Extension.pm b/extensions/BugModal/Extension.pm
index 0c007c2d9..12245dc54 100644
--- a/extensions/BugModal/Extension.pm
+++ b/extensions/BugModal/Extension.pm
@@ -254,6 +254,9 @@ sub template_before_process {
}
}
$vars->{tracking_flags_table} = \@tracking_table;
+
+ # for the "view -> hide treeherder comments" menu item
+ $vars->{treeherder} = Bugzilla->treeherder_user;
}
sub bug_start_of_set_all {
diff --git a/extensions/BugModal/lib/ActivityStream.pm b/extensions/BugModal/lib/ActivityStream.pm
index b66352031..a69790044 100644
--- a/extensions/BugModal/lib/ActivityStream.pm
+++ b/extensions/BugModal/lib/ActivityStream.pm
@@ -109,12 +109,21 @@ sub _add_activity_to_stream {
sub _add_comments_to_stream {
my ($bug, $stream) = @_;
my $user = Bugzilla->user;
+ my $treeherder_id = Bugzilla->treeherder_user->id;
my $raw_comments = $bug->comments();
foreach my $comment (@$raw_comments) {
next if $comment->type == CMT_HAS_DUPE;
- next if $comment->is_private && !($user->is_insider || $user->id == $comment->author->id);
+ my $author_id = $comment->author->id;
+ next if $comment->is_private && !($user->is_insider || $user->id == $author_id);
next if $comment->body eq '' && ($comment->work_time - 0) != 0 && !$user->is_timetracker;
+
+ # treeherder is so spammy we hide its comments by default
+ if ($author_id == $treeherder_id) {
+ $comment->{collapsed} = 1;
+ $comment->{collapsed_reason} = $comment->author->name;
+ }
+
_add_comment_to_stream($stream, date_str_to_time($comment->creation_ts), $comment->author->id, $comment);
}
}
diff --git a/extensions/BugModal/lib/MonkeyPatches.pm b/extensions/BugModal/lib/MonkeyPatches.pm
index 596746b32..c2e24f5ce 100644
--- a/extensions/BugModal/lib/MonkeyPatches.pm
+++ b/extensions/BugModal/lib/MonkeyPatches.pm
@@ -8,6 +8,19 @@
package Bugzilla::Extension::BugModal::MonkeyPatches;
1;
+package Bugzilla;
+use strict;
+use warnings;
+
+use Bugzilla::User;
+
+sub treeherder_user {
+ return Bugzilla->process_cache->{treeherder_user} //=
+ Bugzilla::User->new({ name => 'tbplbot@gmail.com', cache => 1 })
+ || Bugzilla::User->new({ name => 'treeherder@bots.tld', cache => 1 })
+ || Bugzilla::User->new();
+}
+
package Bugzilla::Bug;
use strict;
use warnings;
diff --git a/extensions/BugModal/template/en/default/bug_modal/activity_stream.html.tmpl b/extensions/BugModal/template/en/default/bug_modal/activity_stream.html.tmpl
index 7ea74b469..33d8e73c6 100644
--- a/extensions/BugModal/template/en/default/bug_modal/activity_stream.html.tmpl
+++ b/extensions/BugModal/template/en/default/bug_modal/activity_stream.html.tmpl
@@ -19,17 +19,18 @@
<menuitem id="view-comments-only" label="Comments Only"></menuitem>
<hr>
<menuitem id="view-toggle-cc" label="Show CC Changes"></menuitem>
- [% Hook.process('comments-toggle-menu') %]
+ <menuitem id="view-toggle-treeherder" label="Hide Treeherder Comments" data-userid="[% treeherder.id FILTER none %]"></menuitem>
</menu>
[%
PROCESS bug/time.html.tmpl;
FOREACH change_set IN bug.activity_stream;
+ extra_class = change_set.comment.collapsed ? " ca-" _ change_set.comment.author.id : "";
IF change_set.cc_only;
- '<div class="change-set cc-only" id="' _ change_set.id _ '" style="display:none">';
+ '<div class="change-set cc-only' _ extra_class _ '" id="' _ change_set.id _ '" style="display:none">';
ELSE;
- '<div class="change-set" id="' _ change_set.id _ '">';
+ '<div class="change-set' _ extra_class _ '" id="' _ change_set.id _ '">';
END;
extra_class = "";
@@ -155,7 +156,7 @@
<tr>
<td class="comment-collapse-reason"
title="[% comment.author.moz_nick FILTER html %] [[% comment.creation_ts FILTER time_duration FILTER html %]]">
- Comment hidden ([% comment.tags.join(', ') FILTER html %])
+ Comment hidden ([% comment.collapsed_reason FILTER html %])
</td>
<td class="comment-actions">
<button type="button" class="change-spinner minor" id="ccs-[% comment.count FILTER none %]">
diff --git a/extensions/BugModal/web/comments.js b/extensions/BugModal/web/comments.js
index f9852cd0e..b18f7d3d1 100644
--- a/extensions/BugModal/web/comments.js
+++ b/extensions/BugModal/web/comments.js
@@ -72,7 +72,7 @@ $(function() {
$('#c' + id).find('.comment-tags').hide();
$('#c' + id).find('.gravatar').css('width', '16px').css('height', '16px');
$('#cr-' + id).hide();
- spinner.text('+');
+ realSpinner.text('+');
}
else if (forced == 'show') {
if (defaultCollapsed) {
@@ -87,14 +87,14 @@ $(function() {
$('#c' + id).find('.comment-tags').show();
$('#c' + id).find('.gravatar').css('width', '32px').css('height', '32px');
$('#cr-' + id).show();
- spinner.text('-');
+ realSpinner.text('-');
}
else {
$('#ct-' + id).slideToggle('fast', function() {
$('#c' + id).find(activitySelector).toggle();
- $('#c' + id).find('.comment-tags').toggle();
if ($('#ct-' + id + ':visible').length) {
- spinner.text('-');
+ $('#c' + id).find('.comment-tags').show();
+ realSpinner.text('-');
$('#cr-' + id).show();
if (BUGZILLA.user.id !== 0)
$('#ctag-' + id).show();
@@ -105,7 +105,8 @@ $(function() {
}
}
else {
- spinner.text('+');
+ $('#c' + id).find('.comment-tags').hide();
+ realSpinner.text('+');
$('#cr-' + id).hide();
if (BUGZILLA.user.id !== 0)
$('#ctag-' + id).hide();
@@ -171,6 +172,23 @@ $(function() {
}
});
+ $('#view-toggle-treeherder')
+ .click(function() {
+ var that = $(this);
+ console.log(that.data('userid'));
+ var item = $('.context-menu-item.hover');
+ if (that.data('hidden') === '1') {
+ that.data('hidden', '0');
+ item.text('Hide Treeherder Comments');
+ $('.ca-' + that.data('userid')).show();
+ }
+ else {
+ that.data('hidden', '1');
+ item.text('Show Treeherder Comments');
+ $('.ca-' + that.data('userid')).hide();
+ }
+ });
+
$.contextMenu({
selector: '#view-menu-btn',
trigger: 'left',