PhoenixKitWeb.Components.Core.DashboardOverview (phoenix_kit v1.7.235)

Copy Markdown View Source

The operator half of the /admin landing page (PhoenixKitWeb.Live.Dashboard) — everything below its welcome block.

Renders three blocks, each independently gated by a boolean the caller computes:

  • the action-card grid (Users / Roles / Sessions / Live Activity / Add User / Email, plus the Refresh button);
  • Platform Statistics and its sub-grids (Active Sessions, Real-Time Activity, Secondary Statistics);
  • System Information.

No header, no flash — deliberately

This component renders no <h1> and no flash group. The page already owns exactly one of each: /admin gets its title and subtitle from the LayoutWrapper.app_layout breadcrumb and its flash from that layout. A second header here would put two on one page, which the merged admin-UI standard forbids (dev_docs/pull_requests/2026/673-admin-ui-standards/). The <h2>s below are section headings inside the page, the same level as the welcome block's greeting.

Gating is the caller's job, and it is not optional

Every visibility attr defaults to false, so a caller that forgets one hides the block rather than leaking it. The caller computes the booleans in the LiveView (the repo idiom — HEEx stays declarative) via PhoenixKitWeb.Live.Dashboard.Overview.assign_overview/3, which derives the card gates from PhoenixKitWeb.Users.Auth.can_access_admin_view?/2 — the same decision :phoenix_kit_ensure_admin enforces on the destination, so a visible card and the page it links to cannot disagree.

The statistics data attrs are only read inside :if={@show_statistics}, so a caller that hides the statistics may leave them nil — and should, since producing them costs three aggregate queries plus a migration-version read.

Spacing

The wrapper takes a class attr instead of hardcoding its own margins. The page owns the padded container (the admin LayoutWrapper <main> carries none of its own) and passes only the gap between the welcome block and this one — mt-8. Putting that gap here rather than under the welcome block is deliberate: everything in this component can be gated off, and then nothing renders at all, so the gap disappears with it instead of leaving a band of whitespace below the greeting.

Summary

Functions

Renders the gated operator overview.

Functions

dashboard_overview(assigns)

Renders the gated operator overview.

Blocks whose gate is false emit nothing at all — including the action-card grid's wrapper, whose mb-8 would otherwise leave a band of whitespace on a page where every card is hidden, and the outer wrapper itself, so a visitor who may see none of this gets no stray element (and no stray margin) from the component.

Attributes

  • class (:string) - extra classes for the wrapper — pass the page's own padding here. Defaults to nil.
  • show_users_card (:boolean) - Defaults to false.
  • show_roles_card (:boolean) - Defaults to false.
  • show_sessions_card (:boolean) - Defaults to false.
  • show_live_activity_card (:boolean) - Defaults to false.
  • show_add_user_card (:boolean) - Defaults to false.
  • show_email_card (:boolean) - Defaults to false.
  • show_statistics (:boolean) - gates Platform Statistics, System Information AND the Refresh button — refreshing re-runs the operator aggregates. Defaults to false.
  • stats (:map) - Defaults to nil.
  • session_stats (:map) - Defaults to nil.
  • presence_stats (:map) - Defaults to nil.
  • phoenix_kit_version (:string) - Defaults to nil.
  • migration_current (:any) - Defaults to nil.
  • migration_db (:any) - Defaults to nil.