# `WardrikWeb.Extension`

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:

| Slot | Where the panel is shown | Assigns |
| --- | --- | --- |
| `:agents` | Above the agents list | `@agents`: the result of `agents.list` |
| `:agent` | Next to an agent's timeline | `@agent`: the agent ID. `@conversation`: the conversation ID. `@read`: the result of `agent.read` |

# `slot`

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

Where a panel is shown.

# `pages`

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

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

# `panels`

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

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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
