defmodule VigilWeb.OrgSettingsLive.Components do
@moduledoc "The tab bar the organization settings pages share."
use VigilWeb, :html
attr :scope, :map, required: true
attr :tab, :atom, required: true
slot :inner_block, required: true
def settings(assigns) do
slug = assigns.scope.organization.slug
assigns =
assign(assigns, :tabs, [
{:general, "General", ~p"/orgs/#{slug}/settings", "hero-adjustments-horizontal-micro"},
{:members, "Members", ~p"/orgs/#{slug}/settings/members", "hero-users-micro"},
{:invites, "Invites", ~p"/orgs/#{slug}/settings/invites", "hero-envelope-micro"},
{:teams, "Teams", ~p"/orgs/#{slug}/settings/teams", "hero-user-group-micro"},
{:groups, "Groups", ~p"/orgs/#{slug}/settings/groups", "hero-identification-micro"},
{:audit, "Audit log", ~p"/orgs/#{slug}/settings/audit",
"hero-clipboard-document-list-micro"}
])
~H"""
<div class="shader-glass space-y-6">
<.header>
{@scope.organization.name}
<:subtitle>Organization settings</:subtitle>
</.header>
<nav class="flex flex-wrap gap-1 border-b border-base-300 pb-2" id="settings-tabs">
<.link
:for={{id, label, path, icon} <- @tabs}
navigate={path}
id={"tab-#{id}"}
aria-current={@tab == id && "page"}
class={[
"btn btn-sm gap-1.5",
if(@tab == id, do: "btn-primary btn-soft", else: "btn-ghost")
]}
>
<.icon name={icon} class="size-4" /> {label}
</.link>
</nav>
{render_slot(@inner_block)}
</div>
"""
end
@doc "When a role-gated action was refused."
def forbidden_message(:last_owner), do: "An organization needs at least one owner."
def forbidden_message(:forbidden), do: "Your role here doesn't allow that."
def forbidden_message(:declared), do: "That rule comes from config; change it there."
def forbidden_message(_), do: "That didn't work."
end
neiam
/vigil
public · Issues · Pulls · Labels · Forks · Compare · Actions queued · Badges · Packages
⭐
Log in to mark this repository.
2.0 KiB · text
History
573fef1