Issue #3611735: Fix inert budget/threshold Save buttons on the dashboard

What this does

  • Attaches ai_metering/ai_metering_htmx as a dependency of ai_metering_dashboard. Without it, htmx.js was never loaded on /admin/reports/ai-metering, so the monthly budget and alert threshold Save buttons' hx-post attributes were inert — clicking Save did nothing.
  • Serves htmx from cdn.jsdelivr.net instead of unpkg.com: sites with a strict script-src CSP (e.g. via seckit) commonly already allowlist jsdelivr for Chart.js, but not unpkg.
  • Replaces the eval-based hx-vals='js:...' value selectors with hx-include="closest .ai-quota-editor" plus name attributes on the inputs — a CSP without unsafe-eval blocks the old approach outright.
  • Gives the budget input its own class (ai-budget-input, distinct from the threshold input's ai-threshold-input) so nothing relies on DOM order for correctness.

How to test

  1. Visit /admin/reports/ai-metering, change an editor's monthly budget or alert threshold, and click Save.
  2. The value persists (confirmation message appears in place of the input) without a page reload, and survives a reload.
  3. QuotaEditorTest covers: the htmx library loads from jsdelivr (not unpkg), the Save buttons use hx-include (not hx-vals), and both endpoints actually persist the posted value.

AI assistance

Yes.

Edited by Jérôme Tchania

Merge request reports

Loading