Skip to content

Commit 709b8c9

Browse files
committed
Improve log (better scanability and space usage)
1 parent 149b75d commit 709b8c9

File tree

3 files changed

+67
-48
lines changed

3 files changed

+67
-48
lines changed

app/assets/stylesheets/users.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,4 +225,6 @@ $sizes: (16, 32, 40, 48, 64, 128, 256);
225225
border-bottom-width: 1px !important;
226226
width: 150px;
227227
}
228-
}
228+
}
229+
230+
.mod-warnings-clear-form { display: inline; }

app/controllers/mod_warning_controller.rb

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,20 @@ def log
2626
if current_user.is_global_moderator || current_user.is_global_admin
2727
@warnings = @warnings.or ModWarning.where(user: @user, is_global: true)
2828
end
29-
@warnings = @warnings.order(created_at: :desc).all
29+
@warnings = @warnings.all
30+
@warnings = @warnings.map { |w| {type: :warning, value: w} }
31+
32+
@messages = ThreadFollower.where(user: @user).all.map { |t| t.id - 1 }
33+
@messages = CommentThread.where(post: nil, is_private: true, id: @messages).all
34+
@messages = @messages.filter { |m| m.comments.first.user&.id != @user&.id }
35+
@messages = @messages.map { |m| {type: :message, value: m} }
36+
37+
print "*"*50 + "\n"
38+
print @messages
39+
print "\n" + "*"*50
40+
41+
@entries = @warnings + @messages
42+
@entries = @entries.sort_by { |e| e[:value].created_at }.reverse
3043
render layout: 'without_sidebar'
3144
end
3245

app/views/mod_warning/log.html.erb

Lines changed: 50 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -6,53 +6,57 @@
66
<%= render 'shared/user_mod_sidebar', user: @user %>
77

88
<div class="grid--cell is-9">
9-
<h1>Previously Sent Warnings</h1>
9+
<h1>Previously Sent Messages and Warnings</h1>
1010

11-
<table class="table is-full-width is-with-hover">
12-
<tr>
13-
<th>Date</th>
14-
<th>Type</th>
15-
<th>From</th>
16-
<th>Excerpt</th>
17-
<th>Status</th>
18-
</tr>
19-
<% @warnings.each do |w| %>
20-
<tr>
21-
<td>
22-
<span title="<%= w.created_at.iso8601 %>"><%= time_ago_in_words(w.created_at) %> ago</span>
23-
</td>
24-
<td>
25-
<% if w.is_suspension %>
26-
<% diff = ((w.suspension_end - w.created_at) / (3600 * 24)).to_i %>
27-
<span class="badge is-tag is-red is-filled">Suspension</span>
28-
<span class="badge is-tag is-muted">length: <%= diff %>d</span>
29-
<% if w.is_global %><span class="badge is-tag is-muted">network-wide</span><% end %>
30-
<% else %>
31-
<span class="badge is-tag is-muted is-filled">Warning</span>
32-
<% end %>
33-
</td>
34-
<td>
35-
<%= user_link w.author %>
36-
</td>
37-
<td>
11+
<% @entries.each do |e| %>
12+
<div class="widget">
13+
<% if e[:type] == :message %>
14+
<% m = e[:value] %>
15+
<div class="widget--header is-complex h-bg-tertiary-050">
16+
<div>
17+
<span class="badge is-tag is-filled badge-nobreak"><i class="fas fa-envelope fa-fw"></i> Message</span>
18+
</div>
19+
<div class="h-c-tertiary-700 h-fs-caption h-m-t-2"><span title="<%= m.created_at.iso8601 %>"><%= time_ago_in_words(m.created_at) %> ago</span> by <%= user_link m.comments.first.user %></div>
20+
</div>
21+
<div class="widget--body">
22+
<%= raw(sanitize(render_markdown(m.comments.first.content), scrubber: scrubber)) %>
23+
</div>
24+
<% elsif e[:type] == :warning %>
25+
<% w = e[:value] %>
26+
<div class="widget--header is-complex h-bg-tertiary-050">
27+
<div class="has-float-right h-p-1 h-fs-caption">
28+
<% if w.suspension_active? %>
29+
<%= form_tag lift_mod_warning_url(@user.id), method: :post, class: 'mod-warnings-clear-form' do %>
30+
<%= submit_tag '(lift)', class: 'link is-red' %>
31+
<% end %> &middot;
32+
<strong>Current <i class="fas fa-fw fa-clock"></i></strong>
33+
<% elsif w.active %>
34+
<strong>Unread <i class="fas fa-fw fa-eye-slash"></i></strong>
35+
<% elsif w.read %>
36+
Read <i class="fas fa-fw fa-eye"></i>
37+
<% else %>
38+
Lifted <i class="fas fa-fw fa-undo"></i>
39+
<% end %>
40+
</div>
41+
<div>
42+
<% if w.is_suspension %>
43+
<% diff = ((w.suspension_end - w.created_at) / (3600 * 24)).to_i %>
44+
<span class="badge is-tag is-red is-filled badge-nobreak"><i class="fas fa-user-slash fa-fw"></i> Suspension</span>
45+
<span class="badge is-tag is-muted badge-nobreak">length: <%= diff %>d</span>
46+
<% if w.is_global %>
47+
<span class="badge is-tag is-muted badge-nobreak">network-wide</span>
48+
<% end %>
49+
<% else %>
50+
<span class="badge is-tag is-yellow is-filled badge-nobreak"><i class="fas fa-exclamation-triangle fa-fw"></i> Warning</span>
51+
<% end %>
52+
</div>
53+
<div class="h-c-tertiary-700 h-fs-caption h-m-t-2"><span title="<%= w.created_at.iso8601 %>"><%= time_ago_in_words(w.created_at) %> ago</span> by <%= user_link w.author %></div>
54+
</div>
55+
<div class="widget--body">
3856
<%= raw(sanitize(render_markdown(w.body), scrubber: scrubber)) %>
39-
</td>
40-
<td>
41-
<% if w.suspension_active? %>
42-
<strong>Current</strong>
43-
<%= form_tag lift_mod_warning_url(@user.id), method: :post do %>
44-
<%= submit_tag '(lift)', class: 'link is-red' %>
45-
<% end %>
46-
<% elsif w.active %>
47-
<strong>Unread</strong>
48-
<% elsif w.read %>
49-
Read
50-
<% else %>
51-
<strong>Lifted</strong>
52-
<% end %>
53-
</td>
54-
</tr>
55-
<% end %>
56-
</table>
57+
</div>
58+
<% end %>
59+
</div>
60+
<% end %>
5761
</div>
5862
</div>

0 commit comments

Comments
 (0)