feat(32.2-01): per-item rows and item actions on My account contributions
- pact: AccountContribution.Items/ItemActions/ItemsEmpty, AccountItem,
AccountItemAction, AccountItemActionInput, ErrAccountItemNotFound
- cabana: the list sends items (null without Items), permitted item actions
and the empty line; boot refuses item actions without Items
- cabana: POST {api}/account/contribution-items/{name}/{item}/actions/{action}
runs only for an item the administrator's own Items listed, in a transaction
(path outside /account/contributions/ to avoid a ServeMux overlap)
- swag views; admin.json and schema.d.ts regenerated; route inventories
This commit is contained in:
@@ -156,6 +156,8 @@ Every signed-in administrator can edit their own profile on the My account scree
|
||||
|
||||
- **Plugin sections:** a plugin can add its own card below the API tokens, for something only the signed-in administrator does for themselves, such as linking their site account. The plugin implements `pact.HasAccountContributions` and returns `pact.AccountContribution` entries: a name, a label and description, an optional status line computed for the administrator, and buttons (`pact.AccountAction`) with an optional confirmation (danger variant included), extra permissions and an `Applies` rule. The SPA loads them from `GET <prefix>/api/v1/account/contributions` and runs a button through `POST <prefix>/api/v1/account/contributions/{name}/actions/{action}`, which calls the action's `Run` with the signed-in administrator's id inside a transaction (`cabana.TxFromContext`) and shows the returned message; a returned URL is opened in a new tab and shown as a link. Only an absolute `http`/`https` URL or a same-origin path is passed on; the admin drops anything else. A section whose status fails to load is still listed, marked `error: true`, and My account shows it with an error line; an action whose `Applies` fails is left out and marks its section the same way, so a missing button is explained. The other sections are unaffected. Both routes refuse personal API tokens like the rest of My account, and a page without contributing plugins is unchanged.
|
||||
|
||||
A section can also list rows that belong to the signed-in administrator, such as connected agents: `pact.AccountContribution.Items` answers them (`pact.AccountItem`: an id, a title, an optional subtitle and meta lines), `pact.AccountContribution.ItemsEmpty` is the line shown when there are none, and `pact.AccountContribution.ItemActions` are the buttons of every row (`pact.AccountItemAction`; a `Confirm` text may hold `:title`, which the admin replaces with the row's title). The list carries `items` (an array, possibly empty), `item_actions` (those the administrator holds the permissions for) and `items_empty`; a section without `Items` sends `items` as null and looks as before. A row button posts to `POST <prefix>/api/v1/account/contribution-items/{name}/{item}/actions/{action}`: 404 for an unknown section or action, 403 without the action's permissions, and 404 when the section's `Items` does not list that item for the signed-in administrator, so nobody can act on another administrator's row by guessing its id. `Run` then gets the administrator's id and the item id inside a transaction; a row that is gone meanwhile answers `pact.ErrAccountItemNotFound` and the route 404.
|
||||
|
||||
Plugins that show an administrator, such as an author box, read the subtitle with `cabana.BackendUser.Subtitle` and the picture with `cabana.BackendUserAvatar`, which returns the avatar file (or nil) for an administrator id.
|
||||
|
||||
## Managing administrators
|
||||
|
||||
@@ -90,7 +90,7 @@ A WinterCMS plugin overrides `register*` methods of `PluginBase`. A SummerCMS pl
|
||||
| `pact.HasFrontendPermissions` | Frontend permission codes (`pact.FrontendPermission`) a route's permission middleware checks, offered in the user plugin's permission editors. |
|
||||
| `pact.HasAdminControllers` | Admin controllers built from `fields.yaml` and `columns.yaml`. |
|
||||
| `pact.HasAdminActionExtensions` | Record actions added to any admin controller by ID (`pact.AdminActionExtension`); a `pact.AdminRecordAction` with a `Prompt` asks the administrator for one text value first and receives it as `pact.AdminRecordActionInput.Value`. |
|
||||
| `pact.HasAccountContributions` | Sections with a status line and buttons on the administrator's My account page (`pact.AccountContribution`, `pact.AccountAction`), run for the signed-in administrator only. |
|
||||
| `pact.HasAccountContributions` | Sections with a status line and buttons on the administrator's My account page (`pact.AccountContribution`, `pact.AccountAction`), run for the signed-in administrator only. A section may also list the administrator's rows (`pact.AccountContribution.Items` answering `pact.AccountItem` values, with `pact.AccountContribution.ItemsEmpty` for none) and give each row buttons (`pact.AccountItemAction`, whose `Confirm` may hold `:title`, the row's title); a row button runs only on a row that administrator's own `Items` listed, and its `Run` answers `pact.ErrAccountItemNotFound` for a row that is gone. |
|
||||
| `pact.HasMCP` | MCP tools and prompts (`pact.MCP`, `pact.MCPTool`, `pact.MCPPrompt`) bound to the plugin's own token-guarded routes, served by the framework's opt-in [MCP endpoint](../services/mcp.md). |
|
||||
| `pact.HasModels` | The plugin's GORM models. No framework package reads it yet. |
|
||||
|
||||
|
||||
Reference in New Issue
Block a user