Skip to content

ref(alerts): migrate rule node fields to JsonFormAdapterFieldConfig#112779

Merged
priscilawebdev merged 10 commits intomasterfrom
priscila/ref/migrate-rule-node-fields
Apr 16, 2026
Merged

ref(alerts): migrate rule node fields to JsonFormAdapterFieldConfig#112779
priscilawebdev merged 10 commits intomasterfrom
priscila/ref/migrate-rule-node-fields

Conversation

@priscilawebdev
Copy link
Copy Markdown
Member

@priscilawebdev priscilawebdev commented Apr 13, 2026

Migrate the inline alert rule field rendering in ruleNode.tsx to use
the backendJsonFormAdapter type system and utilities.

  • Replace the loose FormField type ({type: string, [key]: any}) with
    the IssueAlertRuleFormField discriminated union from alerts.tsx
  • Add mapAlertRuleField to bridge backend field types to
    JsonFormAdapterFieldConfig
  • Consolidate ChoiceField, NumberField, TextField into a single
    InlineField component that switches on the adapter field type
  • Use transformChoices from the adapter utils
  • Add missing mailAction, assignee field types and resetsForm to
    the IssueAlertRuleFormField union
  • Add getFormFieldsRecord() helper to narrow formFields without casts
  • Simplify node prop type to IssueAlertRuleActionTemplate
  • Fix test fixture to use strings for choice values (matching the API)
  • Remove lodash/merge dependency

closes https://linear.app/getsentry/issue/DE-1053/endpoint-3-get

Replace the loose FormField type ({type: string, [key]: any})
with the existing IssueAlertRuleFormField discriminated union.
Add missing mailAction and assignee field types, resetsForm to
choice fields, and use IssueAlertRuleActionTemplate for the
node prop. Removes @ts-expect-error and lodash/merge import.
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Apr 13, 2026
Use type guard function for SchemaFormConfig narrowing
instead of as-casts. Fix prefer-optional-chain lint error.
Replace custom ChoiceField, NumberField, TextField components
with a unified InlineField that uses JsonFormAdapterFieldConfig
and transformChoices from the form adapter. Backend field configs
now go through mapAlertRuleField before rendering, aligning with
the adapter pattern used by BackendJsonSubmitForm.
@priscilawebdev
Copy link
Copy Markdown
Member Author

@cursor review

Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 3b235ae. Configure here.

Fix exampleNumberChoiceField test fixture to use strings for initial
and choices keys, matching what the backend API actually returns.
Revert initial type back to string-only. Remove redundant null checks
and type override in mapAlertRuleField.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@priscilawebdev priscilawebdev changed the title ref(alerts): type ruleNode form fields properly ref(alerts): migrate rule node fields to JsonFormAdapterFieldConfig Apr 14, 2026
The type: 'select' is needed to narrow the JsonFormAdapterFieldConfig
union when spreading adapterField. Without it TypeScript produces a
type too wide to reassign, and the select doesn't render.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@priscilawebdev priscilawebdev marked this pull request as ready for review April 14, 2026 10:18
@priscilawebdev priscilawebdev requested a review from a team as a code owner April 14, 2026 10:18
@linear-code
Copy link
Copy Markdown

linear-code bot commented Apr 14, 2026

Comment thread static/app/views/alerts/rules/issue/ruleNode.tsx
@priscilawebdev priscilawebdev requested a review from a team April 15, 2026 06:58
@sentry
Copy link
Copy Markdown
Contributor

sentry bot commented Apr 15, 2026

Sentry Snapshot Testing

Name Added Removed Modified Renamed Unchanged Status
sentry-frontend
sentry-frontend
0 0 0 0 204 ✅ Unchanged

⚙️ sentry-frontend Snapshot Settings

Comment thread static/app/views/alerts/rules/issue/ruleNode.tsx
Use string-backed issue category choices and values in the rule node tests to match the backend rule serializer contract. The production code already relies on string values for issue category filters, so the old numeric fixtures were exercising an unrealistic payload shape.

Co-Authored-By: Codex <noreply@openai.com>
@priscilawebdev priscilawebdev enabled auto-merge (squash) April 16, 2026 11:17
@priscilawebdev priscilawebdev merged commit 3b34269 into master Apr 16, 2026
65 checks passed
@priscilawebdev priscilawebdev deleted the priscila/ref/migrate-rule-node-fields branch April 16, 2026 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants