Skip to content

ref: convert SentryAppExternalForm to FC#113885

Closed
priscilawebdev wants to merge 8 commits into
masterfrom
priscila/ref/sentry-app-external-form-fc
Closed

ref: convert SentryAppExternalForm to FC#113885
priscilawebdev wants to merge 8 commits into
masterfrom
priscila/ref/sentry-app-external-form-fc

Conversation

@priscilawebdev
Copy link
Copy Markdown
Member

@priscilawebdev priscilawebdev commented Apr 24, 2026

Converting to FC here, so it will be easier to review the migration to the BackendJson

Convert the class component to a functional component using hooks, and
switch from a default export wrapped in withApi to a named export using
useApi internally. Update the two importers to use the named export.

Behavior is preserved: state reset is still triggered only on action
changes (mirroring the original componentDidUpdate), the FormModel
instance persists via useRef, and the debounced option loader is kept
stable across renders via useMemo.
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Apr 24, 2026
Drop the useCallback for onSubmitError since it's only passed to Form
and has no stability requirement. Hoist getElementText out of the
component as a module-level function with early returns — it doesn't
close over any state, so it has no business being a hook.
Helpers that are only called from renderField (getDefaultOptions,
getOptions, createPreserveOptionFunction) are not deps of any hook,
so useCallback was paying its own overhead for no benefit. Convert
them to plain arrow consts.

Also drop the rest-spread pass-through wrapping onSubmitSuccess and
return null instead of '' from the empty-installation guard.
getDefaultOptions only closes over resetValues and is a pure mapping
from (field, settings) to options — hoist it to module scope so it
stops capturing props.

createPreserveOptionFunction had exactly one call site, so inline the
handler directly into the onChangeOption prop.
Cover the component's own contract: empty-uuid render guard, field
rendering from config, successful issue-link POST, alert-rule-action
submit shape (settings array + hasSchemaFormConfig), validation gate
before alert-rule-action submit, depends_on load gating, reset-value
label preservation, and reset-on-action-prop-change.
Replace the weak waitFor(not.toHaveBeenCalled()) / waitFor(toHaveBeenCalled())
pair with a synchronous pre-assertion and an exact count check after
typing. Locks in the current per-keystroke reload behavior (6 chars =
6 external calls) so any future debouncing or batching is an explicit,
reviewable change.
Every other test in this spec interacts with config fields (type into
them, click them, read their values), so a broken render loop would
already fail them with clearer errors. The consumer spec in
sentryAppRuleModal.spec.tsx also covers the same smoke path.
Annotating baseProps with ComponentProps<typeof SentryAppExternalForm>
narrows the literal strings against the Props type, so the `as const`
sprinkles on `action` and `element` become unnecessary.
@priscilawebdev
Copy link
Copy Markdown
Member Author

bugbot run

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 9924ddc. Configure here.

@priscilawebdev priscilawebdev marked this pull request as ready for review April 24, 2026 09:14
@priscilawebdev priscilawebdev requested review from a team as code owners April 24, 2026 09:14
@priscilawebdev
Copy link
Copy Markdown
Member Author

Closing — the FC conversion didn't end up simplifying the migration review. Focusing on #112911 instead.

@github-actions github-actions Bot locked and limited conversation to collaborators May 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant