feat: Workbench Phase 1 — gate admin page, count/transfer forms, datalists, filter, honest errors - #1
Merged
Merged
Conversation
…talists, filter, honest errors Now that core can gate a plugin admin page on the plugin's own capability (ADR 0020), the Inventory page and all four form actions require `nimbuscms.inventory:write` — parity with the MCP tools, so a content-only editor can no longer move stock from the UI. - Count + Transfer forms (Ledger::count/transfer already existed; only the UI and the H3 actions were missing). - SKU + location <datalist> suggestions sourced from this plugin's own tables (a typo-guard; a genuinely new SKU can still be typed — Inventory owns no catalog). - A bound SKU substring filter (?q=) on the stock table — no string-built SQL, the term echoed back escaped (no reflected XSS). - Honest notices: InvalidArgumentException -> "badqty", InsufficientStock -> "short", same-location transfer -> "samelocation", instead of collapsing every failure into one generic message. Tests: InventoryAdminTest (render — datalists, filter narrowing, term escaping/SQLi-safety, notice mapping) and InventoryAdminActionsTest (the H3 actions through the real loader — proving the page gates on the plugin cap and each action maps failures honestly). 43 tests green; PHPStan + php-cs-fixer clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of the Inventory/Commerce Phase 1 "Workbench" slice (from Fable's Stocked & Shipped design). Depends on core ADR 0020 (NimbusCMS/nimbus#195, merged): a plugin admin page can now gate on the plugin's own capability.
What
nimbuscms.inventory:write— the same wildcard-immune capability the MCP tools gate on. A content-only editor can no longer receive/adjust/count/transfer stock from the admin UI. (Closes the High from the pre-build security review.)Ledger::count/transferalready existed and were agent-drivable; the UI and H3 actions were missing. Now present.<datalist>suggestions sourced from this plugin's own tables. Suggestions only — a genuinely new SKU can still be typed (Inventory deliberately owns no catalog), so first-receipt still works.?q=SKU substring filter (no string-built SQL; the term is echoed back escaped — no reflected XSS).InvalidArgumentException → badqty,InsufficientStock → short, same-location transfer →samelocation, instead of collapsing every\Throwableinto one generic "check the SKU" notice.Tests
InventoryAdminTest— rendering: datalists list known SKUs/locations, the filter narrows the stock table, a hostile filter term is bound + escaped (SQLi/XSS regression), notice codes map (unknown → no banner).InventoryAdminActionsTest— the four H3 actions through the realPluginLoader(which also proves the page gates on the plugin capability — registration would throw on a pre-0020 core) with happy + honest-error paths and stock landing correctly.43 tests green; PHPStan + php-cs-fixer clean. Reviewed pre-build by
nimbus-review-loop(classified Official plugin) andnimbus-security-review.🤖 Generated with Claude Code