Commit 031737e95cfac0d77ed51ed2306827629bb65ba1

Thomas de Grivel 2021-11-30T15:47:51

deploy_keys

diff --git a/assets/css/app.scss b/assets/css/app.scss
index 3250371..c73d46e 100644
--- a/assets/css/app.scss
+++ b/assets/css/app.scss
@@ -19,11 +19,11 @@ textarea#repository_deploy_keys {
 }
 pre.ssh_keys {
     max-width: 20em;
-    white-space: pre-wrap;       /* Since CSS 2.1 */
-    white-space: -moz-pre-wrap;  /* Mozilla, since 1999 */
-    white-space: -pre-wrap;      /* Opera 4-6 */
-    white-space: -o-pre-wrap;    /* Opera 7 */
-    word-wrap: break-word;       /* Internet Explorer 5.5+ */
+    white-space: pre-wrap;
+}
+pre.admin_ssh_keys {
+    max-width: 40em;
+    white-space: pre-wrap;
 }
 
 /* repository */
diff --git a/lib/kmxgit/repository_manager/repository.ex b/lib/kmxgit/repository_manager/repository.ex
index 1212ffa..ea2e90d 100644
--- a/lib/kmxgit/repository_manager/repository.ex
+++ b/lib/kmxgit/repository_manager/repository.ex
@@ -4,9 +4,7 @@ defmodule Kmxgit.RepositoryManager.Repository do
   import Ecto.Changeset
 
   alias Kmxgit.RepositoryManager
-  alias Kmxgit.OrganisationManager
   alias Kmxgit.OrganisationManager.Organisation
-  alias Kmxgit.UserManager
   alias Kmxgit.UserManager.User
 
   schema "repositories" do
diff --git a/lib/kmxgit_web/controllers/admin/organisation_controller.ex b/lib/kmxgit_web/controllers/admin/organisation_controller.ex
index 6b84e5b..69fa453 100644
--- a/lib/kmxgit_web/controllers/admin/organisation_controller.ex
+++ b/lib/kmxgit_web/controllers/admin/organisation_controller.ex
@@ -10,7 +10,7 @@ defmodule KmxgitWeb.Admin.OrganisationController do
   def index(conn, _params) do
     orgs = OrganisationManager.list_organisations
     conn
-    |> assign(:orgss, orgs)
+    |> assign(:orgs, orgs)
     |> render("index.html")
   end
 
diff --git a/lib/kmxgit_web/templates/admin/organisation/index.html.heex b/lib/kmxgit_web/templates/admin/organisation/index.html.heex
index 9471e5d..b878284 100644
--- a/lib/kmxgit_web/templates/admin/organisation/index.html.heex
+++ b/lib/kmxgit_web/templates/admin/organisation/index.html.heex
@@ -6,12 +6,16 @@
       <th><%= gettext "Id" %></th>
       <th><%= gettext "Name" %></th>
       <th><%= gettext "Slug" %></th>
+      <th><%= gettext "Actions" %></th>
     </tr>
     <%= Enum.map @orgs, fn org -> %>
       <tr>
         <td><%= link org.id, to: Routes.admin_organisation_path(@conn, :show, org) %></td>
-        <td><%= org.name %></td>
-        <td><%= link org.slug.slug, to: Routes.slug_path(@conn, :show, org.slug.slug) %></td>
+        <td><%= link org.name, to: Routes.admin_organisation_path(@conn, :show, org) %></td>
+        <td><%= link org.slug.slug, to: Routes.admin_organisation_path(@conn, :show, org) %></td>
+        <td>
+          <%= link gettext("Show"), to: Routes.slug_path(@conn, :show, org.slug.slug), class: "btn btn-sm btn-primary" %>
+        </td>
       </tr>
     <% end %>
   </table>
diff --git a/lib/kmxgit_web/templates/admin/organisation/show.html.heex b/lib/kmxgit_web/templates/admin/organisation/show.html.heex
index b76344c..7022a7b 100644
--- a/lib/kmxgit_web/templates/admin/organisation/show.html.heex
+++ b/lib/kmxgit_web/templates/admin/organisation/show.html.heex
@@ -8,11 +8,11 @@
     </tr>
     <tr>
       <th><%= gettext "Name" %></th>
-      <td><%= link @org.name, to: Routes.slug_path(@conn, :show, @org.slug.slug) %></td>
+      <td><%= @org.name %></td>
     </tr>
     <tr>
       <th><%= gettext "Slug" %></th>
-      <td><%= link @org.slug.slug, to: Routes.slug_path(@conn, :show, @org.slug.slug) %></td>
+      <td><%= @org.slug.slug %></td>
     </tr>
     <tr>
       <th><%= gettext "Description" %></th>
@@ -47,4 +47,8 @@
   <%= link gettext("Edit organisation"),
       to: Routes.admin_organisation_path(@conn, :edit, @org),
       class: "btn btn-primary" %>
+
+  <%= link gettext("Show"),
+      to: Routes.slug_path(@conn, :show, @org.slug.slug),
+      class: "btn btn-primary" %>
 </div>
