Skip to main content

Module resources

Module resources 

Source
Expand description

Admin-resource registry — single source of truth for the CRUD permissions matrix on /cms-admin/roles/{id}/edit.

Each entry describes one sidebar resource (Pages, Library, Media, Redirects, Users, …) with:

  • a stable string key used in the matrix form (perm[key][action]),
  • a human label shown in the row header,
  • a codename_prefix mapping the row to the existing rustango_role_permissions codename system (so matrix toggles read/write the same column the framework already enforces),
  • the section group used to bucket rows (Content / Media / Site / Audit / Identity / Custom),
  • the subset of crate::permissions::Action columns that apply (read-only rows like Page types and History skip Add/Edit/Delete).

Three sources contribute rows at runtime:

  1. The static built-in list (built_in_resources).
  2. Every registered crate::library::LibraryTypeHandler — each one auto-adds a library_item:<type_name> row so per-snippet CRUD is grantable independently.
  3. Every registered crate::admin::admin_page::AdminPageHandler whose permission_resource() returns Some — custom admin pages appear in the matrix without any role-editor code change.

Structs§

AdminResource
One row in the role permissions matrix.

Enums§

ResourceSection
Visual / logical grouping for the matrix rows. Rendered as the row-header band above its members.

Functions§

all_resources
Full resource list = built-ins + library-type rows + custom admin-page rows. Library-type rows let an admin grant CRUD on a specific snippet kind (e.g. Author) without granting the whole library tab. Custom-page rows surface third-party admin views.
built_in_resources
Built-in sidebar resources, in matrix display order. Library-type rows and custom-admin-page rows are appended dynamically by all_resources.
codename
Build the canonical codename for (resource, action). Always {prefix}.{action_str} — e.g. cms_page.view, cms_library_item__author.edit.
granted_actions
The actions a role currently holds on resource, given the set of granted (role_id, codename) pairs. Only the resource’s own actions are considered, in declaration order. Drives each (resource × role) cell of the tenant permission-overview matrix.
grouped
Group resources by section in display order, preserving the order resources are returned by all_resources.
membership_codenames
The membership permission codenames a page/type view-restriction can require (#members), as (codename, label) — for the restriction editor’s permission picker. Derived from the built-in Membership resources so the picker and the role matrix never drift.
parse_codename
Reverse mapping: given a codename, find the matching (key, action) pair so existing role grants can be rendered as pre-checked matrix cells. Returns None if the codename doesn’t match any registered resource (e.g. a legacy free-form codename the admin hasn’t migrated yet).