Expand description
The auto-generated admin UI.
Modules§
- from_
schema - Phase 14, commit 5 — bridge from
ModelSchemato admin metadata.
Structs§
- Admin
- Builder for the admin. Register models with
.model::<M>(), then hand it to the router viaregister_admin_routes. - Admin
Action - One action-log row as loaded from the DB. The
user_emailis joined in byrecentandfor_objectso the timeline can render the acting user without a second round-trip. - Admin
Entry - Runtime metadata about one admin-registered model.
- Admin
Field - Admin
Relation - Admin
Theme - 1.8.2 — full admin chrome palette. Each field maps onto one of the
framework’s
--rio-*design tokens defined inadmin/base.html, so overriding these values viaAdmin::theme(...)re-skins the entire admin shell (topbar, sidebar, body, cards, headings, hairlines) without touching CSS or rebuilding Tailwind. - FieldUI
- Everything a form / list renderer needs to present one field to a human. All strings are plain text (no HTML) — the caller escapes before emitting.
- Filter
Def - One filter the list page should show for a model. Produced by
infer_filters. - Inverse
Relation - One reverse (
HasMany) relation — an incoming edge pointing at a given target model. Produced by inverting every storedBelongsToat registry-build time. Consumed by the inverse-panel renderer and the delete guard. - LogEntry
- What callers hand to
record. Kept as a borrow-friendly struct so handlers don’t need to clone field strings. - Relation
Registry - Relation lookup tables for one snapshot of the schema.
- Resolved
Relation - One forward (
BelongsTo) relation resolved against the schema. - Site
Branding - Per-project admin branding. Defaults are RustIO-flavoured;
projects override via
Admin::site_branding. - Suggestion
- One proposed action shown next to a dashboard alert.
- User
Profile Row - One key-value row inside a
UserProfileSection. Both fields areStringso projects can format whatever shape they need (numbers, dates, comma-joined lists). Rendered escaped — pass plain text; for arbitrary HTML, projects override the template block instead. - User
Profile Section - One labeled section rendered in the project-extension area of the
built-in user profile page (admin/user_view.html —
{% block project_user_fields %}). A project’s extension closure returnsVec<UserProfileSection>so it can contribute multiple disjoint areas (e.g. “Halal certification” + “Restaurant assignments”) in a single registration.
Enums§
- Action
Type - The three classes of admin mutation we track.
deletecovers both individual and bulk deletions — each bulk-delete row writes its ownDeleteentry so object history is per-row complete. - Confidence
- How sure the suggestion engine is that this is the right action.
- Field
Role - The role a field plays in the admin UI. One field maps to exactly
one role; the ordering of branches in
classify_fieldresolves overlaps (e.g. anemailcolumn isFieldRole::Email, notFieldRole::PlainText). - Field
Type - Filter
Kind - What shape of filter the admin list page should render for a given field. Each variant maps to a concrete HTML control.
- Registry
Error - Why a
RelationRegistrydeclaration was rejected. Each variant names the enclosing relation so CLI tooling (rustio schema,ai validate) can point a user straight at the bad declaration. - Search
Intent - What the user probably typed into the list-page search box. Letting the handler branch on this gives cleaner narrow-match behaviour than “grep every String field”.
Constants§
- RELATION_
FILTER_ DROPDOWN_ CAP - Soft cap on the number of rows a relation filter will expose as a
<select>dropdown. Above this threshold the admin renders a numeric-id input instead, with a muted hint explaining why.
Traits§
- Admin
Model - What the
#[derive(RustioAdmin)]macro produces for each struct.
Functions§
- classify_
field - Assign a
FieldRoleto one field, taking context into account. - classify_
search - Guess what the user meant by the text in the list-page search box. Order of tries: numeric → email → personnummer → text.
- classify_
search_ for_ field - 0.8.0 — variant of
classify_searchthat knows the field is a relation. When the query parses as a non-negative integer, emitsSearchIntent::RelationIdcarrying the target model; otherwise falls through toclassify_searchfor the usual shape-based routing. Called by the admin search handler when the user is searching a specific FK column. - context_
global - Process-global cache for the project’s
rustio.context.json. - derive_
relation_ suggestions - 0.8.0 — propose linking an orphan
<thing>_idcolumn to a known model when the schema has noRelationrecorded for it. Fired from&Schemadirectly because relation metadata lives there (not on admin entries). - derive_
suggestions - Enumerate every suggestion for the current project. Empty when
no context is loaded or when no model overlaps the industry’s
convention list. Deterministic: iteration follows the order of
entriesthenindustry_schema.required_fields. - derive_
suggestions_ from_ entries - 0.7.3 schema-backed variant. Same rules as
derive_suggestionsbut reads field names from [DynamicAdminEntry], which the admin builds fresh from [crate::admin::schema_cache] on every dashboard render. When the cache sees an updatedrustio.schema.json— e.g. afterrustio ai apply+rustio schema+[Reload schema]— the suggestion for the just-added field disappears on the next response, without restarting the process. - ensure_
table - Ensure the
rustio_admin_actionstable and its indexes exist. Idempotent — usesCREATE TABLE IF NOT EXISTS+CREATE INDEX IF NOT EXISTS. Depends onrustio_usersexisting first (the FK target); callers should runauth::init_user_tablesbefore this. - field_
ui_ metadata - Package a field’s display metadata for the admin form / list renderers. All strings are plain text — escape before emitting.
- field_
ui_ metadata_ with_ relation - 0.8.0 — like
field_ui_metadatabut relation-aware. Pass the singular display name of the target model (e.g."Applicant") when the schema records a relation for this field; the returnedFieldUIthen carriesrelation_labeland a form hint of the form “Foreign key to Applicant”. PassingNoneis equivalent to callingfield_ui_metadata. - find_
relation_ suggestion - Companion to
derive_relation_suggestions— locate one by(admin_name, field). Same rejection-of-crafted-URLs story asfind_suggestion. - find_
suggestion - Look up a specific suggestion by
(admin_name, field). ReturnsNoneif the pair isn’t in the current derived set — this is how the route handlers reject crafted URLs. An operator can only click through suggestions the engine actually produced. - find_
suggestion_ from_ entries - Schema-backed counterpart to
find_suggestion. - for_
object - All actions for one
(model, object_id), newest first. - format_
relation_ cell - Render “Target #42” for a foreign-key cell on a list view. Falls
back to the raw id when the caller doesn’t have a target name.
Kept as a free function so the admin list renderer doesn’t have to
reach into
FieldUIdirectly for the common case. - infer_
filters - Infer the filter controls for a model’s list page from its fields
plus active context. Order follows the order of
fields; every filter references a field that actually exists on the model. - infer_
filters_ with_ relations - 0.8.0 — like
infer_filtersbut invokesrelation_target_offor each field to detect relation columns. If the callback returnsSome(target), the filter is emitted asFilterKind::RelationSelectinstead of the numeric-exact fallback. - mask_
pii - Produce a masked display string for a sensitive value. Keeps the
first few characters so a reviewer can tell which row they’re
looking at, replaces the rest with
•. Length of the output matches the input so the layout doesn’t jump when a user toggles visibility. - recent
- Fetch the most recent
limitadmin actions, newest first. Optional filters bymodel_nameand byaction_typestring (the UI passes both through as URL query params, so we take them as&strrather than typed enums). - record
- Write one row to the action log.
- register_
admin_ routes