Skip to content

Per-event section switches - #2664

Draft
soof-golan wants to merge 8 commits into
peterdrier:mainfrom
soof-golan:section-switches
Draft

soof-golan wants to merge 8 commits into
peterdrier:mainfrom
soof-golan:section-switches

Conversation

@soof-golan

Copy link
Copy Markdown

[bot] Opened on behalf of @soof-golan (Kiez Burn e.V., which runs a fork of Humans).

What

Per-event section switches: an admin ticks sections off on the event form at /Settings#event, and while that event is active those sections are gone — their pages answer 404, their nav, tiles, cards, parts, meters, banners and helper-index entries drop out, links into them are removed from views, and their recurring jobs are paused.

Why

ISection.IsActive turns a section off per deployment, at the cost of a code change and a deploy, and it also removes the section's services. A burn that simply doesn't use a feature this year (Cantina, Rideshare, Tickets sold elsewhere) needs something an admin can flip and flip back. Kiez Burn has run this in production since November.

How it works

  • The list lives on the event row (settings_events.SwitchedOffSections, jsonb, nullable). ISectionSwitches (Base) reads it from the in-memory active event; every event-settings write flushes it. A stored name resolves through ISectionCatalog.TryResolve, so it survives a section rename.
  • What cannot be switched off: ISection.CanBeSwitchedOff (default true) is false for Auth, Users, Gdpr, Onboarding and Settings. The save refuses those and any unknown name.
  • Pages: SectionSwitchFilter, a global resource filter, answers 404 for a controller whose assembly is a switched-off section. [StaysOnWhenSectionIsOff] exempts one controller (Consent's MyDataController, a member's own data page).
  • Contributions: the composers of ISectionContribution seams drop a switched-off section's entries with SwitchedOn(HttpContext).
  • Links written in views: SectionLinkTagHelper drops <a>/<form> whose target is switched off, via SectionRoutes (derived from routed actions, so no view names a section). hide-with-links drops an enclosing element once all its links are gone; keep-text keeps a link's text.
  • Jobs: SwitchedOffSectionJobs unschedules a switched-off section's recurring jobs within a minute and reschedules them when it is back. Jobs marked [StaysOnWhenSectionIsOff] (retention, the email outbox, the legal document sync) keep running.

Docs: docs/features/global/section-activation.md ("Per-event switches"), the Settings invariants, background-jobs.md.

Existing surface checked

Reuses ISectionContribution composition, ISectionCatalog, ISection.FormerNames, the event-settings form and change listener, and the Hangfire recurring-job registration. New surface: ISectionSwitches, ISection.CanBeSwitchedOff, StaysOnWhenSectionIsOffAttribute, SectionRoutes, SectionLinkTagHelper, SectionSwitchFilter, SwitchedOffSectionJobs — each is the one place its concern lives.

Checklist

  • Review tier: tier:thorough — cross-section filtering, a global filter, a tag helper over every view, and a migration.
  • No migration edited by hand — generated with dotnet ef migrations add AddSwitchedOffSections --context SettingsDbContext. It was run with the clock set to 2026-11-20 11:54:51 (libfaketime) so its id equals the one Kiez Burn's production already recorded for the same column; the .cs is byte-identical to that one, so the fork takes this file on its next merge without re-running it.
  • No NOT NULL column added — the new column is nullable.
  • Section labeled — Settings / Admin (please add).
  • Targeting main on peterdrier/Humans, branched off it.
  • Build + test pass locally: full dotnet test Humans.slnx, plus Humans.Integration.Tests (133/133) migrating an empty database.
  • Nav coverage — no new page; the switches are on the existing event form.
  • Dates/times via NodaTime.

Reviewer notes

  • Big because it touches every composer and adds hide-with-links/keep-text to views; the logic itself sits in a handful of files.
  • Not covered, by design (listed in section-activation.md): minimal-API endpoints, URLs built in script or TableModel.Link(…) columns, help/access-matrix contributions.
  • The commits keep their history; squash is fine.

A switched-off section stays composed, so its consumers keep working, but its pages answer 404 and its nav, tiles, cards and parts are filtered out while that event is active.

(cherry picked from commit 2e2eaaf)
Links resolve to the section that serves them from the app's own routes, so a link, and a wrapper marked hide-with-links, disappears with its section.

(cherry picked from commit 7bcedab)
A host that renders views without it, like a section's view tests, has nothing switched off to resolve.

(cherry picked from commit 8c38579)
A controller marked StaysOnWhenSectionIsOff keeps answering and keeps its links.

(cherry picked from commit a3af3e4)
…ms, the helper and click-throughs

(cherry picked from commit e160735)
Retention, the email outbox and the legal document sync stay on.

(cherry picked from commit 27cb0d7)
EF generates the migration after RenameTablesToSectionPrefix, so it adds the
column to settings_events. SectionSwitches reads the in-memory active event,
and the test names follow HUM0043.
@github-actions github-actions Bot added the db PR includes EF Core migration label Nov 27, 2026
@github-actions

Copy link
Copy Markdown

This PR has a merge conflict with main. Merge origin/main into the branch and resolve the conflicts. The merge-conflict label comes off automatically once it merges cleanly.

@peterdrier peterdrier mentioned this pull request Nov 28, 2026
2 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

db PR includes EF Core migration merge-conflict

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant