feat(admin): make application Active + Maintenance toggle switches, not text (BUNYIP-420) #416

Merged
longjacksonle merged 1 commit from feat/BUNYIP-420-app-toggle-switches into main 2026-07-30 05:30:51 +02:00

What

Closes BUNYIP-420. The applications list rendered Active / Maintenance as a text value ("Active: on") plus a separate "Toggle" button. They are now proper toggle switches: color + knob position show the state, and a single click applies it.

How

  • New toggle_switch(on, label) helper in views/ui.rs: a form-submit button styled as a switch (primary track + sliding knob when on, muted when off), with role="switch" + aria-checked + aria-label (state is conveyed by color/position, not text).
  • Each switch is its form's submit control, so it posts the flipped value through the same /admin/applications/{id}/field path - no handler change. Maintenance mode still takes effect.
  • The maintenance message field (Edit page) is unchanged.

Tests

toggle_switch_reflects_on_and_off_state - on -> bg-primary + knob-right + aria-checked="true"; off -> muted + knob-left + aria-checked="false"; asserts it is a submit control. just check-container green.

Verification (screenshot shared in-thread)

  • Applications list renders switches for both controls, with correct on/off colors (Active off on Vervain Agent; Maintenance on for one app).
  • Toggling via the switch persists: a click flips maintenance_mode in the DB and redirects back (303) through the unchanged /field handler.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LerAorB26HGHLfjC9iDUbd

## What Closes BUNYIP-420. The applications list rendered Active / Maintenance as a text value ("Active: on") plus a separate "Toggle" button. They are now proper toggle switches: color + knob position show the state, and a single click applies it. ## How - New `toggle_switch(on, label)` helper in `views/ui.rs`: a form-submit button styled as a switch (primary track + sliding knob when on, muted when off), with `role="switch"` + `aria-checked` + `aria-label` (state is conveyed by color/position, not text). - Each switch is its form's submit control, so it posts the flipped value through the **same** `/admin/applications/{id}/field` path - no handler change. Maintenance mode still takes effect. - The maintenance message field (Edit page) is unchanged. ## Tests `toggle_switch_reflects_on_and_off_state` - on -> `bg-primary` + knob-right + `aria-checked="true"`; off -> muted + knob-left + `aria-checked="false"`; asserts it is a submit control. `just check-container` green. ## Verification (screenshot shared in-thread) - Applications list renders switches for both controls, with correct on/off colors (Active off on Vervain Agent; Maintenance on for one app). - Toggling via the switch persists: a click flips `maintenance_mode` in the DB and redirects back (303) through the unchanged `/field` handler. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01LerAorB26HGHLfjC9iDUbd
feat(admin): make application Active + Maintenance toggle switches, not text (BUNYIP-420)
All checks were successful
E2E / Playwright against deployment (pull_request) Successful in 1m32s
Check / fmt + clippy + build + tests (pull_request) Successful in 8m15s
Create release / Create release from merged PR (pull_request) Has been skipped
63015f442e
The applications list rendered each Active / Maintenance control as a text value ("Active: on") plus a separate "Toggle" button, so the state was not obvious and changing it was not a single click.

Adds a reusable toggle_switch helper in views/ui.rs: a form-submit button styled as a switch (colored track + sliding knob) with role="switch" + aria-checked + aria-label, so state is conveyed by color/position and a single click applies it. The switch is the form's submit control, so it posts the flipped value through the SAME /admin/applications/{id}/field path - no handler change, and maintenance mode still takes effect (verified: toggling flips maintenance_mode in the DB and redirects back). The maintenance message field on the Edit page is unchanged.

Tests: toggle_switch_reflects_on_and_off_state (on -> bg-primary + knob-right + aria-checked=true; off -> muted + knob-left + aria-checked=false; is a submit control). just check-container green. Verified rendered on the applications list (on/off states for both Active and Maintenance) at 1440px.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LerAorB26HGHLfjC9iDUbd
longjacksonle scheduled this pull request to auto merge when all checks succeed 2026-07-30 05:23:14 +02:00
longjacksonle deleted branch feat/BUNYIP-420-app-toggle-switches 2026-07-30 05:30:51 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/bunyip!416
No description provided.