Skip to main content

Crate renox_admin

Crate renox_admin 

Source
Expand description

An admin panel for Renox apps, generated from their models (Laravel’s Filament resources): each model is declared once, as an AdminResource (its grid columns, its form fields, its policy), and the panel gives it a list with search, filters, sorting, bulk actions and exports, and create, edit, view and delete pages, on the UI kit and renox::grid.

use renox::prelude::*;
use renox_admin::Admin;

App::new()
    .module(Auth::new())
    .module(
        Admin::new()
            .title("Back office")
            .authorize(|user| user.has_role("staff")) // who may open the panel
            .resource(Products),
    )

The panel lives at /admin (path), behind a login. Nobody gets in until Admin::authorize (or Admin::gate) says who may; then each page asks the resource’s AdminResource::allows, which by default asks the model’s Policy (viewAny, view, create, update, delete, …). Pages are built-in templates (renox-admin/*.html) that an app replaces with files of the same name. The guide is docs/admin.md in the Renox repository.

Re-exports§

pub use entry::Entry;
pub use field::Field;
pub use field::FieldKind;
pub use relation::RelationManager;
pub use resource::ActionContext;
pub use resource::ActionInput;
pub use resource::AdminAction;
pub use resource::AdminResource;
pub use resource::BoxFuture;
pub use resource::Filter;
pub use resource::SaveContext;

Modules§

entry
A record’s details on its view page: what AdminResource::entries returns, drawn with the UI kit’s infolist and entry.
field
A resource’s form fields: what AdminResource::fields returns, drawn on the create and edit pages with the UI kit’s field macros.
relation
Child rows managed from a record’s own pages (Filament’s relation managers): RelationManager.
resource
What an app declares for each model in the panel: AdminResource, with its AdminActions and Filters.

Structs§

Admin
The admin panel module: its address, its title, who may use it and its resources.

Enums§

Slot
A place in the panel’s layout where an app (or a module) adds content without replacing the layout: Admin::slot, or a file of the slot’s name under the app’s views (renox-admin/slots/after_content.html). A slot’s template sees the page’s values (admin, resource, record, title, …) and the request’s globals (request.route, auth, …).