Skip to content

Self-hosted project management for devs and their clients: tickets, time tracking, docs and meetings, with an AI assistant that cites its sources. AGPL-3.0.

5.9 KB
Raw Blame
<div class="container mx-auto px-4 py-8">
  <!-- Header -->
  <div class="flex items-start justify-between mb-8">
    <div>
      <h1 class="text-3xl font-bold mb-2"><%= t('views.admin.ai_packages.index.title') %></h1>
      <p class="text-gray-600"><%= t('views.admin.ai_packages.index.subtitle') %></p>
    </div>
    <%= link_to new_admin_ai_package_path,
        class: "inline-flex items-center px-4 py-2 border-2 border-black rounded-lg bg-black text-white hover:shadow-[2px_2px_0_0_#000000] transition-all" do %>
      <i class="bi bi-plus mr-2"></i>
      <%= t('views.admin.ai_packages.index.add') %>
    <% end %>
  </div>

  <div class="bg-white border-2 border-black rounded-lg shadow-[2px_2px_0_0_#000000] overflow-hidden">
    <div class="px-4 py-3 border-b-2 border-black bg-gray-50">
      <h2 class="text-lg font-bold"><%= t('views.admin.ai_packages.index.table_title') %></h2>
    </div>

    <% if @ai_packages.any? %>
      <div class="overflow-x-auto">
        <table class="w-full">
          <thead class="bg-gray-100 border-b-2 border-black">
            <tr>
              <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"><%= t('views.admin.ai_packages.index.th_name') %></th>
              <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"><%= t('views.admin.ai_packages.index.th_jurisdiction') %></th>
              <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"><%= t('views.admin.ai_packages.index.th_tiers') %></th>
              <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"><%= t('views.admin.ai_packages.index.th_published') %></th>
              <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"><%= t('views.admin.ai_packages.index.th_position') %></th>
              <th scope="col" class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider"><%= t('views.admin.ai_packages.index.th_actions') %></th>
            </tr>
          </thead>
          <tbody class="bg-white divide-y divide-gray-200">
            <% @ai_packages.each do |ai_package| %>
              <tr class="hover:bg-gray-50 transition-colors">
                <td class="px-6 py-4 text-sm font-medium text-gray-900">
                  <%= link_to ai_package.name, admin_ai_package_path(ai_package), class: "hover:underline" %>
                  <% if ai_package.processing_region.present? %>
                    <div class="text-xs text-gray-500"><%= ai_package.processing_region %></div>
                  <% end %>
                </td>
                <td class="px-6 py-4">
                  <%= render 'jurisdiction_badge', jurisdiction: ai_package.jurisdiction %>
                </td>
                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-700">
                  <%= t('views.admin.ai_packages.index.tier_count', count: ai_package.tiers.size) %>
                </td>
                <td class="px-6 py-4 whitespace-nowrap">
                  <%= render 'published_badge', active: ai_package.active? %>
                </td>
                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-700 tabular-nums"><%= ai_package.position %></td>
                <td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
                  <div class="flex items-center justify-end space-x-2">
                    <%= link_to admin_ai_package_path(ai_package),
                        class: "inline-flex items-center px-2 py-1 border-2 border-black rounded-lg hover:shadow-[2px_2px_0_0_#000000] transition-all",
                        title: t('views.admin.ai_packages.index.tooltip_details') do %>
                      <i class="bi bi-eye"></i>
                    <% end %>

                    <%= link_to edit_admin_ai_package_path(ai_package),
                        class: "inline-flex items-center px-2 py-1 border-2 border-black rounded-lg hover:shadow-[2px_2px_0_0_#000000] transition-all",
                        title: t('views.admin.ai_packages.index.tooltip_edit') do %>
                      <i class="bi bi-pencil"></i>
                    <% end %>

                    <%# button_to (native form) — data-turbo-method is documented
                        as unreliable in the admin area, so every non-GET action
                        here posts a real form. %>
                    <%= button_to admin_ai_package_path(ai_package),
                        method: :delete,
                        form_class: "inline-block",
                        data: { turbo_confirm: t('views.confirm.delete_ai_package') },
                        class: "inline-flex items-center px-2 py-1 border-2 border-black rounded-lg bg-red-100 hover:bg-red-200 hover:shadow-[2px_2px_0_0_#000000] transition-all",
                        title: t('views.admin.ai_packages.index.tooltip_delete') do %>
                      <i class="bi bi-trash"></i>
                    <% end %>
                  </div>
                </td>
              </tr>
            <% end %>
          </tbody>
        </table>
      </div>
    <% else %>
      <div class="px-4 py-12 text-center">
        <i class="bi bi-box-seam text-gray-400 text-4xl mb-4"></i>
        <h3 class="text-lg font-bold text-gray-900 mb-2"><%= t('views.admin.ai_packages.index.empty_title') %></h3>
        <p class="text-gray-500 mb-4"><%= t('views.admin.ai_packages.index.empty_description') %></p>
        <%= link_to new_admin_ai_package_path,
            class: "inline-flex items-center px-4 py-2 border-2 border-black rounded-lg bg-black text-white hover:shadow-[2px_2px_0_0_#000000] transition-all" do %>
          <i class="bi bi-plus mr-2"></i>
          <%= t('views.admin.ai_packages.index.empty_add_first') %>
        <% end %>
      </div>
    <% end %>
  </div>
</div>