[DT-3584] Migrate Nexus form to Superforms with validation#3158
Open
andrewzamojc wants to merge 12 commits intomainfrom
Open
[DT-3584] Migrate Nexus form to Superforms with validation#3158andrewzamojc wants to merge 12 commits intomainfrom
andrewzamojc wants to merge 12 commits intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- 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.
d6cb621 to
f7d61ff
Compare
- 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Before - fixing name
After
Clicked save without filling it out
invalid name
fixed it
here's the edit form, same validation but has a delete button
Changes
nexus-form.svelte: Refactored to use Superforms with proper validation
$form,$errors, and$enhancenexus-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
Testing