KartaWeb.Navigation (Karta v1.0.0)

What the admin interface's navigation shows: the areas at each level (the instance, an organisation, a mail server) and the trail of breadcrumbs to the current page. KartaWeb.Layouts.app/1 renders both from the page's context:

  • :current_scope - who is looking (Karta.Accounts.Scope);
  • :organisation, :server - the records the page is about, already loaded for the scope by KartaWeb.Authorize (or nil);
  • :active - the area the page belongs to (an item's id);
  • :crumb - the record the page shows (a domain, a message), named in the last breadcrumb; or a list of {label, path}, the records on the way to it (a webhook) and it (one of its deliveries).

An item is listed only when the scope may use its page (KartaWeb.Authorize.allowed?/2 with the item's permission). Only pages that exist are listed: an area that later work adds gets its item here with its page, never before. The order of the sections and items is the order on screen.

Summary

Types

A breadcrumb: a label, and a path unless it is the current page.

One entry: what it is called, where it leads, and whether it is the current area.

A group of items: the instance, an organisation or a mail server.

Functions

The breadcrumbs for the page's context: the organisations, the organisation and the mail server the page is in, then the page's own area when it is not the overview of the last of them, then :crumb (a label for the record the page shows: a domain, a message; or the {label, path} of each record on the way to it, and its own) when given. The last crumb has no path; a page outside any organisation that is not the organisations list has only its :crumb.

The sections of the sidebar, in order, for the page's context.

Types

crumb()

@type crumb() :: %{label: String.t(), path: String.t() | nil}

A breadcrumb: a label, and a path unless it is the current page.

item()

@type item() :: %{
  id: atom(),
  label: String.t(),
  icon: String.t(),
  path: String.t(),
  active: boolean()
}

One entry: what it is called, where it leads, and whether it is the current area.

section()

@type section() :: %{
  id: atom(),
  title: String.t() | nil,
  kind: String.t() | nil,
  path: String.t() | nil,
  items: [item()]
}

A group of items: the instance, an organisation or a mail server.

Functions

sections(context)

@spec sections(map()) :: [section()]

The sections of the sidebar, in order, for the page's context.