defmodule GitGudWeb.ImportLive.Index do
@moduledoc "Past and running import batches for the current user."
use GitGudWeb, :live_view
alias GitGud.Imports
@impl true
def mount(_params, _session, socket) do
user = socket.assigns.current_scope.user
{:ok,
socket
|> assign(:page_title, "Imports")
|> assign(:imports, Imports.list_imports(user))}
end
defp status_badge("completed"), do: "badge-success"
defp status_badge("failed"), do: "badge-error"
defp status_badge("canceled"), do: "badge-warning"
defp status_badge("running"), do: "badge-info"
defp status_badge(_), do: "badge-ghost"
defp source_label(%{provider: "git"} = import_row), do: import_row.remote_owner
defp source_label(import_row),
do: "#{String.capitalize(import_row.provider)} · #{import_row.remote_owner}"
@impl true
def render(assigns) do
~H"""
<Layouts.app flash={@flash} current_scope={@current_scope}>
<div class="space-y-6 max-w-4xl">
<div class="flex items-center justify-between gap-3">
<h1 class="text-2xl font-semibold">Imports</h1>
<.link navigate={~p"/repositories/import"} class="btn btn-sm btn-primary">New import</.link>
</div>
<p :if={@imports == []} class="text-sm opacity-70">
No imports yet. Pull repositories in from GitHub, GitLab, or any git URL.
</p>
<div :if={@imports != []} class="overflow-x-auto border border-base-300 rounded-lg">
<table class="table table-sm">
<thead>
<tr>
<th>Source</th>
<th>Destination</th>
<th>Started</th>
<th class="w-28">Status</th>
</tr>
</thead>
<tbody>
<tr :for={import_row <- @imports}>
<td>
<.link
navigate={~p"/imports/#{import_row.id}"}
class="link link-hover font-medium break-all"
>
{source_label(import_row)}
</.link>
</td>
<td class="opacity-70">
{if import_row.organization, do: import_row.organization.handle, else: "personal"}
</td>
<td class="opacity-70 whitespace-nowrap">
{Calendar.strftime(import_row.inserted_at, "%Y-%m-%d %H:%M")}
</td>
<td>
<span class={"badge badge-sm #{status_badge(import_row.status)}"}>
{import_row.status}
</span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</Layouts.app>
"""
end
end
neiam /gitgud
Git Gud
public · Issues · Pulls · Labels · Forks · Compare · Actions success · Packages
⭐
Log in to mark this repository.
2.7 KiB · text
History
6280797