$vars->{tracking_flags_table} = \@tracking_table;
# for the "view -> hide treeherder comments" menu item
- my $treeherder_id = Bugzilla->treeherder_user->id;
+ my @treeherder_ids = map { $_->id } @{Bugzilla->treeherder_users};
foreach my $change_set (@{ $bug->activity_stream }) {
- if ($change_set->{comment} && $change_set->{comment}->author->id == $treeherder_id) {
- $vars->{treeherder} = Bugzilla->treeherder_user;
+ if ($change_set->{comment} &&
+ any { $change_set->{comment}->author->id == $_ } @treeherder_ids){
+ $vars->{treeherder_user_ids} = \@treeherder_ids;
last;
}
}
use Bugzilla::Extension::BugModal::Util qw(date_str_to_time);
use Bugzilla::User;
use Bugzilla::Constants;
+use List::MoreUtils qw(any);
# returns an arrayref containing all changes to the bug - comments, field
# changes, and duplicates
sub _add_comments_to_stream {
my ($bug, $stream) = @_;
my $user = Bugzilla->user;
- my $treeherder_id = Bugzilla->treeherder_user->id;
+ my @treeherder_ids = map { $_->id } @{Bugzilla->treeherder_users};
my $raw_comments = $bug->comments();
foreach my $comment (@$raw_comments) {
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) {
+ if (any { $_ == $author_id } @treeherder_ids) {
$comment->{collapsed} = 1;
$comment->{collapsed_reason} = $comment->author->name;
}
+
if ($comment->type != CMT_ATTACHMENT_CREATED && $comment->count == 0 && length($comment->body) == 0) {
$comment->{collapsed} = 1;
$comment->{collapsed_reason} = 'empty';
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 => 'orangefactor@bots.tld', cache => 1 })
- || Bugzilla::User->new();
+sub treeherder_users {
+ return Bugzilla->process_cache->{treeherder_users} //=
+ [grep { defined $_ } (
+ Bugzilla::User->new({ name => 'tbplbot@gmail.com', cache => 1 }),
+ Bugzilla::User->new({ name => 'orangefactor@bots.tld', cache => 1 }),
+ )];
}
package Bugzilla::Bug;
<li role="presentation">
<a id="view-toggle-cc" role="menuitem" tabindex="-1">Show CC Changes</a>
</li>
- [% IF treeherder %]
+ [% IF treeherder_user_ids.size %]
<li role="presentation">
- <a id="view-toggle-treeherder" role="menuitem" data-userid="[% treeherder.id FILTER none %]">Hide Treeherder Comments</a>
+ <a id="view-toggle-treeherder" role="menuitem" data-userids="[[% treeherder_user_ids.join(',') FILTER none %]]">Show Treeherder Comments</a>
</li>
[% END %]
</ul>
$('#view-toggle-cc')
.click(function() {
var that = $(this);
- var item = $('.context-menu-item.hover');
if (that.data('shown') === '1') {
that.data('shown', '0');
- item.text('Show CC Changes');
+ that.text('Show CC Changes');
$('.cc-only').hide();
}
else {
that.data('shown', '1');
- item.text('Hide CC Changes');
+ that.text('Hide CC Changes');
$('.cc-only').show();
}
});
$('#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();
+ var userids = that.data('userids');
+ if (that.data('hidden') === '0') {
+ that.data('hidden', '1');
+ that.text('Show Treeherder Comments');
+ userids.forEach((id) => {
+ $('.ca-' + id).each(function() {
+ toggleChange($(this).find('.default-collapsed .change-spinner').first(), 'hide');
+ });
+ });
}
else {
- that.data('hidden', '1');
- item.text('Show Treeherder Comments');
- $('.ca-' + that.data('userid')).hide();
+ that.data('hidden', '0');
+ that.text('Hide Treeherder Comments');
+ userids.forEach((id) => {
+ $('.ca-' + id).each(function() {
+ toggleChange($(this).find('.default-collapsed .change-spinner').first(), 'show');
+ });
+ });
}
});