Skip to content

Commit 0062703

Browse files
committed
Include Thredded flash messages styling and moderation stats updates
1 parent 926d336 commit 0062703

File tree

3 files changed

+38
-11
lines changed

3 files changed

+38
-11
lines changed

app/views/thredded/moderation/pending.html.erb

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,37 @@
44

55
<%= thredded_page do %>
66
<div class="thredded--main-section mt-6">
7+
<%
8+
pending_review_count = Thredded::Post.pending_moderation.count
9+
approved_today_count = Thredded::Post.where(moderation_state: :approved).where('updated_at >= ?', Time.zone.now.beginning_of_day).count
10+
blocked_today_count = Thredded::Post.where(moderation_state: :blocked).where('updated_at >= ?', Time.zone.now.beginning_of_day).count
11+
%>
712
<!-- Moderation Stats Dashboard -->
8-
<div class="moderation-dashboard grid grid-cols-2 lg:grid-cols-4 gap-4 mb-8">
13+
<div class="moderation-dashboard grid grid-cols-2 lg:grid-cols-3 gap-4 mb-8">
914
<div class="stat-card bg-white dark:bg-slate-800 rounded-lg shadow-sm border border-slate-200 dark:border-slate-700 p-6 flex flex-col items-center text-center">
1015
<div class="stat-icon pending text-3xl mb-2 text-amber-500">
1116
<i class="material-icons text-current text-3xl">pending_actions</i>
1217
</div>
13-
<div class="stat-value text-3xl font-bold dark:text-white"><%= @posts.try(:total_count) || 0 %></div>
18+
<div class="stat-value text-3xl font-bold dark:text-white"><%= pending_review_count %></div>
1419
<div class="stat-label text-sm text-gray-500 dark:text-gray-400 uppercase tracking-widest mt-1">Pending Review</div>
1520
</div>
1621

1722
<div class="stat-card bg-white dark:bg-slate-800 rounded-lg shadow-sm border border-slate-200 dark:border-slate-700 p-6 flex flex-col items-center text-center">
1823
<div class="stat-icon approved text-3xl mb-2 text-emerald-500">
1924
<i class="material-icons text-current text-3xl">check_circle</i>
2025
</div>
21-
<div class="stat-value text-3xl font-bold dark:text-white">--</div>
26+
<div class="stat-value text-3xl font-bold dark:text-white"><%= approved_today_count %></div>
2227
<div class="stat-label text-sm text-gray-500 dark:text-gray-400 uppercase tracking-widest mt-1">Approved Today</div>
2328
</div>
2429

2530
<div class="stat-card bg-white dark:bg-slate-800 rounded-lg shadow-sm border border-slate-200 dark:border-slate-700 p-6 flex flex-col items-center text-center">
2631
<div class="stat-icon blocked text-3xl mb-2 text-red-500">
2732
<i class="material-icons text-current text-3xl">block</i>
2833
</div>
29-
<div class="stat-value text-3xl font-bold dark:text-white">--</div>
34+
<div class="stat-value text-3xl font-bold dark:text-white"><%= blocked_today_count %></div>
3035
<div class="stat-label text-sm text-gray-500 dark:text-gray-400 uppercase tracking-widest mt-1">Blocked Today</div>
3136
</div>
3237

33-
<div class="stat-card bg-white dark:bg-slate-800 rounded-lg shadow-sm border border-slate-200 dark:border-slate-700 p-6 flex flex-col items-center text-center">
34-
<div class="stat-icon users text-3xl mb-2 text-blue-500">
35-
<i class="material-icons text-current text-3xl">group</i>
36-
</div>
37-
<div class="stat-value text-3xl font-bold dark:text-white">--</div>
38-
<div class="stat-label text-sm text-gray-500 dark:text-gray-400 uppercase tracking-widest mt-1">Active Users</div>
39-
</div>
4038
</div>
4139

4240
<!-- Last Moderated Notice -->
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<% unless messages.blank? %>
2+
<div class="mb-4 p-4 text-sm font-medium text-red-800 rounded-lg bg-red-50 dark:bg-red-900/30 dark:text-red-300 dark:border dark:border-red-800/50" role="alert">
3+
<%= safe_join messages, raw("<br>") %>
4+
</div>
5+
<% end %>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<% [:success, :error, :notice, :alert].each do |key| %>
2+
<% if flash[key] %>
3+
<%
4+
color_classes = case key.to_sym
5+
when :success then "bg-green-50 text-green-800 border-green-200 dark:bg-green-900/30 dark:text-green-300 dark:border-green-800/50"
6+
when :error, :alert then "bg-red-50 text-red-800 border-red-200 dark:bg-red-900/30 dark:text-red-300 dark:border-red-800/50"
7+
when :warning then "bg-yellow-50 text-yellow-800 border-yellow-200 dark:bg-yellow-900/30 dark:text-yellow-300 dark:border-yellow-800/50"
8+
else "bg-blue-50 text-blue-800 border-blue-200 dark:bg-blue-900/30 dark:text-blue-300 dark:border-blue-800/50"
9+
end
10+
icon = case key.to_sym
11+
when :success then "check_circle"
12+
when :error, :alert then "error"
13+
when :warning then "warning"
14+
else "info"
15+
end
16+
%>
17+
<div class="flex items-center p-4 mb-4 text-sm border rounded-lg <%= color_classes %>" role="alert" data-thredded-flash-message>
18+
<i class="material-icons flex-shrink-0 inline mr-3" style="font-size: 20px;"><%= icon %></i>
19+
<div class="font-medium">
20+
<%= flash[key] %>
21+
</div>
22+
</div>
23+
<% end %>
24+
<% end %>

0 commit comments

Comments
 (0)