Render the Brex panel through ProviderItem::PanelComponent

Merged
JA
1d ago
+575-124

Summary

Provider kit Track B, B4b: Brex's Settings > Providers panel (settings/providers/_brex_panel) renders through a shared ProviderItem::PanelComponent. The panel's HTML is unchanged, checked against snapshots of the partial taken before the change.

Part of #5003 (Track B, item 4, second of two slices: B4a card, B4b panel).

Stacked on #5232. Fork pre-flight: jaysbeekay/sure#722 (same branch, same commit; its CI, Gatekeeper review and screenshot history live there).

What changed

  • ProviderItem::PanelComponent (new): the panel's template, moved from the Brex partial. It covers the error alert, each connection with its sync, disconnect and edit form, and the add-connection form. Messages come from the provider's existing <key>_items.provider_panel.* keys (no locale changes); the panel id comes from the panel declaration's turbo_id.
  • Provider-specific parts:
    • setup steps: a setup_steps slot, which the Brex partial fills with its four steps;
    • credential fields: a partial hook, <key>_items/_credential_fields with form:, item: and editing:, rendered inside each form. This departs from the "slots" default in jaysbeekay/sure#670's plan, because a slot is filled before the component renders and cannot receive the per-form builder. brex_items/_credential_fields holds Brex's token and base URL fields, plus the sandbox note on the add form.
  • settings/providers/_brex_panel keeps its brex_items: / error_message: locals and fallbacks and renders the component.

Screenshots

Rendering unchanged: this PR moves the Brex panel onto a shared component, and the snapshot tests show the HTML matches the partial's. After only, at this PR's head: Settings > Providers, the Brex connection from the test fixtures (brex_items(:one)).

LightDark
Afterafter-lightafter-dark

Demo data

No demo data needed: no new records.

Migration notes

No migration.

Verification

  • Snapshots: three renders of the original Brex panel, recorded before the change, in test/components/provider_item/snapshots/, with the same normalisation as B4a:

    • no connections;
    • one connection;
    • a syncing connection with an error.

    ProviderItem::PanelComponentTest asserts the panel still renders each one, and that it renders through ProviderItem::PanelComponent; the latter fails without the change (uninitialized constant ProviderItem::PanelComponent).

  • Snapshot provenance (re-checked 2026-11-17): the three partial snapshot tests were run against the old _brex_panel on up/provider-kit-card, before this slice: 3 runs, 0 failures.

  • Review fix (2026-11-17): the component reads its turbo id from Provider::Factory.panel_declarations instead of Settings::ProvidersController::FAMILY_PANELS_BY_KEY.

  • Existing tests unchanged: Settings::ProvidersControllerTest and BrexItemsControllerTest (which renders the panel after create and update) pass unedited.

  • Mutations, each caught: no setup steps; the edit form given the add form's fields; the add form given the edit form's fields; the wrong panel id; no error alert; sync enabled while syncing; the add-connection heading shown with no connections.

  • bin/rails test (full, at the B4b commit): 16,294 runs, 0 failures; the same 8 ReleaseNotesWorkflowTest errors (no node in the test image).

  • bin/rubocop, erb_lint on the changed templates and bin/brakeman: no offenses or warnings.

  • Diff with copy detection (git diff -C against B4a): non-test +184 / -124.

  • Checked against upstream AGENTS.md (blob 1a5dbebd, 2026-11-17): no deviations.

Blast radius

  • render_provider_panel("brex", …) and the Settings > Providers page render settings/providers/brex_panel with the same locals and the same brex-providers-panel Turbo target.
  • Siblings: the other providers' panels keep their own partials for now.

Summary by cubic

Renders the Brex Settings > Providers panel through a new shared ProviderItem::PanelComponent, with the HTML unchanged from the old partial (pinned by snapshot tests). The component owns the error alert, each connection's sync, disconnect and edit form, and the add-connection form, using the provider's existing provider_panel locale keys and the panel id from its panel_declarations entry. Providers fill a setup_steps slot and supply credential fields as <key>_items/_credential_fields, rendered inside each form because a slot can't receive the per-form builder. The Brex partial only renders the component, keeping its locals and the brex-providers-panel Turbo target; other providers' panels stay on their own partials for now.

Summary by CodeRabbit

  • New Features
    • Added a Brex settings panel for managing provider connections, including adding, editing, syncing, and disconnecting connections.
    • Added setup instructions, credential guidance, and error alerts. Tokens are masked, and new connections include guidance on production and staging URLs.