Skip to content

Commit 0cd18eb

Browse files
committed
Merge branch 'pull/4990'
2 parents 09e802b + 1a23bfa commit 0cd18eb

File tree

5 files changed

+72
-0
lines changed

5 files changed

+72
-0
lines changed

app/assets/stylesheets/common.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,14 @@ tr.turn {
816816
}
817817
}
818818

819+
/* Rules for the issues page */
820+
821+
.issues.issues-index {
822+
td.reporter_users {
823+
max-width: 5rem;
824+
}
825+
}
826+
819827
/* Rules for the account confirmation page */
820828

821829
.accounts-terms-show {

app/controllers/issues_controller.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ def index
4444
end
4545

4646
@issues, @newer_issues_id, @older_issues_id = get_page_items(@issues, :limit => @params[:limit])
47+
48+
@unique_reporters = @issues.each_with_object({}) do |issue, reporters|
49+
user_ids = issue.reports.order(:created_at => :desc).map(&:user_id).uniq
50+
reporters[issue.id] = {
51+
:count => user_ids.size,
52+
:users => User.in_order_of(:id, user_ids.first(3))
53+
}
54+
end
55+
4756
render :partial => "page" if turbo_frame_request_id == "pagination"
4857
end
4958

app/views/issues/_page.html.erb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<th><%= t ".reports" %></th>
1414
<th><%= t ".reported_item" %></th>
1515
<th><%= t ".reported_user" %></th>
16+
<th class="reporter_users"><%= t ".reporter_users" %></th>
1617
<th><%= t ".last_updated" %></th>
1718
</tr>
1819
</thead>
@@ -23,6 +24,14 @@
2324
<td class="text-nowrap"><%= link_to t(".reports_count", :count => issue.reports_count), issue %></td>
2425
<td><%= link_to reportable_title(issue.reportable), reportable_url(issue.reportable) %></td>
2526
<td><%= link_to issue.reported_user.display_name, issue.reported_user if issue.reported_user %></td>
27+
<td class="reporter_users text-truncate">
28+
<% @unique_reporters[issue.id][:users].each do |reporter| %>
29+
<%= link_to reporter.display_name, reporter, :class => "d-block text-truncate", :title => reporter.display_name %>
30+
<% end %>
31+
<% if @unique_reporters[issue.id][:count] > 3 %>
32+
<p class="m-0"><%= t ".more_reporters", :count => @unique_reporters[issue.id][:count] - 3 %></p>
33+
<% end %>
34+
</td>
2635
<td>
2736
<% if issue.user_updated %>
2837
<%= t ".last_updated_time_ago_user_html", :user => link_to(issue.user_updated.display_name, issue.user_updated),

config/locales/en.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,9 +1512,11 @@ en:
15121512
reports: Reports
15131513
last_updated: Last Updated
15141514
last_updated_time_ago_user_html: "%{time_ago} by %{user}"
1515+
reporter_users: Reporter Users
15151516
reports_count:
15161517
one: "%{count} Report"
15171518
other: "%{count} Reports"
1519+
more_reporters: "and %{count} more"
15181520
reported_item: Reported Item
15191521
states:
15201522
ignored: Ignored

test/system/issues_test.rb

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,4 +204,48 @@ def test_issues_pagination
204204
assert_no_content(/extra_#{n}[^\d]/i)
205205
end
206206
end
207+
208+
def test_single_issue_reporters
209+
sign_in_as(create(:moderator_user))
210+
issue = create(:issue, :assigned_role => "moderator")
211+
issue.reports << create(:report, :user => create(:user, :display_name => "Test Name"))
212+
213+
visit issues_path
214+
assert_content issue.reported_user.display_name
215+
assert_content issue.reports.first.user.display_name
216+
end
217+
218+
def test_multiple_issue_reporters
219+
sign_in_as(create(:moderator_user))
220+
issue = create(:issue, :assigned_role => "moderator")
221+
222+
create_list(:report, 5, :issue => issue)
223+
224+
visit issues_path
225+
0.upto(1).each do |n|
226+
assert_no_content issue.reports[n].user.display_name
227+
end
228+
2.upto(4).each do |n|
229+
assert_content issue.reports[n].user.display_name
230+
end
231+
end
232+
233+
def test_ordering_issue_reporters
234+
sign_in_as(create(:moderator_user))
235+
issue = create(:issue, :assigned_role => "moderator")
236+
237+
create_list(:report, 5, :issue => issue)
238+
239+
4.downto(0).each do |n|
240+
issue.reports << create(:report, :user => issue.reports[n].user)
241+
end
242+
243+
visit issues_path
244+
0.upto(2).each do |n|
245+
assert_content issue.reports[n].user.display_name
246+
end
247+
3.upto(4).each do |n|
248+
assert_no_content issue.reports[n].user.display_name
249+
end
250+
end
207251
end

0 commit comments

Comments
 (0)