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
keyused in the matrix form (perm[key][action]), - a human
labelshown in the row header, - a
codename_prefixmapping the row to the existingrustango_role_permissionscodename system (so matrix toggles read/write the same column the framework already enforces), - the
sectiongroup used to bucket rows (Content / Media / Site / Audit / Identity / Custom), - the subset of
crate::permissions::Actioncolumns that apply (read-only rows like Page types and History skip Add/Edit/Delete).
Three sources contribute rows at runtime:
- The static built-in list (
built_in_resources). - Every registered
crate::library::LibraryTypeHandler— each one auto-adds alibrary_item:<type_name>row so per-snippet CRUD is grantable independently. - Every registered
crate::admin::admin_page::AdminPageHandlerwhosepermission_resource()returnsSome— custom admin pages appear in the matrix without any role-editor code change.
Structs§
- Admin
Resource - One row in the role permissions matrix.
Enums§
- Resource
Section - 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 ownactionsare 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. ReturnsNoneif the codename doesn’t match any registered resource (e.g. a legacy free-form codename the admin hasn’t migrated yet).