Issue #3611735: Fix inert budget/threshold Save buttons on the dashboard
What this does
- Attaches
ai_metering/ai_metering_htmxas a dependency ofai_metering_dashboard. Without it, htmx.js was never loaded on/admin/reports/ai-metering, so the monthly budget and alert threshold Save buttons'hx-postattributes were inert — clicking Save did nothing. - Serves htmx from
cdn.jsdelivr.netinstead ofunpkg.com: sites with a strictscript-srcCSP (e.g. via seckit) commonly already allowlist jsdelivr for Chart.js, but not unpkg. - Replaces the eval-based
hx-vals='js:...'value selectors withhx-include="closest .ai-quota-editor"plusnameattributes on the inputs — a CSP withoutunsafe-evalblocks the old approach outright. - Gives the budget input its own class (
ai-budget-input, distinct from the threshold input'sai-threshold-input) so nothing relies on DOM order for correctness.
How to test
- Visit
/admin/reports/ai-metering, change an editor's monthly budget or alert threshold, and click Save. - The value persists (confirmation message appears in place of the input) without a page reload, and survives a reload.
QuotaEditorTestcovers: the htmx library loads from jsdelivr (not unpkg), the Save buttons usehx-include(nothx-vals), and both endpoints actually persist the posted value.
AI assistance
Yes.
Edited by Jérôme Tchania