ref(forms): Migrate highlights settings#115778
Conversation
📊 Type Coverage Diff
🔍 3 new type safety issues introducedType assertions (
This is informational only and does not block the PR. |
8438cf1 to
e3f74f3
Compare
e3f74f3 to
0021112
Compare
0021112 to
ea42b1f
Compare
0bd5d8d to
26c9707
Compare
a631887 to
fb3d394
Compare
| return {}; | ||
| } | ||
|
|
||
| return JSON.parse(highlightContext) as NonNullable<DetailedProject['highlightContext']>; |
There was a problem hiding this comment.
could we re-use the schema here instead of doing another manual JSON.parse ?
There was a problem hiding this comment.
Agreed in principle ....and I tried this. To re-use the schema we need AutoSaveForm to apply the transform on submit (so mutationFn receives the parsed output instead of the raw form value). This required a lot of changes in other files (PR is updated)... What is your take on this?
753c6de to
ecc4f1f
Compare
ecc4f1f to
cc24014
Compare
bf0dbd7 to
2ac4318
Compare
2ac4318 to
249df1e
Compare
There was a problem hiding this comment.
lots of unrelated formatting changes here
There was a problem hiding this comment.
yes... I was expecting these to be auto fixed in this PR 😅
| `AutoSaveForm` keeps field state typed as the schema input, but submits the schema's parsed output to the mutation. This matches `useScrapsForm` and lets you use transforms or narrower output types without extra parsing in `mutationFn`. | ||
|
|
||
| > [!WARNING] | ||
| > The schema is applied to the form value on submit, so unknown keys are stripped per Zod's default behavior. For map-like fields with arbitrary keys, use `z.record(z.string(), …)` — not `z.object({})`, which declares zero keys and will strip everything at submit time. |
There was a problem hiding this comment.
we can also use passthrough to allow arbitrary values
There was a problem hiding this comment.
passthrough is deprecated, so I am using looseObject({}) instead 710fe6e
Restore single quotes, brace spacing, and arrow-param style to match the rest of the file; keep only the new "Transformed Submit Values" section as the intended change.
Switch the choice_mapper schema in backendJsonFormAdapter to
z.looseObject({}) so arbitrary keys pass through, matching the modern
Zod 4 idiom (replaces deprecated .passthrough()). Mention z.looseObject
alongside z.record in the AutoSaveForm doc warning.
…ings-form-migration
Replace the legacy highlights JsonForm with AutoSaveForm text areas for tags and context. This keeps the existing autosave behavior, preserves the project cache updates, and tightens the tests around the autosave requests. closes https://linear.app/getsentry/issue/DE-1251/migrate-eventshighlightshighlightssettingsformtsx-from-legacy-form
Replace the legacy highlights JsonForm with AutoSaveForm text areas for tags and context.
This keeps the existing autosave behavior, preserves the project cache updates,
and tightens the tests around the autosave requests.
closes https://linear.app/getsentry/issue/DE-1251/migrate-eventshighlightshighlightssettingsformtsx-from-legacy-form