Render the Brex panel through ProviderItem::PanelComponent

JA
5d 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 jaysbeekay/sure#670 (Track B, item 4, second of two slices: B4a card, B4b panel). Stacked on B4a (jaysbeekay/sure#721) in fork stack #687.

Upstream draft PR: https://github.com/we-promise/sure/pull/5233 (same branch, same commit), in native stack we-promise/sure#5268 on refactor/provider-kit.

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 #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.