From 20101201c6e5251ee129d393fdb643d16d25d964 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Tue, 6 Jan 2026 13:04:22 -0600 Subject: [PATCH] Fix admin layout to use proper Phoenix component pattern The admin layout was incorrectly defined as a separate .html.heex file using @inner_content. Phoenix components should use render_slot(@inner_block). Moved admin layout definition into layouts.ex as a proper function component, matching the pattern used by app/1 and authenticated/1 layouts. --- lib/towerops_web/components/layouts.ex | 65 +++++++++++++++++++ .../components/layouts/admin.html.heex | 37 ----------- 2 files changed, 65 insertions(+), 37 deletions(-) delete mode 100644 lib/towerops_web/components/layouts/admin.html.heex diff --git a/lib/towerops_web/components/layouts.ex b/lib/towerops_web/components/layouts.ex index a377730d..346f25d1 100644 --- a/lib/towerops_web/components/layouts.ex +++ b/lib/towerops_web/components/layouts.ex @@ -302,4 +302,69 @@ defmodule ToweropsWeb.Layouts do """ end + + @doc """ + Renders the admin layout. + + Use this for admin pages that require superuser access. + + ## Examples + + +

Admin Content

+
+ + """ + attr :flash, :map, required: true, doc: "the map of flash messages" + + slot :inner_block, required: true + + def admin(assigns) do + ~H""" +
+ + +
+ {render_slot(@inner_block)} +
+
+ + <.flash_group flash={@flash} /> + """ + end end diff --git a/lib/towerops_web/components/layouts/admin.html.heex b/lib/towerops_web/components/layouts/admin.html.heex deleted file mode 100644 index 21eb3fa7..00000000 --- a/lib/towerops_web/components/layouts/admin.html.heex +++ /dev/null @@ -1,37 +0,0 @@ -
- - -
- <.flash_group flash={@flash} /> - {@inner_content} -
-