Render Brex's selection and error dialogs through shared components
Summary
Provider kit Track B, B5a: Brex's account-selection dialogs and its two error dialogs render through shared components. select_accounts and select_existing_account share one ProviderItem::AccountSelectionComponent; _api_error and _setup_required become ProviderItem::ApiErrorComponent and ProviderItem::SetupRequiredComponent. The move itself leaves the HTML unchanged, checked against snapshots taken before the change. A separate commit then switches the dialogs' hand-built alert and Cancel link to DS primitives (see Screenshots).
Part of jaysbeekay/sure#670 (Track B, item 5, first of two slices: B5a selection pages, B5b setup page). Stacked on B4b (jaysbeekay/sure#722) in fork stack #687.
Upstream draft PR: https://github.com/we-promise/sure/pull/5234 (same branch, same commit), in native stack we-promise/sure#5268 on refactor/provider-kit.
What changed
ProviderItem::AccountSelectionComponent: the two Brex selection templates differed in seven lines (title, description, form URL, hidden field, checkbox or radio, cancel path, button label), so one component covers both. It picks between them by whether anaccount:is given. Messages come from the provider's existingselect_accounts.*/select_existing_account.*keys, includingconfigure_name_in_<key>; field names come from the provider key (<key>_item_id,<key>_account_id).- The provider turns its API payloads into
AccountSelectionComponent::Options (id, name, metadata). Brex does it in a newbrex_account_optionshelper, built on its existingbrex_account_display/brex_account_metadata. ProviderItem::ApiErrorComponentandProviderItem::SetupRequiredComponent: the two dialogs, with messages from<key>_items.api_error.*/setup_required.*.- The four Brex views keep their names, ivars and locals and render the components; the controller is unchanged.
Screenshots
The move (first commit) changes nothing visible. The DS commit (8fb320136) renders the API error and setup-required messages as DS::Alert (error and warning variants) and the Cancel as a secondary DS::Link, as AGENTS.md and the design-system guide ask. Before is this branch without that commit; after is with it. 1400px and 390px wide.
| Before | After | |
|---|---|---|
| Select accounts, desktop | ![]() | ![]() |
| Select accounts, phone | ![]() | ![]() |
| API error, desktop | ![]() | ![]() |
| API error, phone | ![]() | ![]() |
| Setup required, desktop | ![]() | ![]() |
| Setup required, phone | ![]() | ![]() |
Demo data
No demo data needed: no new records.
Migration notes
No migration.
Verification
-
Snapshots: five renders of the original views, recorded before the change, with the same normalisation as B4:
- select accounts;
- select accounts where no account has a name (Brex always supplies a default name, so the test stubs
BrexAccount.name_forto reach the "cannot import" path, with noreturn_to); - select an existing account;
- the API error;
- setup required.
ProviderItem::SelectionComponentsTestasserts the views still render each one, and that they render through the three components; the latter fails without the change (uninitialized constant ProviderItem::AccountSelectionComponent). -
Snapshot provenance (re-checked 2026-11-17): the five original snapshot tests, plus the new mixed-names one, were run against the old Brex templates on
up/provider-kit-panel, before this slice: all pass (the only error is the wiring test, since the components don't exist there). -
Review fixes (2026-11-17): a test for the API error's fallback link with no return path; a snapshot where one account is named and one is not (recorded from the old template); then the DS commit, which re-records the six affected snapshots on purpose. Each re-recorded diff is the alert block or the Cancel link and nothing else.
-
Existing tests unchanged:
BrexItemsControllerTest,BrexItemsProviderKitTestand the Brex helper tests pass unedited. -
Mutations, each caught: the radio button's field name; the hidden connection id's field name; the submit enabled with no nameable account; the wrong cancel path; the "configure the name in Brex" message key; the API error ignoring its return path; the checkbox's field name.
-
bin/rails test(full, at the B5a commit): 16,300 runs, 0 failures; the same 8ReleaseNotesWorkflowTesterrors (nonodein the test image). -
bin/rubocop,erb_linton the changed templates andbin/brakeman: no offenses or warnings. -
Diff with copy detection (
git diff -Cagainst B4b): non-test +238 / -195. -
Checked against upstream AGENTS.md (blob 1a5dbebd, 2026-11-17): no deviations.
Blast radius
ProviderItemsControllerrendersbrex_items/select_accounts,brex_items/select_existing_account,brex_items/setup_requiredandbrex_items/api_errorwith the same ivars and locals; unchanged.- Siblings: the other providers' selection and error dialogs keep their own templates for now.











