Skip to content

feat(portal): deactivation and reactivation with the user's patches, in one transaction #257

Closed

Description

@allisonmahmood

Part of #247. Implements spec §10; decision Admin authority, drawn on the page mocks.

What to build

  • The pick page GET /company/users/:id/deactivate in packages/portal (admins; the last-active-admin rule refuses at the top as today): the user's live patches, each with a checkbox and a static badge listing its live dependants (patch and owner; the user's own marked "theirs"); retired and deleted patches shown, not selectable; three submits: Keep their patches live (the leave-them-all choice: deactivates at once), Retire selected, Retire all; Retire selected with nothing checked stays on the page with "Select at least one, or keep their patches live." (422). A user with no live patches goes straight to the confirmation.
  • The confirmation (POST with the selection, re-rendered): recomputed for the exact selection; every live dependant not itself in the selection, whichever owner it has, or "Nothing breaks"; the acknowledgement when anything breaks; confirm commits the deactivation and every selected retire (ordinary retires, actor the admin) in one transaction, or nothing: Users.deactivate and Users.reactivate take an optional outer transaction and open their own only when none is given (the portal always passes one), and the last-active-admin rule runs on GET and POST.
  • Reactivation mirrors it: GET/POST /company/users/:id/reactivate with the user's retired patches, however retired; Keep them retired, Restore selected, Restore all; the comes-back-broken warning per patch whose current version's sources are off, where a source that is live or in the same selection counts as intact; one transaction with Users.reactivate.
  • /company's Deactivate and Reactivate buttons become links to these pages; Companies' one-click POST /company/users/:id/deactivate and /reactivate routes move to the portal. Bulk retire and restore exist only here.

Admitted at merge

The whole admin governance of §4 and §10 is in the portal.

Done when

  • Tested: the badges; the confirmation recomputed for three selections (nothing selected, a chain inside the selection showing no breakage, a dependant outside it showing breakage); the transaction committing deactivation and retires together, and rolling both back when one retire fails (alternate layer); the no-live-patches shortcut; reactivation's warning; the last-active-admin refusal; /company's links.

Surfaces

Served pages (ui-consistency), reverse states (reactivation mirrors deactivation; a retired patch is restorable from its card too), the Companies glossary (Deactivation, Reactivation gain the pick), the Portal glossary (Pick page from decided to built), docs/product.md § Ownership and deactivation from decided to built, CONTEXT-MAP.md's Companies line.

Activity

  1. added
    ready-for-agent
    on Sep 14, 2026
  2. allisonmahmood commented on Sep 15, 2026

    @allisonmahmood
    OwnerAuthor

    §10's "optional outer transaction" is satisfied by Effect's ambient sql.withTransaction nesting: Users and Patches join the portal's transaction through savepoints, commit or roll back together, and Users opens its own transaction when called outside one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions