Skip to content

[DT-3584] Migrate Nexus form to Superforms with validation#3158

Open
andrewzamojc wants to merge 12 commits intomainfrom
DT-3584-nexus-form-superforms
Open

[DT-3584] Migrate Nexus form to Superforms with validation#3158
andrewzamojc wants to merge 12 commits intomainfrom
DT-3584-nexus-form-superforms

Conversation

@andrewzamojc
Copy link
Contributor

@andrewzamojc andrewzamojc commented Feb 12, 2026

Summary

Migrates the Nexus endpoint form to use Superforms with Zod validation, following the established Superforms pattern used throughout the application.

To test it yourself, run it locally and go to nexus. Try saving without filling out the form, or adding invalid data.

Before - on load before clicking submit

Screenshot 2026-02-17 at 5 01 18 PM

Before - fixing name

Screenshot 2026-02-17 at 5 02 27 PM

After

Screenshot 2026-02-17 at 4 56 11 PM

Clicked save without filling it out

Screenshot 2026-02-17 at 4 56 18 PM

invalid name

Screenshot 2026-02-17 at 4 56 37 PM

fixed it

Screenshot 2026-02-17 at 4 56 41 PM

here's the edit form, same validation but has a delete button

Screenshot 2026-02-17 at 4 57 02 PM

Changes

  • nexus-form.svelte: Refactored to use Superforms with proper validation

    • Replaced manual state management with Superforms $form, $errors, and $enhance
    • Added Zod schema validation for form fields
    • Improved error handling and user feedback
  • nexus-create-endpoint.svelte & nexus-edit-endpoint.svelte: Updated to work with new Superforms pattern

  • Page components: Updated to pass data correctly to Superforms-enabled components

Benefits

  • Type-safe validation: Zod schema ensures runtime type safety
  • Consistent UX: Matches validation patterns used in other forms (capacity, groups, auth settings)
  • Better error handling: Clearer error messages and validation feedback
  • Maintainability: Follows established Superforms factory pattern

Testing

  • Tested Nexus endpoint creation flow
  • Tested Nexus endpoint edit flow
  • Verified validation errors display correctly
  • Confirmed form submission handling works as expected

@andrewzamojc andrewzamojc requested a review from a team as a code owner February 12, 2026 19:53
@andrewzamojc andrewzamojc requested review from GiantRobots and removed request for a team February 12, 2026 19:53
@vercel
Copy link

vercel bot commented Feb 12, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
holocene Ready Ready Preview, Comment Feb 18, 2026 9:53pm

Request Review

- Replace writable store pattern with Superforms
- Add Zod schema for form validation
- Fix error display: only show after user interaction
- Remove `endpointForm` store export
- Use bind:this pattern to expose form methods
- Update parent components to use new API
- Ensure errors don't show on initial load or empty state
- Add optional chaining for formComponent in  block
- Add null checks for endpoint.id in update and delete handlers
This resolves the 'used before being assigned' error by acknowledging
that formComponent is undefined until the component mounts and bind:this executes.
- Add toNexusEndpoint() utility to convert flat form data to nested API structure
- Update create/edit pages to use transformation helper
- Standardize nameHintText prop flow: base form has default, wrappers pass through
- Remove inline transformations in favor of reusable utility

This supports the Superforms migration by providing a shared transformation
helper that both ui and cloud-ui can use to convert the new flat form structure
to the nested NexusEndpoint structure required by the API.
- Change onSubmit prop type to return Promise<void>
- Update onCreate and onUpdate wrapper callbacks to Promise<void>
- Ensures SuperForms properly awaits async operations including navigation
- Matches pattern used in other forms (projects, etc)
- Shows spinner during API call and navigation
- Better visual feedback for users
- Add tainted state tracking from SuperForms
- Button disabled when form hasn't been modified (edit forms only)
- Prevents 'Nothing to change' API error
- Matches pattern used in namespace settings forms
- Button re-enables/disables as user makes/reverts changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments