refactor: extract shared admin_links component, add to map sidebar
Some checks failed
Build and Push / Build and Push Docker Image (push) Failing after 4m49s
Some checks failed
Build and Push / Build and Push Docker Image (push) Failing after 4m49s
This commit is contained in:
parent
124f3b67fb
commit
15d6284602
2 changed files with 49 additions and 30 deletions
|
|
@ -74,12 +74,7 @@ defmodule MicrowavepropWeb.Layouts do
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
class="dropdown-content menu bg-base-100 rounded-box z-[1] w-44 p-2 shadow-lg"
|
class="dropdown-content menu bg-base-100 rounded-box z-[1] w-44 p-2 shadow-lg"
|
||||||
>
|
>
|
||||||
<li><.link href="/admin/dashboard">Dashboard</.link></li>
|
<.admin_links variant={:dropdown} />
|
||||||
<li><.link navigate="/users">Users</.link></li>
|
|
||||||
<li><.link navigate="/admin/beacon-monitors">Beacon monitors</.link></li>
|
|
||||||
<li><.link navigate="/admin/contact-edits">Contact edits</.link></li>
|
|
||||||
<li><.link navigate="/status">Status</.link></li>
|
|
||||||
<li><.link href="/admin/oban">Oban</.link></li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<%= if @current_scope && @current_scope.user do %>
|
<%= if @current_scope && @current_scope.user do %>
|
||||||
|
|
@ -173,30 +168,7 @@ defmodule MicrowavepropWeb.Layouts do
|
||||||
<div class="px-3 py-1 text-xs font-semibold uppercase tracking-wider text-base-content/40">
|
<div class="px-3 py-1 text-xs font-semibold uppercase tracking-wider text-base-content/40">
|
||||||
Admin
|
Admin
|
||||||
</div>
|
</div>
|
||||||
<.link
|
<.admin_links variant={:mobile} />
|
||||||
href="/admin/dashboard"
|
|
||||||
class="block px-3 py-2.5 rounded-lg hover:bg-base-200 transition-colors text-sm font-medium"
|
|
||||||
>Dashboard</.link>
|
|
||||||
<.link
|
|
||||||
navigate="/users"
|
|
||||||
class="block px-3 py-2.5 rounded-lg hover:bg-base-200 transition-colors text-sm font-medium"
|
|
||||||
>Users</.link>
|
|
||||||
<.link
|
|
||||||
navigate="/admin/beacon-monitors"
|
|
||||||
class="block px-3 py-2.5 rounded-lg hover:bg-base-200 transition-colors text-sm font-medium"
|
|
||||||
>Beacon monitors</.link>
|
|
||||||
<.link
|
|
||||||
navigate="/admin/contact-edits"
|
|
||||||
class="block px-3 py-2.5 rounded-lg hover:bg-base-200 transition-colors text-sm font-medium"
|
|
||||||
>Contact edits</.link>
|
|
||||||
<.link
|
|
||||||
navigate="/status"
|
|
||||||
class="block px-3 py-2.5 rounded-lg hover:bg-base-200 transition-colors text-sm font-medium"
|
|
||||||
>Status</.link>
|
|
||||||
<.link
|
|
||||||
href="/admin/oban"
|
|
||||||
class="block px-3 py-2.5 rounded-lg hover:bg-base-200 transition-colors text-sm font-medium"
|
|
||||||
>Oban</.link>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="border-t border-base-200 my-2"></div>
|
<div class="border-t border-base-200 my-2"></div>
|
||||||
<%= if @current_scope && @current_scope.user do %>
|
<%= if @current_scope && @current_scope.user do %>
|
||||||
|
|
@ -420,4 +392,41 @@ defmodule MicrowavepropWeb.Layouts do
|
||||||
</div>
|
</div>
|
||||||
"""
|
"""
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Renders admin navigation links. Use `variant` to control markup for each context:
|
||||||
|
|
||||||
|
* `:dropdown` — `<li>` items for daisyUI dropdown menus
|
||||||
|
* `:mobile` — styled block links for the mobile hamburger menu
|
||||||
|
* `:sidebar` — `<li>` items for daisyUI menu lists (map sidebar)
|
||||||
|
"""
|
||||||
|
attr :variant, :atom, default: :dropdown, values: [:dropdown, :mobile, :sidebar]
|
||||||
|
|
||||||
|
@spec admin_links(assigns :: map()) :: Rendered.t()
|
||||||
|
def admin_links(assigns) do
|
||||||
|
~H"""
|
||||||
|
<%= for link <- [
|
||||||
|
%{label: "Dashboard", href: "/admin/dashboard"},
|
||||||
|
%{label: "Users", navigate: "/users"},
|
||||||
|
%{label: "Beacon monitors", navigate: "/admin/beacon-monitors"},
|
||||||
|
%{label: "Contact edits", navigate: "/admin/contact-edits"},
|
||||||
|
%{label: "Status", navigate: "/status"},
|
||||||
|
%{label: "Oban", href: "/admin/oban"}
|
||||||
|
] do %>
|
||||||
|
<%= if @variant == :dropdown do %>
|
||||||
|
<li><.link navigate={link[:navigate]} href={link[:href]}>{link.label}</.link></li>
|
||||||
|
<% end %>
|
||||||
|
<%= if @variant == :mobile do %>
|
||||||
|
<.link
|
||||||
|
navigate={link[:navigate]}
|
||||||
|
href={link[:href]}
|
||||||
|
class="block px-3 py-2.5 rounded-lg hover:bg-base-200 transition-colors text-sm font-medium"
|
||||||
|
>{link.label}</.link>
|
||||||
|
<% end %>
|
||||||
|
<%= if @variant == :sidebar do %>
|
||||||
|
<li><.link navigate={link[:navigate]} href={link[:href]}>{link.label}</.link></li>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
"""
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@ defmodule MicrowavepropWeb.MapLive do
|
||||||
use MicrowavepropWeb, :live_view
|
use MicrowavepropWeb, :live_view
|
||||||
use LiveStash, stored_keys: [:selected_band, :selected_time]
|
use LiveStash, stored_keys: [:selected_band, :selected_time]
|
||||||
|
|
||||||
|
import MicrowavepropWeb.Layouts, only: [admin_links: 1]
|
||||||
|
|
||||||
alias Microwaveprop.Propagation
|
alias Microwaveprop.Propagation
|
||||||
alias Microwaveprop.Propagation.BandConfig
|
alias Microwaveprop.Propagation.BandConfig
|
||||||
alias Microwaveprop.Propagation.PipelineStatus
|
alias Microwaveprop.Propagation.PipelineStatus
|
||||||
|
|
@ -995,6 +997,14 @@ defmodule MicrowavepropWeb.MapLive do
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<%!-- Admin --%>
|
||||||
|
<ul
|
||||||
|
:if={@current_scope && @current_scope.user && @current_scope.user.is_admin}
|
||||||
|
class="menu menu-xs border-t border-base-300 pt-2 px-0"
|
||||||
|
>
|
||||||
|
<.admin_links variant={:sidebar} />
|
||||||
|
</ul>
|
||||||
|
|
||||||
<%!-- Auth --%>
|
<%!-- Auth --%>
|
||||||
<ul class="menu menu-xs border-t border-base-300 pt-2 px-0">
|
<ul class="menu menu-xs border-t border-base-300 pt-2 px-0">
|
||||||
<%= if @current_scope && @current_scope.user do %>
|
<%= if @current_scope && @current_scope.user do %>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue