Beacon.LiveAdmin.PageBuilder behaviour (Beacon LiveAdmin v0.4.2)

View Source

The foundation for building admin pages.

Either built-in pages and custom pages on your app should implement these callbacks to properly mount the menu and the private assigns used by LiveAdmin.

Summary

Types

session()

@type session() :: map()

unsigned_params()

@type unsigned_params() :: map()

Callbacks

handle_event(event, unsigned_params, socket)

(optional)
@callback handle_event(
  event :: binary(),
  unsigned_params(),
  socket :: Phoenix.LiveView.Socket.t()
) ::
  {:noreply, Phoenix.LiveView.Socket.t()}
  | {:reply, map(), Phoenix.LiveView.Socket.t()}

handle_info(msg, socket)

(optional)
@callback handle_info(msg :: term(), socket :: Phoenix.LiveView.Socket.t()) ::
  {:noreply, Phoenix.LiveView.Socket.t()}

handle_params(unsigned_params, uri, socket)

(optional)
@callback handle_params(
  unsigned_params(),
  uri :: String.t(),
  socket :: Phoenix.LiveView.Socket.t()
) ::
  {:noreply, Phoenix.LiveView.Socket.t()}

init(term)

@callback init(term()) :: {:ok, session()}

menu_link(prefix, live_action)

@callback menu_link(prefix :: String.t(), live_action :: atom()) ::
  {:root, String.t()} | {:submenu, String.t()} | :skip

menu_link(prefix, live_action, icon)

(optional)
@callback menu_link(prefix :: String.t(), live_action :: atom(), icon :: String.t()) ::
  {:root, String.t()} | {:submenu, String.t()} | :skip

mount(unsigned_params, session, socket)

(optional)

render(assigns)

@callback render(assigns :: Phoenix.LiveView.Socket.assigns()) ::
  Phoenix.LiveView.Rendered.t()