diff --git a/lib/kmxgit_web/templates/admin/repository/index.html.heex b/lib/kmxgit_web/templates/admin/repository/index.html.heex
index 6315e82..034932b 100644
--- a/lib/kmxgit_web/templates/admin/repository/index.html.heex
+++ b/lib/kmxgit_web/templates/admin/repository/index.html.heex
@@ -6,6 +6,7 @@
       <th><%= gettext "Id" %></th>
       <th><%= gettext "Owner" %></th>
       <th><%= gettext "Slug" %></th>
+      <th><%= gettext "Actions" %></th>
     </tr>
     <%= Enum.map @repos, fn(repo) -> %>
       <tr>
@@ -19,6 +20,9 @@
           <% end %>
         </td>
         <td><%= link Repository.full_slug(repo), to: Routes.admin_repository_path(@conn, :show, repo) %></td>
+        <td>
+          <%= link gettext("Show"), to: Routes.repository_path(@conn, :show, Repository.owner_slug(repo), Repository.splat(repo)), class: "btn btn-sm btn-primary" %>
+        </td>
       </tr>
     <% end %>
   </table>
diff --git a/lib/kmxgit_web/templates/admin/repository/show.html.heex b/lib/kmxgit_web/templates/admin/repository/show.html.heex
index 3d0ba67..390af70 100644
--- a/lib/kmxgit_web/templates/admin/repository/show.html.heex
+++ b/lib/kmxgit_web/templates/admin/repository/show.html.heex
@@ -45,6 +45,10 @@
             class: "btn btn-primary btn-sm" %>
       </td>
     </tr>
+    <tr>
+      <th><%= gettext "Deploy keys" %></th>
+      <td><pre class="admin_ssh_keys"><%= @repo.deploy_keys %></pre></td>
+    </tr>
   </table>
 
   <%= link gettext("Delete repo"),
@@ -57,4 +61,7 @@
       to: Routes.admin_repository_path(@conn, :edit, @repo),
       class: "btn btn-primary" %>
 
+  <%= link gettext("Show"),
+      to: Routes.repository_path(@conn, :show, Repository.owner_slug(@repo), Repository.splat(@repo)),
+      class: "btn btn-primary" %>
 </div>
diff --git a/lib/kmxgit_web/templates/admin/user/index.html.heex b/lib/kmxgit_web/templates/admin/user/index.html.heex
index 028a6c1..4dfde1e 100644
--- a/lib/kmxgit_web/templates/admin/user/index.html.heex
+++ b/lib/kmxgit_web/templates/admin/user/index.html.heex
@@ -8,14 +8,18 @@
       <th><%= gettext "Email" %></th>
       <th><%= gettext "Login" %></th>
       <th><%= gettext "Admin" %></th>
+      <th><%= gettext "Deploy" %></th>
+      <th><%= gettext "Actions" %></th>
     </tr>
     <%= Enum.map @users, fn(user) -> %>
       <tr>
         <td><%= link user.id, to: Routes.admin_user_path(@conn, :show, user) %></td>
-        <td><%= user.name %></td>
+        <td><%= link user.name, to: Routes.admin_user_path(@conn, :show, user) %></td>
         <td><%= link user.email, to: "mailto:#{user.email}" %></td>
-        <td><%= link user.slug.slug, to: Routes.slug_path(@conn, :show, user.slug.slug) %></td>
+        <td><%= link user.slug.slug, to: Routes.admin_user_path(@conn, :show, user) %></td>
         <td><%= user.is_admin %></td>
+        <td><%= user.deploy_only %></td>
+        <td><%= link gettext("Show"), to: Routes.slug_path(@conn, :show, user.slug.slug), class: "btn btn-sm btn-primary" %></td>
       </tr>
     <% end %>
   </table>
diff --git a/lib/kmxgit_web/templates/admin/user/show.html.heex b/lib/kmxgit_web/templates/admin/user/show.html.heex
index 8f81b6c..2c6ca42 100644
--- a/lib/kmxgit_web/templates/admin/user/show.html.heex
+++ b/lib/kmxgit_web/templates/admin/user/show.html.heex
@@ -46,11 +46,7 @@
     </tr>
     <tr>
       <th><%= gettext "SSH keys" %></th>
-      <td class="scroll-x">
-        <pre class="ssh_keys">
-          <%= @user.ssh_keys %>
-        </pre>
-      </td>
+      <td><pre class="admin_ssh_keys"><%= @user.ssh_keys %></pre></td>
     </tr>
   </table>
 
@@ -64,4 +60,7 @@
       to: Routes.admin_user_path(@conn, :edit, @user),
       class: "btn btn-primary" %>
 
+  <%= link gettext("Show"),
+      to: Routes.slug_path(@conn, :show, @user.slug.slug),
+      class: "btn btn-primary" %>
 </div>
diff --git a/priv/repo/migrations/20211130124538_add_deploy_keys_to_repositories.exs b/priv/repo/migrations/20211130124538_add_deploy_keys_to_repositories.exs
new file mode 100644
index 0000000..0d000cc
--- /dev/null
+++ b/priv/repo/migrations/20211130124538_add_deploy_keys_to_repositories.exs
@@ -0,0 +1,9 @@
+defmodule Kmxgit.Repo.Migrations.AddDeployKeysToRepositories do
+  use Ecto.Migration
+
+  def change do
+    alter table(:repositories) do
+      add :deploy_keys, :text
+    end
+  end
+end