MailglassAdmin.Preview.Sidebar (MailglassAdmin v2.3.0)

Copy Markdown View Source

Content-level email preview pickers with always-visible scenario groups and status badges. picker/1 renders the full browse directory for the preview index; menu/1 renders the compact document-selector control for individual preview pages.

Branches on the second element of each {mod, reflection} tuple from MailglassAdmin.Preview.Discovery.discover/1:

  • list when is_list(list) — healthy mailable; render a static group label with scenario links. Active scenario gets a Glass left border; inactive gets border-transparent + hover state.
  • :no_previews — stub mailable; shows the literal copy "No previews defined" per UI-SPEC Copywriting Contract line 457.
  • {:error, _} — preview_props/0 raised during discovery; shows a warning badge (via MailglassAdmin.Components.badge/1).

Boundary classification: submodule auto-classifies into the MailglassAdmin root boundary.

Summary

Functions

Renders a compact grouped menu for switching the current email preview.

Renders the email preview picker.

Absolute /<mount>/<Mailable>/<scenario> path (no query string).

Functions

mailable_entry(assigns)

Attributes

  • mod (:atom) (required)
  • reflection (:any) (required)
  • current_mailable (:atom) - Defaults to nil.
  • current_scenario (:atom) - Defaults to nil.
  • device_width (:integer) - Defaults to 768.
  • admin_chrome_theme (:atom) - Defaults to nil.
  • mount_path (:string) - Defaults to nil.

mailable_menu_entry(assigns)

Attributes

  • mod (:atom) (required)
  • reflection (:any) (required)
  • current_mailable (:atom) - Defaults to nil.
  • current_scenario (:atom) - Defaults to nil.
  • device_width (:integer) - Defaults to 768.
  • admin_chrome_theme (:atom) - Defaults to nil.
  • mount_path (:string) - Defaults to nil.

picker(assigns)

(since 0.1.0)

Renders the email preview picker.

mailables is the list of {module, reflection} tuples produced by MailglassAdmin.Preview.Discovery.discover/1. current_mailable and current_scenario drive the active-item highlight.

Attributes

  • mailables (:list) (required)
  • current_mailable (:atom) - Defaults to nil.
  • current_scenario (:atom) - Defaults to nil.
  • device_width (:integer) - Defaults to 768.
  • admin_chrome_theme (:atom) - Defaults to nil.
  • mount_path (:string) - Defaults to nil.
  • testid (:string) - Defaults to "preview-mailables-picker".

scenario_base_path(mount_path, mod, scenario)

@spec scenario_base_path(String.t() | nil, module(), atom() | String.t()) ::
  String.t()

Absolute /<mount>/<Mailable>/<scenario> path (no query string).

Shared by the sidebar links and PreviewLive's start-page deep link so both build identical, mount-aware URLs. mount_path is the absolute base the admin surface is mounted at (/dev/mail, /admin/preview, …) as recovered by MailglassAdmin.MountPath.base/1.