Skip to main content

Crate tablo_core

Crate tablo_core 

Source
Expand description

Tablo: a server-rendered admin toolkit on Topcoat and Toasty.

A Panel serves one Resource per Toasty model. A resource names the model and the RecordForm struct its create and edit submissions parse into, and declares the rest as one ResourceDef value: its Policy, which denies by default, and any Table or Schema that arranges or extends what the record form derives. The app mounts the panel on its own Topcoat router with RouterBuilderPanelExt::panel, which builds each def once, binds it to the database schema and checks it first; one router mounts any number of panels at distinct prefixes.

#[derive(tablo_core::RecordForm)]
#[form(model = Book)]
pub struct BookForm {
    pub title: String,
}

pub struct BookResource;

impl Resource for BookResource {
    type Model = Book;
    type Form = BookForm;

    fn declare() -> ResourceDef<Self> {
        ResourceDef::new().policy(Allow)
    }
}

let router = Router::builder()
    .discover()
    .app_context(db)
    .panel(Panel::new("admin").resource::<BookResource>())?
    .build();

The user guide walks through a complete panel and each part of it. ResourceDef lists everything a resource declares, Resource the hooks it overrides, and Panel every builder call.

Re-exports§

pub use auth::Auth;
pub use auth::Authenticator;
pub use auth::PanelUser;
pub use auth::PasswordAuth;
pub use auth::membership;
pub use form::FieldError;
pub use form::FieldErrorKind;
pub use form::FieldErrors;
pub use form::FormField;
pub use form::FormScalar;
pub use form::NoForm;
pub use form::Posted;
pub use form::RecordForm;
pub use navigation::NavTarget;
pub use navigation::NavigationItem;
pub use notification::Notification;
pub use notification::NotificationStatus;
pub use panel::Brand;
pub use panel::Panel;
pub use panel::RouterBuilderPanelExt;
pub use panel::can_list;
pub use panel::url;
pub use policy::Ability;
pub use policy::Allow;
pub use policy::Deny;
pub use policy::Policy;
pub use policy::ReadOnly;
pub use policy::when;
pub use resource::Action;
pub use resource::Committed;
pub use resource::ForeignKey;
pub use resource::Mutation;
pub use resource::Relation;
pub use resource::Resource;
pub use resource::ResourceDef;
pub use resource::can;
pub use resource::scoped_query;
pub use resource::scoped_view_query;
pub use resource::write_create;
pub use resource::write_update;
pub use schema::ChoiceField;
pub use schema::Control;
pub use schema::ControlInput;
pub use schema::CustomField;
pub use schema::EmbeddedForm;
pub use schema::Field;
pub use schema::FileField;
pub use schema::Grid;
pub use schema::Group;
pub use schema::IntoOptions;
pub use schema::IntoSchema;
pub use schema::Options;
pub use schema::Repeater;
pub use schema::Schema;
pub use schema::Section;
pub use schema::Source;
pub use schema::TextField;
pub use schema::Toggle;
pub use schema::declare;
pub use table::BooleanColumn;
pub use table::Column;
pub use table::ColumnWidth;
pub use table::ComputedColumn;
pub use table::Cursor;
pub use table::DateFilter;
pub use table::Filter;
pub use table::FilterInput;
pub use table::Includes;
pub use table::IntoColumns;
pub use table::IntoFilters;
pub use table::QueryFilter;
pub use table::SelectFilter;
pub use table::Sort;
pub use table::Table;
pub use table::TablePage;
pub use table::TableState;
pub use table::TernaryFilter;
pub use table::TextColumn;
pub use table::contains_expr;
pub use tenancy::Membership;
pub use tenancy::Tenancy;
pub use tenancy::Tenant;
pub use tenancy::require_tenant;
pub use tenancy::tenant_id;
pub use upload::Uploader;

Modules§

auth
Authenticates panel users and gates panel routes.
csrf
CSRF protection via double-submit cookie.
db
The Db glue: how Tablo code reaches the pooled Toasty database.
form
Record forms: the typed value a form submission parses into, and the write that stores it.
navigation
Sidebar navigation: NavigationItem and the NavTarget it points with.
notification
Transient user-visible message produced by an Action’s result and rendered in the Panel shell; stored as a JSON flash cookie with hardened attributes that Topcoat flushes on error responses too (topcoat#408).
panel
Panel — an admin panel an app mounts into its router.
policy
Authorizes resource abilities, denying by default.
resource
Resource — maps one Toasty Model to its admin UI.
schema
Unified Schema primitive — fields and layout blocks that compose via view!.
table
A resource’s list view: the Table builder and its columns and filters, the URL state a list reads, query planning (filter_expr/search_expr/order_bys_for), and the page a table loads.
tenancy
Scopes resources to the request tenant.
upload
Names where uploaded bytes go: a file field binds a String column and the app’s Uploader decides what path the record stores.

Macros§

lens
Build a Lens from a model and a field, or a chain of embedded fields.

Structs§

DeclarationError
One declaration mistake: who declares it, where, and what is wrong.
Lens
A model field’s typed path, which queries filter and sort on, paired with the function that reads the field off a loaded record.
MountError
Why RouterBuilderPanelExt::panel refused a panel: every declaration mistake it found.

Enums§

DeclarationErrorKind
What is wrong with a declaration.
SegmentFault
Why a path segment cannot be a literal URL segment.
Site
The part of a declaration a DeclarationError is in.

Traits§

Page
A panel page that is not a resource, mounted at {prefix}/{slug} with a sidebar entry; the panel owns the route and entry while the page owns its markup.

Derive Macros§

EmbeddedForm
Derives EmbeddedForm for an embedded struct or enum.
Options
Derive Options for a unit-variant enum: the (value, label) list a choice field, a select filter and a column share.
RecordForm
Derive RecordForm for the typed value a resource’s form writes.