PhoenixKitWeb.Components.UserDashboardNav (phoenix_kit v2.16.0)

Copy Markdown View Source

User dashboard navigation components for the PhoenixKit user dashboard. Provides navigation elements specifically for user dashboard pages.

Summary

Functions

Renders the user widget for dashboard navigation.

Functions

user_dropdown(assigns)

Renders the user widget for dashboard navigation.

For authenticated visitors this is the avatar dropdown (email, the admin area, Settings, language switcher, log out). For anonymous visitors the same dropdown shape is rendered with a generic "not signed in" icon and guest-relevant links (log in, sign up, forgot password, magic link) plus the same language switcher — so a single widget covers both states and always offers a language switcher.

One destination, two labels

Every signed-in visitor gets exactly one entry leading to /admin, because /admin is the one page core declares unconditionally and admits EVERY authenticated visitor to (PhoenixKitWeb.Users.Auth.landing_view?/1 exempts the index from the admin-area gate, and the page shows a permission-less visitor the welcome block and nothing else). An admin-area holder sees it as "Admin Panel" with a shield; everybody else sees "My Account" with a house. The two are mutually exclusive and share admin_entry_label/1.

The URL is always built with Routes.path("/admin"), so a host running config :phoenix_kit, admin_path: "/myaccount" gets /myaccount here for free — /admin stays the canonical spelling in code.

Attributes

  • :scope — current scope; nil/unauthenticated renders the guest dropdown.

  • :current_path — used for active-link highlighting and locale-switch URLs. Canonicalised before comparison, so a renamed admin segment still highlights.

  • :current_locale — the active locale. A full dialect ("en-US") is accepted: every URL built here reduces it to the base code the router actually serves (/en/…), so passing @current_locale rather than @current_locale_base no longer emits a link that costs a redirect.

  • :show_language_switcher — include the in-menu language list (default true). Set false when the host renders a standalone switcher elsewhere to avoid a duplicate. Applies to both the signed-in and guest states.

  • :guest_links — which guest links may appear, e.g. [:login, :register, :reset, :magic_link] (default: all). Links are also gated by the allow_registration / magic_link_login_enabled settings, so this list can only narrow, never force-enable a disabled feature.

  • :authenticated_links — which authenticated-menu entries may appear, e.g. [:admin, :dashboard, :settings, :logout] (default: all). Same narrowing rule as :guest_links:admin still requires Scope.can_access_admin_area?/1 to be true, so listing it can't grant an entry a non-admin shouldn't see. Use this to hide entries a host app's own navigation already covers.

    :dashboard is the "My Account" half of the pair described above — the admin-area entry shown to a visitor :admin does not cover. It used to point at the deprecated user dashboard (/dashboard, PhoenixKit.Install.Deprecations.user_dashboard_warning/0), which a host can compile out with user_dashboard_enabled: false — leaving this menu offering a 404. The key name is kept so hosts passing an explicit list need no edit.

Attributes

  • scope (:any) - Defaults to nil.
  • current_path (:string) - Defaults to "".
  • current_locale (:string) - Defaults to "en".
  • admin_edit_url (:string) - Defaults to nil.
  • admin_edit_label (:string) - Defaults to nil.
  • show_language_switcher (:boolean) - Defaults to true.
  • guest_links (:list) - Defaults to [:login, :register, :reset, :magic_link].
  • authenticated_links (:list) - Defaults to [:admin, :dashboard, :settings, :logout].