main
erb 59 lines 3.51 KB
Raw
1 <% content_for :title, "Repositories" %>
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">Repositories <span class="text-gray-500 text-base font-normal">(<%= number_with_delimiter(@search.total) %>)</span></h1>
5
6 <%= form_with url: admin_repositories_path, method: :get, class: "flex items-center gap-2" do %>
7 <% if params[:kind].present? %><%= hidden_field_tag :kind, params[:kind] %><% end %>
8 <% if params[:filter].present? %><%= hidden_field_tag :filter, params[:filter] %><% end %>
9 <%= search_field_tag :q, @search.query, placeholder: "Search name, description…",
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
15 <div class="flex items-center gap-2 mb-4 text-sm">
16 <% tabs = [ [ "All", {} ], [ "Code", { kind: "code" } ], [ "Models", { kind: "model" } ], [ "Private", { filter: "private" } ] ] %>
17 <% tabs.each do |label, extra| %>
18 <% active = (extra[:kind].to_s == params[:kind].to_s) && (extra[:filter].to_s == params[:filter].to_s) %>
19 <%= link_to label, admin_repositories_path(extra.merge(q: @search.query.presence)),
20 class: "px-2.5 py-1 rounded #{active ? 'bg-surface-600 text-gray-200' : 'text-gray-400 hover:text-gray-200'}" %>
21 <% end %>
22 </div>
23
24 <div class="rounded-lg border border-surface-600 overflow-hidden">
25 <table class="w-full text-sm">
26 <thead class="bg-surface-800 text-gray-500 text-xs uppercase tracking-wide">
27 <tr>
28 <th class="text-left font-medium px-4 py-2.5">Repository</th>
29 <th class="text-left font-medium px-4 py-2.5 hidden sm:table-cell">Kind</th>
30 <th class="text-left font-medium px-4 py-2.5 hidden md:table-cell">Stars</th>
31 <th class="text-left font-medium px-4 py-2.5 hidden lg:table-cell">Created</th>
32 <th class="px-4 py-2.5"></th>
33 </tr>
34 </thead>
35 <tbody class="divide-y divide-surface-600">
36 <% @search.records.each do |repo| %>
37 <tr class="hover:bg-surface-800/50">
38 <td class="px-4 py-2.5">
39 <p class="text-gray-200"><%= repo.user.username %>/<span class="text-gray-100 font-medium"><%= repo.name %></span>
40 <% if repo.is_private %><span class="ml-1 inline-flex items-center rounded bg-surface-600 text-gray-400 px-1.5 py-0.5 text-xs">private</span><% end %>
41 </p>
42 <% if repo.description.present? %><p class="text-xs text-gray-500 truncate max-w-md"><%= repo.description %></p><% end %>
43 </td>
44 <td class="px-4 py-2.5 hidden sm:table-cell text-gray-400"><%= repo.kind %></td>
45 <td class="px-4 py-2.5 hidden md:table-cell text-gray-400"><%= repo.stars_count %></td>
46 <td class="px-4 py-2.5 hidden lg:table-cell text-gray-500"><%= repo.created_at.strftime("%b %-d, %Y") %></td>
47 <td class="px-4 py-2.5 text-right">
48 <%= link_to "View", admin_repository_path(repo.id), class: "text-brand-400 hover:text-brand-300" %>
49 </td>
50 </tr>
51 <% end %>
52 <% if @search.records.empty? %>
53 <tr><td colspan="5" class="px-4 py-8 text-center text-gray-500">No repositories match your search.</td></tr>
54 <% end %>
55 </tbody>
56 </table>
57 </div>
58
59 <%= render "admin/pagination", page: @search.page, has_next: @search.has_next?, total: @search.total, per_page: @search.per_page %>