Restore the publicly-searchable toggle on the election settings page - #1490
Restore the publicly-searchable toggle on the election settings page#1490jacksonloper wants to merge 1 commit into
Conversation
The is_public checkbox was dropped in 5808a62, which converted the settings page from checkboxes to switches but didn't carry this one over. That branch was authored before 4b4aec3 (which had just fixed the checkbox to write election.is_public instead of the nonexistent election.settings.is_public) and landed on top of it, so both the fix and the setting disappeared in one merge. Everything below the UI still worked: is_public is still a column, electionValidation still checks it, getOpenElections still filters on it, and the label/tip strings were still in en.yaml. But the only remaining writer was Wizard.tsx hardcoding false, so no election created since that merge could ever appear on /browse. Restored as a SwitchSetting rather than an ElectionSwitchSetting since is_public sits on the election, not in election.settings. It's disabled with an explanation on voter-list elections, where getOpenElections' voter_access == 'open' filter would suppress the listing anyway. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
✅ Deploy Preview for bettervoting ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughSummary by CodeRabbit
WalkthroughElection settings now manage the top-level Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
What happened
The "Make {{election}} Publicly Searchable" (
is_public) setting silently disappeared from the admin settings page. Two branches collided:4b4aec34(Apr 28) — "fix make election publically searchable toggle". The checkbox had been writing toelection.settings.is_public, but the field actually lives at the top level ofElection. That commit added separateeditedIsPublicstate wired toelection.is_public.5808a623(authored Mar 31, merged later) — the checkbox→SwitchSettingrefactor. It convertedrandom_candidate_order,ballot_updates,require_instruction_confirmation,draggable_ballot, andmax_rankingsinto switches, but<CheckboxSetting setting='is_public'/>was deleted and never carried over.Because the refactor branch was authored before the fix but landed on top of it, both the fix and the setting went away in one merge. Nothing in that diff suggests it was intentional — the other four toggles all survived.
Impact
Everything below the UI still worked:
packages/shared/src/domain_model/Election.ts:27—is_public?: boolean, still validated at:148packages/backend/src/Models/Elections.ts:103—getOpenElectionsstill filters.where("is_public", "=", true)packages/frontend/src/i18n/en.yaml— the label and tip text were still there, orphaned…but the only remaining writer in the frontend was
Wizard.tsx:33hardcodingis_public: false. So no election created since that merge could ever appear on/browse— the browse tab has only been showing elections whose flag was set before the regression.The change
Restored the setting on
/admin/settings, next to the other toggles.It uses a bare
SwitchSetting+useOptimisticTogglerather than theElectionSwitchSettinghelper, because that helper writes intoelection.settings[key]andis_publicis a top-level column — same reason thepublic_resultsswitch is hand-rolled.One addition beyond a straight revert: the switch is disabled with an explanation on voter-list elections.
getOpenElectionsalso filters onsettings.voter_access == 'open', so on a closed election turningis_publicon would have no visible effect. New stringdisabled_msgs.is_public_when_voter_list.Verification
tsc --noEmiton the frontend: cleaneslinton the changed component: cleanen.yamlparsesNot covered: there's no existing E2E coverage of the settings page (
testing/tests/has no/admin/settingsspec), and adding one needs the full docker stack to run against, so I didn't add a regression test here. Worth a follow-up — a switch-level assertion on that page would have caught this.Related loose end (not fixed here)
en.yaml:923public_description— "{{capital_election}} will be open to anyone via the 'Browse Polls' page" — is now unreferenced anywhere in the frontend. It was attached to the wizard's old "public" voter-access preset, which the auth-modes refactor (7d43150b) removed. Worth deciding whether the creation wizard should offer public listing up front, rather than only via settings after the fact.🤖 Generated with Claude Code