Commit ef78743aaf4d16a5628edfa20045092b58e4a7e7

Thomas de Grivel 2021-11-22T13:16:44

admin: repositories

diff --git a/lib/kmxgit_web/templates/admin/organisation/show.html.heex b/lib/kmxgit_web/templates/admin/organisation/show.html.heex
index 2eb5479..a9c0b0b 100644
--- a/lib/kmxgit_web/templates/admin/organisation/show.html.heex
+++ b/lib/kmxgit_web/templates/admin/organisation/show.html.heex
@@ -1,5 +1,5 @@
 <div class="container-fluid">
-  <h1>Organisation <%= @org.name || @org.slug.slug %></h1>
+  <h1><%= gettext("Organisation %{org}", org: @org.name || @org.slug.slug) %></h1>
 
   <table class="table admin-properties">
     <tr>
diff --git a/lib/kmxgit_web/templates/admin/repository/add_user.html.heex b/lib/kmxgit_web/templates/admin/repository/add_user.html.heex
new file mode 100644
index 0000000..557ea9d
--- /dev/null
+++ b/lib/kmxgit_web/templates/admin/repository/add_user.html.heex
@@ -0,0 +1,17 @@
+<div class="container-fluid">
+
+  <h1><%= gettext "Add user to %{repo}", repo: Repository.full_slug(@repo) %></h1>
+
+  <%= form_for :repository, @action, fn f -> %>
+
+    <div class="mb-3">
+      <%= label f, :login, class: "form-label" %>
+      <%= text_input f, :login, class: "form=control" %>
+    </div>
+
+    <div class="mb-3">
+      <%= submit gettext("Submit"), class: "btn btn-primary" %>
+    </div>
+
+  <% end %>
+</div>
diff --git a/lib/kmxgit_web/templates/admin/repository/index.html.heex b/lib/kmxgit_web/templates/admin/repository/index.html.heex
index 46f115c..6315e82 100644
--- a/lib/kmxgit_web/templates/admin/repository/index.html.heex
+++ b/lib/kmxgit_web/templates/admin/repository/index.html.heex
@@ -10,13 +10,15 @@
     <%= Enum.map @repos, fn(repo) -> %>
       <tr>
         <td><%= link repo.id, to: Routes.admin_repository_path(@conn, :show, repo) %></td>
-        <%= case owner = Repository.owner(repo) do %>
-          <% %Organisation{} -> %>
-            <td><%= link owner.name || owner.slug.slug, to: Routes.admin_organisation_path(@conn, :show, owner) %></td>
-          <% %User{} -> %>
-            <td><%= link owner.slug.slug, to: Routes.admin_user_path(@conn, :show, owner) %></td>
-        <% end %>
-        <td><%= link Repository.full_slug(repo), to: Routes.repository_path(@conn, :show, Repository.owner_slug(repo), Repository.splat(repo)) %></td>
+        <td>
+          <%= case owner = Repository.owner(repo) do %>
+            <% %Organisation{} -> %>
+              <%= link owner.name || owner.slug.slug, to: Routes.admin_organisation_path(@conn, :show, owner) %>
+            <% %User{} -> %>
+              <%= link owner.slug.slug, to: Routes.admin_user_path(@conn, :show, owner) %>
+          <% end %>
+        </td>
+        <td><%= link Repository.full_slug(repo), to: Routes.admin_repository_path(@conn, :show, repo) %></td>
       </tr>
     <% end %>
   </table>
diff --git a/lib/kmxgit_web/templates/admin/repository/remove_user.html.heex b/lib/kmxgit_web/templates/admin/repository/remove_user.html.heex
new file mode 100644
index 0000000..6b7a494
--- /dev/null
+++ b/lib/kmxgit_web/templates/admin/repository/remove_user.html.heex
@@ -0,0 +1,17 @@
+<div class="container-fluid">
+
+  <h1><%= gettext "Remove user from %{repo}", repo: Repository.full_slug(@repo) %></h1>
+
+  <%= form_for :repository, @action, fn f -> %>
+
+    <div class="mb-3">
+      <%= label f, :login, class: "form-label" %>
+      <%= text_input f, :login, class: "form=control" %>
+    </div>
+
+    <div class="mb-3">
+      <%= submit gettext("Submit"), class: "btn btn-primary" %>
+    </div>
+
+  <% end %>
+</div>
diff --git a/lib/kmxgit_web/templates/admin/repository/show.html.heex b/lib/kmxgit_web/templates/admin/repository/show.html.heex
new file mode 100644
index 0000000..3d0ba67
--- /dev/null
+++ b/lib/kmxgit_web/templates/admin/repository/show.html.heex
@@ -0,0 +1,60 @@
+<div class="container-fluid">
+  <h1><%= gettext("Repository %{repo}", repo: Repository.full_slug(@repo)) %></h1>
+
+  <table class="table admin-properties">
+    <tr>
+      <th><%= gettext "Id" %></th>
+      <td><%= @repo.id %></td>
+    </tr>
+    <tr>
+      <th><%= gettext "Owner" %></th>
+      <td>
+        <%= case owner = Repository.owner(@repo) do %>
+          <% %Organisation{} -> %>
+            <%= gettext "Organisation" %>
+            <%= link owner.name || owner.slug.slug, to: Routes.admin_organisation_path(@conn, :show, owner) %>
+          <% %User{} -> %>
+            <%= gettext "User" %>
+            <%= link owner.slug.slug, to: Routes.admin_user_path(@conn, :show, owner) %>
+        <% end %>
+      </td>
+    </tr>
+    <tr>
+      <th><%= gettext "Slug" %></th>
+      <td><%= link Repository.full_slug(@repo), to: Routes.repository_path(@conn, :show, Repository.owner_slug(@repo), Repository.splat(@repo)) %></td>
+    </tr>
+    <tr>
+      <th><%= gettext "Description" %></th>
+      <td>
+        <%= if @repo.description do %>
+          <%= raw Earmark.as_html!(@repo.description) %>
+        <% end %>
+      </td>
+    </tr>
+    <tr>
+      <th><%= gettext "Members" %></th>
+      <td>
+        <%= for user <- @members do %>
+          <%= link(user.slug.slug, to: Routes.admin_user_path(@conn, :show, user), class: "user") %>
+        <% end %>
+        <%= link "-",
+            to: Routes.admin_repository__path(@conn, :remove_user, @repo),
+            class: "btn btn-danger btn-sm" %>
+        <%= link "+",
+            to: Routes.admin_repository__path(@conn, :add_user, @repo),
+            class: "btn btn-primary btn-sm" %>
+      </td>
+    </tr>
+  </table>
+
+  <%= link gettext("Delete repo"),
+      to: Routes.admin_repository_path(@conn, :delete, @repo),
+      class: "btn btn-danger",
+      data: [confirm: gettext("Are you sure you want to delete this repo ?")],
+      method: :delete %>
+
+  <%= link gettext("Edit repo"),
+      to: Routes.admin_repository_path(@conn, :edit, @repo),
+      class: "btn btn-primary" %>
+
+</div>