MishkaCmsCore.Sidebar.Group (Mishka CMS Core v0.0.1)

Copy Markdown View Source

A collapsible section of the admin sidebar — the heading a set of MishkaCmsCore.Sidebar.Item links sit under, and the unit an admin collapses, reorders or hides.

A group carries no path of its own: it exists only to hold items, and MishkaCmsCore.Sidebar.menu/1 drops it entirely once permission filtering leaves it with none. items is filled in by menu/1, not by the plugin that declares the group — an extension contributes items with group: "<key>" and never has to know which other extension owns the section, so several extensions can share one heading (that is how Blog and Documents both land under Plugins).

key is the identity: the DOM id of the collapse target, the settings key prefix (sidebar.<key>.order), and what Sidebar.collect/0 de-duplicates on. Keep it stable — renaming it orphans an admin's saved order.

permissions is a list where holding ANY grants — a name, or {:under, prefix} for anyone holding anything under prefix (MishkaCmsCore.Accounts.Checks.AccessPermissions); [] means "any signed-in admin". position is :main (the scrolling nav) or :footer (pinned above the sidebar's bottom edge, where Settings lives).

See MishkaCmsCore.Sidebar for the event contract and MishkaCmsCore.Sidebar.Item.

Summary

Functions

A sample %MishkaCmsCore.Sidebar.Group{} populated from defaults + type-based fallbacks.

Builds a group, raising on an invalid declaration.

Types

t()

@type t() :: %MishkaCmsCore.Sidebar.Group{
  icon: String.t() | nil,
  items: list() | nil,
  key: String.t(),
  label: String.t(),
  order: integer() | nil,
  permissions: list() | nil,
  position: atom() | nil
}

Functions

builder(attrs_or_input, error \\ false)

enforce_keys()

enforce_keys(field)

example()

A sample %MishkaCmsCore.Sidebar.Group{} populated from defaults + type-based fallbacks.

keys()

keys(field)

new!(attrs)

@spec new!(map()) :: t()

Builds a group, raising on an invalid declaration.

Menus are declared in module attributes so a descriptor is built once at compile time rather than on every admin mount; that also means a malformed group fails the build instead of a page render.