Skip to content

Conversation

@rossnelson
Copy link
Collaborator

@rossnelson rossnelson commented Jun 30, 2025

Description & motivation 💭

Creates a reusable codec server configuration form following the established patterns from search-attributes-form. The implementation emphasizes component abstraction to reduce code duplication while maintaining clean separation of concerns.

Key architectural decisions include using the SuperForms + reactive adapter pattern for flexible data integration, extracting common form components (Message and TaintedBadge) to eliminate duplication between forms, and implementing smart section visibility where the custom error section automatically shows when values are populated.

The form integrates comprehensive i18n support with proper translation templating for HTML links, uses Zod schema validation for URL requirements and type safety, and includes tainted state tracking with visual feedback through badge indicators.

Screenshots (if applicable) 📸

Empty Prefilled
CleanShot 2025-07-01 at 12 59 47 CleanShot 2025-07-01 at 12 59 50

Storybook stories available at Forms/Codec Server Form showing:

  • Empty form state with endpoint input and toggles
  • Prefilled form with custom error section expanded
  • Loading skeleton states

Storybook Links

Design Considerations 🎨

  • Uses toggle switches instead of checkboxes for better UX
  • Smart visibility for custom error section (shows when values populated)
  • Matches existing search attributes form patterns and styling
  • Tainted state badge on save button shows change count

Testing 🧪

How was this tested 👻

  • Manual testing
  • E2E tests added
  • Unit tests added

Manual Testing Steps

  • Tested form validation for required URL endpoints
  • Verified toggle switches work correctly
  • Confirmed custom section expand/collapse behavior
  • Validated tainted state tracking and badge display
  • Tested skeleton loading states
  • Verified Storybook stories render properly

Steps for others to test: 🚶🏽‍♂️🚶🏽‍♀️

  1. View Storybook: Forms/Codec Server Form
  2. Test different form states (Default, Prefilled)
  3. Validate URL requirements in endpoint field
  4. Toggle access token and CORS credentials switches
  5. Expand custom section and test remove functionality
  6. Verify save button badge shows when form is modified

Checklists

Draft Checklist

  • Component implementation complete
  • Storybook stories created
  • Documentation written
  • Linting and type checking passing

Merge Checklist

  • Supports custom error messaging and redirect links for codec failures
  • Integrates with existing settings API for persistence
  • Maintains form state with proper validation and error handling

Issue(s) closed

DT-3070

Docs

Any docs updates needed?

Component includes comprehensive MDX documentation in Storybook with usage examples and API reference.

@vercel
Copy link

vercel bot commented Jun 30, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
holocene ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 21, 2025 5:24pm

Copy link
Contributor

@andrewzamojc andrewzamojc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool stuff with Superforms and zod. I like the adapter pattern. Code looks good! The one blocking question I have is around the use of switches, after which I'll put an approval.


<!-- Toggle Switches -->
<div class="space-y-3">
<ToggleSwitch
Copy link
Contributor

@andrewzamojc andrewzamojc Jul 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible change: How do you feel about switches here? I'm under the impression that checkboxes are better on forms that use a submit button. The switch metaphor is intended to be "live" like a light switch, and should make a result immediately (e.g. turn dark mode on/off).

I found random article about it, but happy to hear more from you if you really prefer switches here. https://blog.uxtweak.com/checkbox-vs-toggle-switch/

Copy link
Collaborator Author

@rossnelson rossnelson Jul 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switches are pretty, but I don't mind either way. I think we could bring it up with design.

const adapter = createCodecAdapter();
</script>
<CodecServerForm {adapter} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment: This seems nice. The fetching is captured and reusable, while the form is purer. I like the separation.

PUT /api/v1/settings/codec
```

The codec adapter handles the transformation between the form data structure and the API format, ensuring compatibility with both current and future endpoints.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment: This doc was really helpful! I dig it.

Copy link
Contributor

@andrewzamojc andrewzamojc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. We can take the switch/checkbox conversation out of the way of this PR. Cool forms! 👍

@laurakwhit laurakwhit self-requested a review July 9, 2025 23:40
Implement codec server configuration form using search-attributes-form as template:

- Form fields: endpoint URL, access token toggle, CORS credentials toggle
- Expandable custom error message and redirect link section
- Smart visibility logic for custom fields when values are populated
- Zod validation for required URL endpoints and optional custom links
- Toggle switches for better UX instead of checkboxes
- Tainted state tracking with badge on save button
- SuperForms integration with dataType: 'json' and resetForm: false
- Skeleton loading states matching existing patterns
- API integration with codec adapter for OSS endpoints
- Storybook documentation and examples
- Direct imports (no barrel exports) for better tree shaking
- Svelte 5 state management instead of legacy stores
- Use fetchSettings() from settings-service instead of direct API calls
- Properly integrate with existing Settings type structure
- Follow same pattern as other codec functionality in codebase
- Clear messaging about development limitations vs actual functionality
- Remove namespace parameter from createCodecAdapter() for OSS
- OSS operates at cluster level, Cloud will be namespace-scoped
- Update messaging and documentation to reflect cluster-level scope
- Prepare for future Cloud adapter implementation
Create FormMessage component to handle both form validation errors and status messages. Abstract TaintedBadge logic from duplicated implementations in both forms.
- Move form components to /form/ directory and rename for better organization
- Make TaintedBadge and Message components "dumb" - accept resolved values instead of stores
- Add comprehensive i18n translations for codec server form
- Fix search attributes form reset function error
- Clean up component interfaces with better prop naming (message -> value, formErrors -> errors)
- Extract tainted count calculation to derived variables in parent components
- Add proper TypeScript types for Alert intent
…ating

- Replace custom HTML link with Holocene Link component for better consistency
- Split endpoint description into prefix/suffix pattern for cleaner templating
- Remove manual styling in favor of component defaults
- Follow cloud-ui patterns for codec server endpoint links
Move retry state and logic from callers into ApiError component itself.
Components now pass retryConfig with retryFn instead of managing
retry state externally.

- Add internal retry state (retryCount, isRetrying)
- Replace onRetry callback with retryConfig interface
- Add loading state during retry operations
- Simplify caller interface to config-based approach
@rossnelson rossnelson merged commit 7524f46 into main Jul 21, 2025
16 checks passed
@rossnelson rossnelson deleted the codec-server-form branch July 21, 2025 17:55
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.

3 participants