Frontend action decorators
How to add a button / action — or hook a lifecycle event — onto a stock list, related list, or
edit form without writing a full custom React remote. This is the typed frontend seam exposed by
@agilecontent/mib-modules; it is the frontend counterpart of the backend
custom-actions ([AjaxMethod]) mechanism.
Contract-level, provider-confirmed. This page documents the platform seam (the
@agilecontent/mib-modulesDecoratorstype and how the shell injects it), with the provider side read from the shell source (MibFrontEnd@master d73f51e84, cms 2.48.0). The GVPcore-decoratorsclasses are cited only as a worked example — a greenfield consumer registers its own decorators from its own federated remote.
The model — two decoupled halves
An action is two independent halves:
- Frontend half — a React component (
ElementType) registered against a stock component kind (relatedList/list/contentEdition), federated from your remote to the shell, injected through a React context, selected per page by config, and rendered by the stock component (per-row for item-actions, in the toolbar for header-actions). - Backend half — whatever the action's
onClickdoes. It is not necessarily an[AjaxMethod]handler (see the four onClick patterns).
The two halves are wired separately — the frontend registration says where the button appears; the
onClick says what it does.
The type contract {#contract}
@agilecontent/mib-modules defines a single Decorators type — the frontend seams on the three stock
component kinds:
Decorators = { relatedList: RelatedList; list: List; contentEdition: ContentEdition }
// relatedList (decorators/related-list/types.d.ts)
events?: { delete?, deleteAll?, refresh?, refreshing?, onChange?, revalidateView? }
itemActions?: { [actionKey: string]: ElementType } // per-row
headerActions?: { [actionKey: string]: ElementType } // toolbar
// list (decorators/list/types.d.ts)
selectionHeaderActions?: { [actionKey: string]: ElementType } // bulk — shown when rows are selected
itemActions?: { [actionKey: string]: ElementType } // per-row — cms-2.54.0+
headerActions?: { [actionKey: string]: ElementType } // toolbar — cms-2.54.0+
events?: { delete?, refresh?, revalidateView? } // cms-2.54.0+ (header slot: refresh, revalidateView)
// contentEdition (decorators/content-edition/types.d.ts)
headerActions?: { [actionKey: string]: ElementType } // the form/edit header
events?: { onValidateFailed?, revalidate? }
An action is always an ElementType (a React component) keyed by a string. There is no column,
cell, or field decoration here — only actions + lifecycle events. (That absence is the dividing line;
see When it does NOT apply.)
How it is wired, end to end
Registration (your remote). Build a nested map of those
ElementTypes and export it:// src/core-decorators/related-list/index.ts { headerActions: { subscriptionUsersRefresh }, itemActions: { userKickSession, userResetPin, userDisplayDevice, cdnLivesPreview /* … */ } } // src/main.tsx export const decorators = coreDecorators; // ← the action registryFederation (remote → shell). The remote publishes
decoratorsas part of its exposed module (@originjs/vite-plugin-federation,exposes: { './all': './src/main.tsx' }), with@agilecontent/mib-modulesas a shared singleton so the remote and the shell agree on theDecoratorstypes and the same stock components. The shell loads the remote and reads.decorators.Injection (shell → mib-modules), via React context. The shell wraps the app in
<ComponentsContextProvider buildDecorators=… >. Any stock component callsuseDecorators('relatedList')and gets back{ itemActions, headerActions, events }.buildDecorators?: <K extends keyof Decorators>(component: K) => Decorators[K] | undefined; useDecorators: <K extends keyof Decorators>(component: K) => Decorators[K] | undefined;Crucial:
useDecoratorsis keyed by component kind ('relatedList'), not by page — so every related list on every page receives the same registered map. Which actions actually show is decided in the next layer.Gating — shell-side key-name matching, decided by the BACKEND payload. There is no page-level filtering of the decorators map; every component of that kind evaluates the full map and each entry is switched on/off by whether the backend emitted a truthy key of the same name:
Seam Gate Source of truth relatedList.headerActionsBoolean(schema.configuration[actionKey])the component's config emitted by the BFF ( getHeaderActionsByConfig,header-actions/helpers/index.ts:6-19)relatedList.itemActionsrow.permissions[actionKey]truthyper row, from the API ( filterActionsByPermissions,item-actions/helpers/permissions.ts:4-15)list.selectionHeaderActionsBoolean(schema.configuration[actionKey])list component config list.itemActions(cms-2.54.0+)row.permissions[actionKey]truthyper row, from the API — the same gate as the related list list.headerActions(cms-2.54.0+)Boolean(schema.configuration[actionKey])list component config, including keys a ContributeSchemaoverride addscontentEdition.headerActionsBoolean(mergedConfig[actionKey])page config + form component schema.configurationmerged (mergeConfigs,content-edition/utils/index.ts:225-240)Stock
row.permissionskeys areedit/remove/preview/download/quickEdit/deleteFromBaseline, but the filter readsRecord<string, boolean|undefined>— arbitrary custom keys work if the backend emits them, and from MIB 7.0.1 a stock component does: thePermissionsmodel carries a[JsonExtensionData]bag whose entries serialize as siblings of the core keys (MibServer3 PR #1961, MEDIAIBOX-12236;MediaiBox.Cms.FrontEnd.Model/Dao/Permissions.cs). Extra structural gate: the related-list actions column only mounts whenconfiguration.deleteAllis set or some row has any truthy permission (RelatedList.tsx:411-412). On top of that, an action can still self-refine (disable per row, or bind itself to one page via a hardcoded{pageKey, templateComponentKey}+ event bus — the GVP subscription-users pattern).Render. Item-actions per row (inside the fixed actions column) · header-actions in the toolbar · selection-header-actions on row-select · contentEdition header-actions before the stock Save/Remove buttons.
The action component's contract
Every action is FC<Props>:
type Props = {
row: Record<string, unknown>; // the decorated row — item-actions only (as observed; the type doesn't enforce it for header-actions)
size?: 'small' | 'middle' | 'large';
events?: Decorators['relatedList']['events']; // list lifecycle callbacks (often unused)
};
Beyond props it pulls ambient state from shared hooks — useContentContext() → contentContext.pageIds
(the current record ids) — and UI primitives from @agilecontent/ui (useModal, Tooltip, icons).
What the onClick does — not necessarily [AjaxMethod] {#onclick-patterns}
Three patterns are observed in the reference decorators; a fourth is available but wasn't exercised:
| Pattern | What it does | Example |
|---|---|---|
GVP [AjaxMethod] handler (observed) |
GET/POST /api/v2/handler/{pageKey}/{componentKey}?__ACTION=&__PARAMETERS=&__IDs= → BFF HandlerV2Controller → the [AjaxMethod] on the backend component. (All reference actions call it via GET; the backend also supports POST.) |
the custom-actions path |
| Pure frontend (observed) | opens a drawer / modal from row data — no network call | a content-preview button |
| Event-bus signal (observed) | emitRefreshEvent(type, pageConfig) on a pub/sub bus scoped by {pageKey, templateComponentKey}; a separate component listens and emits …Completed. (The worker component that performs the work was not read — this is inferred from the emit/listen pair.) |
a "refresh" header-action decoupled from its worker |
| Direct mib-api (available, NOT observed) | could call the content API through the shared @agilecontent/mib-api-connector dep instead of a GVP handler — but no reference decorator does this; it's the natural fourth, not a verified pattern |
a content-level action |
So the button and the backend are loosely coupled: [AjaxMethod] is one option, not the definition.
The events prop — one type, DISJOINT subsets per slot
The Events type declares six optional keys, but the shell populates disjoint subsets at each
call site (RelatedList.tsx:414-441 and :558-567):
| Slot | events actually passed |
Props actually passed |
|---|---|---|
relatedList.itemActions |
{ delete(id), revalidateView() } only |
{ row, items, size, events } — schema stripped, no componentKey |
relatedList.headerActions |
{ deleteAll, refresh, refreshing, onChange } only |
{ componentKey, events } — no row |
list.selectionHeaderActions |
no events prop at all |
{ componentKey, items, setItems, refresh } |
list.itemActions (cms-2.54.0+) |
{ delete(id), refresh, revalidateView } — refresh re-fetches the rows; on a list page revalidateView reloads the page, not the table |
{ row, items, size, events } |
list.headerActions (cms-2.54.0+) |
{ refresh, revalidateView } |
{ componentKey, events } |
contentEdition.headerActions |
{ onValidateFailed, revalidate } |
{ events, form } |
So events.refresh?.() inside an item-action is a silent no-op — the per-row refresh is
events.revalidateView?.(). And refresh on the header slot is the confirm-modal-wrapped
refresh (danger-styled, RelatedList.tsx:503-532), not a silent re-fetch; refreshing is its
loading bool; onChange pushes a RelatedListValue into the page form.
There is also a second, consumer-owned coordination channel — a window CustomEvent bus (GVP
common/event-bus/refresh-event) scoped by {pageKey, templateComponentKey}, used when the trigger
(a header-action) and the worker (a useFormChange page hook that owns the antd form) are
decoupled. Don't conflate the two.
Runtime flow
page load
→ BFF GET /api/v2/display/{pageKey} (backend component MapData/MapSchema)
→ shell builds the STOCK components + their config
→ each stock component calls useDecorators(kind) (context ← federated remote.decorators)
→ selects applicable actions: config | self-bound pageConfig | row self-gate
→ renders: item-actions per row · header-actions in toolbar · selection-header-actions on select
user click
→ onClick: [AjaxMethod handler] | [mib-api] | [pure frontend] | [event-bus emit]
→ on success: events.refresh() OR emitRefreshEvent(…) → the stock list re-fetches from the BFF
The three surfaces
| Stock kind | Decorations | Used for |
|---|---|---|
relatedList |
itemActions (per-row), headerActions (toolbar), events |
related lists — the common case |
list |
itemActions (per-row) and headerActions (toolbar) from cms-2.54.0, selectionHeaderActions |
a stock list page: a row or toolbar button, bulk actions on checked rows |
contentEdition |
headerActions, events (onValidateFailed/revalidate) |
the form / edit header |
When it does NOT apply — the drop-vs-keep-custom line {#boundary}
This seam decorates actions + lifecycle events only — there is no decorator hook to inject custom
columns, cell renderers, or form fields. But a decorator is not the only middle tier: the remote also
exports useFormChange (from main.tsx) for form dynamics. So the deciding rule has three tiers, not
two:
- Needs only a button / action / lifecycle hook → decorator — drop the custom remote, keep the stock list/related/form component and register the action.
- Needs conditional field behaviour — show/hide a field, react to another field's change ("show field
Y when X") →
useFormChangehook — still no custom remote (the middle tier). See Playbook C. - Needs a custom column or cell renderer, a server-computed / per-type injected field schema (e.g. a
GetAdditionalFields-style dynamic form), a matrix, or a tree → no decorator or hook covers it → it stays a full custom remote (src/components/*, a customviewType).
Use these three tiers as the deciding rule when classifying an existing custom component as
drop / slim / keep — decorator and useFormChange both mean drop or slim, not keep.
Availability — a property of the deployed shell image
The Decorators type + useDecorators ship in @agilecontent/mib-modules (published); the
consumption code ships only inside the cms image. What renders is decided by the deployed shell
version, not by what the remote installs:
| Seam | First shell release | Commit |
|---|---|---|
relatedList.itemActions |
cms 2.6.0 (2025-08-04) |
9d9ae33db |
relatedList.headerActions |
cms 2.7.0 (2025-08-08) |
e09105a18 |
list.selectionHeaderActions |
cms-2.31.0 (2026-02-24) |
8950854c6 |
list.itemActions · list.headerActions |
cms-2.54.0 (2026-09-22) |
85eab986b |
contentEdition.headerActions |
cms-2.37.0 (2026-03-27) |
bb56bf4b6 |
⚠️ asyncRelatedList consumes NO decorators at all (zero useDecorators/ItemActions/
HeaderActions in async-related-list/, cms 2.48.0; its SelectionHeader is its own component and
its action column is hand-rolled). Turning ASYNC_MODE on silently removes every custom action
from that panel.
Caveats & grounding {#caveats}
- Provider side source-confirmed (cms 2.48.0):
bootstrapawaitsinitFederation()before the app mounts; 3 fixed slots (customComponents{,2,3}/all←CUSTOM_COMPONENTS_{,2_,3_}URLfrom runtimeconfig.json); decorators merge with a kind-level clobber (the later slot's wholerelatedListwins; onlyuseFormChangecomposes additively); remote load failure is silent; a hanging remote blocks CMS boot. See shell-architecture. - Both gates live-proven 2026-08-06 (greenfield stack,
mib-cms-frontend 7.0.0-beta8):- Header gate: an arbitrary MIB3UX config row does NOT flow —
schema.configurationis the typedRelatedListSchemaConfiguration(7 props), hand-picked mapping, everything else dropped. The extend path works: theConfigurationslot is declaredobjectand the V2 serializer resolves runtime types (DictionaryKeyPolicyunset → dict keys verbatim), so aContributeSchemaoverride that round-trips it into aDictionaryand adds the key emitted{addNew:…, exportRows:true}live. - Item gate — CLOSED on the stock BFF:
row.permissionsis the concretePermissionsclass (create/edit/remove/read/preview/download/quickEdit, no extension data;deleteFromBaselineexists only in the shell's TS type). A custom key can never appear from the stock pipeline — custom itemAction keys require a custom-tier component authoring its own payload (the GVP production pattern:CustomPermissions : PermissionReactModel { UserKickSession }), or a core change ([JsonExtensionData]onPermissions).TransformDatacan toggle the 7 stock bools per row (source-grounded; stock keys draw stock buttons too). - Two traps discovered in the proof run: config keys are case-insensitive in the BFF dictionary
— two rows differing only by case crash
MapSchemaand the component is silently dropped from the 200 render (log[Render] … MapSchema threw ArgumentException;mib client get --strictflags it). And seam-vs-image drift:TransformDatapostdates 7.0.0-beta8 — an override compiled against a newer package loads and is silently never called on an older image; seam presence is a property of the deployed image.
- Header gate: an arbitrary MIB3UX config row does NOT flow —
list/contentEditiondecorators were unused by the reference remote; the shell-side consumption is read and typed, but exercise them and confirm.- Dev mode / Storybook never render decorators (no
ComponentsContextProviderwithbuildDecoratorsin the remote's dev harness) — verify against a real shell.
Source
Consumer types: @agilecontent/mib-modules/dist/modules/decorators/{index,related-list/types,list/types, content-edition/types}.d.ts and contexts/components-context.d.ts. Provider + call sites (read from
source, cms 2.48.0): apps/cms/src/application/config/federation.ts, apps/cms/src/common/helpers/ components.ts, packages/core-components/src/components/related-list/RelatedList.tsx and its
item-actions/header-actions helpers. Reference registration:
MIBFrontEnd-GVP-components/src/core-decorators/*, src/main.tsx, vite.config.ts. Backend dispatch for
the [AjaxMethod] onClick pattern: see custom-actions.
Recipe — register an itemAction / headerAction (worked code)
The registry item recipe.frontend-decorator-action carries the full worked code: the
core-decorators registration, an item-action FC written against the real props
({row, items, size, events: {delete, revalidateView}}), a header-action FC
({componentKey, events: {deleteAll, refresh, refreshing, onChange}}), the two backend gates
(schema.configuration[actionKey] / row.permissions[actionKey]), and the verify ladder (unit-test
with a buildDecorators wrapper → npm run build && npm run preview → check the live payload for
the gate keys). Fetch it with mib get recipe.frontend-decorator-action.
Recipe — exactly one flag true across sibling rows
Enforce 'exactly one row has FLAG=true' among the children of one parent, without replacing the stock grid.