From c290f3ecabec75b741d375e6130af9060255c274 Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Mon, 15 Jun 2015 12:49:59 +0800 Subject: Bug 1146774: treeherder/tbpl comments are not automatically collapsed --- Bugzilla/Comment.pm | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'Bugzilla/Comment.pm') diff --git a/Bugzilla/Comment.pm b/Bugzilla/Comment.pm index 979019541..69e973c7f 100644 --- a/Bugzilla/Comment.pm +++ b/Bugzilla/Comment.pm @@ -213,25 +213,31 @@ sub tags { sub collapsed { my ($self) = @_; - return 0 unless Bugzilla->params->{'comment_taggers_group'}; return $self->{collapsed} if exists $self->{collapsed}; + return 0 unless Bugzilla->params->{'comment_taggers_group'}; $self->{collapsed} = 0; Bugzilla->request_cache->{comment_tags_collapsed} - ||= [ split(/\s*,\s*/, Bugzilla->params->{'collapsed_comment_tags'}) ]; + ||= [ split(/\s*,\s*/, lc(Bugzilla->params->{'collapsed_comment_tags'})) ]; my @collapsed_tags = @{ Bugzilla->request_cache->{comment_tags_collapsed} }; - foreach my $my_tag (@{ $self->tags }) { - $my_tag = lc($my_tag); + my @reason; + foreach my $my_tag (map { lc } @{ $self->tags }) { foreach my $collapsed_tag (@collapsed_tags) { - if ($my_tag eq lc($collapsed_tag)) { - $self->{collapsed} = 1; - last; - } + push @reason, $my_tag if $my_tag eq $collapsed_tag; } - last if $self->{collapsed}; + } + if (@reason) { + $self->{collapsed} = 1; + $self->{collapsed_reason} = join(', ', sort @reason); } return $self->{collapsed}; } +sub collapsed_reason { + my ($self) = @_; + return 0 unless $self->collapsed; + return $self->{collapsed_reason}; +} + sub bug { my $self = shift; require Bugzilla::Bug; -- cgit v1.2.3-24-g4f1b