Skip to content

ref(plugins): migrate plugin config to BackendJsonSubmitForm#112340

Merged
priscilawebdev merged 23 commits intomasterfrom
priscila/ref/plugin-config-to-backend-form-adapter
Apr 14, 2026
Merged

ref(plugins): migrate plugin config to BackendJsonSubmitForm#112340
priscilawebdev merged 23 commits intomasterfrom
priscila/ref/plugin-config-to-backend-form-adapter

Conversation

@priscilawebdev
Copy link
Copy Markdown
Member

@priscilawebdev priscilawebdev commented Apr 7, 2026

Migrate the project-level plugin configuration forms from the legacy
PluginSettings class component + GenericField rendering to the new
BackendJsonSubmitForm adapter.

PluginConfig now fetches field definitions directly via useApiQuery
from GET /projects/{org}/{project}/plugins/{id}/ and maps the backend
field types (boolboolean, readonlydisabled, etc.) to the
JsonFormAdapterFieldConfig shape. This removes the dependency on the
client-side plugin module system (plugins.get(plugin).renderSettings())
for rendering settings.

I considered preserving some plugin-specific legacy UX in the migrated
forms. Jira previously used a multi-step settings flow and SessionStack
used a collapsible advanced section. I did not carry those behaviors
forward here; the migrated form is intentionally flat because restoring
that legacy custom UI did not seem worth the extra complexity for these
hidden/deprecated plugin settings.

closes https://linear.app/getsentry/issue/DE-1054/endpoint-4-get-api0organizationsorgpluginsconfigs

@linear-code
Copy link
Copy Markdown

linear-code bot commented Apr 7, 2026

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Apr 7, 2026
Base automatically changed from tkdodo/ref/de-1052-externalissues-to-backendformadapter to master April 9, 2026 09:10
Replace the legacy PluginSettings class component and GenericField
rendering with BackendJsonSubmitForm for plugin configuration forms.

The plugin config now fetches field definitions via useApiQuery and
maps backend field types to the new form adapter, eliminating the
dependency on the client-side plugin module system for settings.

Refs DE-1054
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@priscilawebdev priscilawebdev force-pushed the priscila/ref/plugin-config-to-backend-form-adapter branch from eec026a to b11e9c3 Compare April 13, 2026 06:28
Remove blanket `as JsonFormAdapterFieldConfig` casts by pulling default
out of the base object so TypeScript can narrow each union member.
Drop useMemo/useRef in favor of direct derivation from pluginData,
use fetchMutation generic instead of cast, and inline one-liner handler.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add a settings-style footer action row with a top divider for the migrated plugin configuration form, and provide a fallback placeholder for secret fields when the backend does not send one.

This keeps the migrated UI usable while preserving the existing backend-driven form flow.

Co-Authored-By: Codex <noreply@openai.com>
Improve migrated plugin configuration UX by restoring single-select clearability, normalizing legacy empty select options into placeholders, and refreshing plugin data after reset so stale values are not shown.

Also simplify plugin config typing around nullable backend fields and enabled state fallback.

Co-Authored-By: Codex <noreply@openai.com>
Replace type assertions in plugin config field mapping with runtime narrowing helpers, and parse test-plugin response detail with a runtime guard instead of a typed fetchMutation cast.

This keeps mapper behavior explicit for nullable/unknown backend values and avoids unsafe assumptions about response shape.

Co-Authored-By: Codex <noreply@openai.com>
priscilawebdev and others added 2 commits April 13, 2026 10:31
Add a singleSelectClearable switch to BackendJsonSubmitForm and enable it only for PluginConfig so legacy plugin repo fields can be cleared without changing other adapter consumers.

Also keep plugin config runtime narrowing and placeholder handling improvements.

Co-Authored-By: Codex <noreply@openai.com>
Add a short inline comment explaining that reset refetches both plugin list and plugin details to keep toggle state and config values synchronized.

Co-Authored-By: Codex <noreply@openai.com>
@priscilawebdev priscilawebdev marked this pull request as ready for review April 13, 2026 08:55
@priscilawebdev priscilawebdev requested a review from a team as a code owner April 13, 2026 08:55
Avoid seeding plugin config initial values with empty strings when the backend has no saved value. This lets the form adapter fall back to field-specific defaults so booleans submit false and single selects submit null instead of empty strings.

Inline the select change handlers in the backend form adapter now that the clearable branches are typed explicitly.

Refs DE-1054
Co-Authored-By: OpenAI Codex <noreply@openai.com>
Treat null in initialValues as an intentional override instead of falling through to a field default. This keeps cleared select fields empty even when the backend field declares a default option.

Add a regression test covering the submit path for a clearable select with a null initial value.

Co-Authored-By: Codex <codex@openai.com>
Backend returns null (Python None) for unconfigured fields.
Previously null bypassed typed defaults in computeDefaultValues,
causing booleans to submit null instead of false.
Truthiness check treated false and 0 as unconfigured,
causing duplicate analytics events on subsequent saves.
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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6e3b834. Configure here.

getDetailMessage now JSON-stringifies array and object detail values
instead of silently dropping them. Also removes the redundant
JSON.stringify at the call site that was double-quoting string details.

Co-Authored-By: Claude Opus 4.6 <noreply@example.com>
Copy link
Copy Markdown
Collaborator

@TkDodo TkDodo left a comment

Choose a reason for hiding this comment

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

looks good 🙌

Replace the form-level isClearable prop with per-field logic: optional
select fields are clearable, required ones are not. This is a cleaner
API since clearability is inherently tied to whether a field is required.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace manual fetchMutation + useState with useMutation hook. This
eliminates the separate testResults state by using mutation.data
directly. Also type the response and simplify getDetailMessage.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The type is already inferred from fetchMutation's return type.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace manual fetchMutation + try/catch with useMutation hook for
the plugin config save request, consistent with the test mutation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
These attributes are not referenced in any test, backend code, or
stylesheet. Remove dead code from both Panel elements.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@TkDodo TkDodo left a comment

Choose a reason for hiding this comment

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

great work 🙌

@priscilawebdev priscilawebdev merged commit 63aa643 into master Apr 14, 2026
62 checks passed
@priscilawebdev priscilawebdev deleted the priscila/ref/plugin-config-to-backend-form-adapter branch April 14, 2026 12:08
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