WardrikWeb.Extension behaviour (wardrik_web v0.1.0-rc.1)

Copy Markdown

An extension adds pages and panels to the dashboard.

A page is a LiveView with its own link in the navigation. A panel is a LiveComponent shown on an existing page.

List your extensions in WardrikWeb.Router.wardrik_dashboard/2:

wardrik_dashboard "/wardrik",
  resolver: {MyAppWeb.WardrikResolver, []},
  extensions: [MyAppWeb.DashboardExtension]

An extension looks like this:

defmodule MyAppWeb.DashboardExtension do
  use WardrikWeb.Extension

  @impl WardrikWeb.Extension
  def pages, do: [%WardrikWeb.Page{path: "fleet", label: "Fleet", live: MyApp.FleetLive}]

  @impl WardrikWeb.Extension
  def panels(:agents), do: [MyApp.BulkActions]
  def panels(_slot), do: []
end

Every panel gets @scope and @dashboard. Each slot also passes these assigns:

SlotWhere the panel is shownAssigns
:agentsAbove the agents list@agents: the result of agents.list
:agentNext to an agent's timeline@agent: the agent ID. @conversation: the conversation ID. @read: the result of agent.read

Summary

Types

Where a panel is shown.

Callbacks

Returns the pages the extension adds. Defaults to [].

Returns the panels the extension adds to slot. Defaults to [].

Types

slot()

@type slot() :: :agents | :agent

Where a panel is shown.

Callbacks

pages()

@callback pages() :: [WardrikWeb.Page.t()]

Returns the pages the extension adds. Defaults to [].

panels(slot)

@callback panels(slot()) :: [module()]

Returns the panels the extension adds to slot. Defaults to [].