feat(ui): migrate delete/leave-org sections to state machines#8948
feat(ui): migrate delete/leave-org sections to state machines#8948alexcarpenter wants to merge 2 commits into
Conversation
🦋 Changeset detectedLatest commit: 531fbbe The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository YAML (base), Repository UI (inherited) Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
Replaces the useState(open) + useState(isDeleting) pairs in DeleteOrganization and LeaveOrganization with machine definitions. Each section gets a co-located *-machine.ts that declares its three states (idle → confirming → deleting/leaving) and the four events that drive them (OPEN, CANCEL, CONFIRM, done/error). The .tsx files shrink to a single useMachine call; impossible state combinations (open while not confirming, deleting without confirming) become unrepresentable.
Adds optional error?: string | null to DestructiveProps so section machines can surface async failure messages inside the confirm dialog.
577b67e to
531fbbe
Compare
Summary
Replaces
useStateboolean pairs inDeleteOrganizationandLeaveOrganizationwith co-located machine definitions, demonstrating the simplest machine pattern.Each section gets a
*-machine.tswith three states and four events:Before: two
useStatebooleans, event handlers with manual flag resets, impossible states representable (isDeleting && !open).After:
useMachine(machine, { context: { destroyFn } })— impossible combinations unrepresentable by construction.Stack
feat/mosaic-machine-core— core library ✅feat/mosaic-machine-signin— sign-in flow machines + adoption guideTest plan
turbo test --filter @clerk/uipasses