Skip to main content

Module admin_page

Module admin_page 

Source
Expand description

Extension point for custom admin pages.

Authors building on top of rustango-cms register a unit-struct handler via crate::register_admin_page! and it appears as a sidebar entry under its declared SidebarSection. All registered handlers route through a single dispatcher mounted at /cms-admin/x/{slug}; no per-page router scaffolding to maintain.

Custom pages inherit the bundled admin chrome — they extend rcms_admin/_base.html and get the sidebar, topbar, action-bar slot, flash banners, theme tokens, and every class from cms.css for free.

§Example

ⓘ
use axum::response::Response;
use async_trait::async_trait;
use rustango_cms::admin::admin_page::{AdminPageCtx, AdminPageHandler, SidebarSection};

#[derive(Default)]
pub struct ReportsDashboard;

#[async_trait]
impl AdminPageHandler for ReportsDashboard {
    fn slug(&self) -> &'static str { "reports" }              // → /cms-admin/x/reports
    fn label(&self) -> &'static str { "Reports" }
    fn icon(&self) -> Option<&'static str> { Some("insights") }
    fn section(&self) -> SidebarSection { SidebarSection::Site }
    async fn render(&self, ctx: AdminPageCtx<'_>) -> Response {
        // Build a Tera context, render `reports.html` (host-registered),
        // return the response.
        todo!()
    }
}

rustango_cms::register_admin_page!(ReportsDashboard);

Structs§

AdminForm
A posted application/x-www-form-urlencoded body, in field order. Repeated names (checkbox lists, multi-selects) keep every value.
AdminPageCtx
Request-scoped context handed to every custom admin page. References rather than owns so the handler doesn’t have to clone the Tera instance / per-tenant pool.
AdminPageHandlerRegistration
Registration entry submitted via inventory::submit! by the register_admin_page! macro. Mirrors PageTypeHandlerRegistration.

Enums§

MessageLevel
Message severity, in five levels.
SidebarSection
Where the custom page’s sidebar entry lands. Built-ins: Content, Site, Settings. Use Custom(&'static str) to spin up a new section heading on demand (e.g. Custom("Tools")).

Traits§

AdminPageHandler
Trait every custom admin page implements. Compiled-in via the inventory registry — see crate::register_admin_page!.

Functions§

find_admin_page
Find a registered handler by slug. Returns None for unknown slugs — the dispatch route maps that to a 404.
registered_admin_pages
Iterator over every registered handler. Used by the sidebar enumeration in add_chrome() and by the route dispatcher.
required_codename
The codename a request to admin page slug needs, or None when the page declares no AdminPageHandler::permission_resource (or no page has that slug: the dispatcher answers 404).