main
erb 66 lines 3.59 KB
Raw
1 <% content_for :title, "Users" %>
2
3 <div class="flex flex-wrap items-center justify-between gap-3 mb-4">
4 <h1 class="text-xl font-semibold text-gray-100">Users <span class="text-gray-500 text-base font-normal">(<%= number_with_delimiter(@search.total) %>)</span></h1>
5
6 <div class="flex items-center gap-2">
7 <%= form_with url: admin_users_path, method: :get, class: "flex items-center gap-2" do %>
8 <% if params[:filter].present? %><%= hidden_field_tag :filter, params[:filter] %><% end %>
9 <%= search_field_tag :q, @search.query, placeholder: "Search username, email, name…",
10 class: "bg-surface-800 border border-surface-600 rounded px-3 py-1.5 text-sm text-gray-200 w-64 focus:outline-none focus:border-brand-500" %>
11 <%= submit_tag "Search", class: "px-3 py-1.5 rounded bg-brand-500/15 text-brand-300 text-sm hover:bg-brand-500/25 cursor-pointer border-0" %>
12 <% end %>
13 </div>
14 </div>
15
16 <div class="flex items-center gap-2 mb-4 text-sm">
17 <%= link_to "All", admin_users_path(q: @search.query.presence),
18 class: "px-2.5 py-1 rounded #{params[:filter].blank? ? 'bg-surface-600 text-gray-200' : 'text-gray-400 hover:text-gray-200'}" %>
19 <%= link_to "Admins", admin_users_path(filter: "admins", q: @search.query.presence),
20 class: "px-2.5 py-1 rounded #{params[:filter] == 'admins' ? 'bg-surface-600 text-gray-200' : 'text-gray-400 hover:text-gray-200'}" %>
21 </div>
22
23 <div class="rounded-lg border border-surface-600 overflow-hidden">
24 <table class="w-full text-sm">
25 <thead class="bg-surface-800 text-gray-500 text-xs uppercase tracking-wide">
26 <tr>
27 <th class="text-left font-medium px-4 py-2.5">User</th>
28 <th class="text-left font-medium px-4 py-2.5 hidden sm:table-cell">Plan</th>
29 <th class="text-left font-medium px-4 py-2.5 hidden md:table-cell">Repos</th>
30 <th class="text-left font-medium px-4 py-2.5 hidden lg:table-cell">Joined</th>
31 <th class="px-4 py-2.5"></th>
32 </tr>
33 </thead>
34 <tbody class="divide-y divide-surface-600">
35 <% @search.records.each do |user| %>
36 <tr class="hover:bg-surface-800/50">
37 <td class="px-4 py-2.5">
38 <div class="flex items-center gap-3">
39 <img src="<%= user.avatar_url_or_default %>" alt="" class="w-7 h-7 rounded-full border border-surface-500">
40 <div class="min-w-0">
41 <p class="text-gray-200 truncate">
42 <%= user.username %>
43 <% if user.admin? %><span class="ml-1 inline-flex items-center rounded bg-brand-500/15 text-brand-300 px-1.5 py-0.5 text-xs">admin</span><% end %>
44 </p>
45 <p class="text-xs text-gray-500 truncate"><%= user.email %></p>
46 </div>
47 </div>
48 </td>
49 <td class="px-4 py-2.5 hidden sm:table-cell">
50 <%= admin_plan_badge(user.subscription&.plan) %>
51 </td>
52 <td class="px-4 py-2.5 hidden md:table-cell text-gray-400"><%= user.repositories.size %></td>
53 <td class="px-4 py-2.5 hidden lg:table-cell text-gray-500"><%= user.created_at.strftime("%b %-d, %Y") %></td>
54 <td class="px-4 py-2.5 text-right">
55 <%= link_to "View", admin_user_path(user.username), class: "text-brand-400 hover:text-brand-300" %>
56 </td>
57 </tr>
58 <% end %>
59 <% if @search.records.empty? %>
60 <tr><td colspan="5" class="px-4 py-8 text-center text-gray-500">No users match your search.</td></tr>
61 <% end %>
62 </tbody>
63 </table>
64 </div>
65
66 <%= render "admin/pagination", page: @search.page, has_next: @search.has_next?, total: @search.total, per_page: @search.per_page %>