Render Lunch Flow's selection dialogs through shared components

JA
5d ago
+533-214

Summary

Provider kit Track B, B7e: Lunch Flow's account-selection dialogs and its two error dialogs render through the shared components Brex has used since B5a: select_accounts and select_existing_account through ProviderItem::AccountSelectionComponent, _api_error through ProviderItem::ApiErrorComponent, _setup_required through ProviderItem::SetupRequiredComponent. A pure move, proven against snapshots recorded from the old views. The one HTML change is the Cancel link, which is now the secondary DS::Link from the DS commit on jaysbeekay/sure#723 (8fb320136); the three affected snapshots were re-recorded in 02a249d78.

Part of jaysbeekay/sure#670 (Track B, step 7: the Lunch Flow conversion, views; option (c), kit variants and hooks that reproduce each provider's HTML). Stacked on the Lunch Flow panel slice (jaysbeekay/sure#750) in fork stack #687.

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

Before / after

Before (Lunch Flow's own views)After
Selection dialogstwo 60-line templates, near copiesAccountSelectionComponent with variant: :classic
Form taghand-written <form> plus its own authenticity_token fieldthe same, from the :classic variant (Brex keeps form_with)
Row without a nameborder-error bg-error/5, text-errorthe same, from :classic (Brex keeps destructive)
Cancel linkdata-action="DS--dialog#close"the same, from :classic
Submit with nothing selectableenabledenabled, from :classic (Brex's is disabled)
Row contentinline in each templatelunchflow_account_options helper: name; IBAN's last four, institution, currency, status
API error dialogDS::Alert heading, four "Label:" issues, always links to provider settingsApiErrorComponent with notice: :alert, heading:, issues:, link_text:, and return_path: nil
Setup-required dialogDS::Alert warning, own step keysSetupRequiredComponent with notice: :alert, heading:, description:, steps_title:, steps:, link_text:
Rendered HTMLunchanged (snapshots), except the Cancel link's classes (DS secondary link, from jaysbeekay/sure#723)

What changed

  • ProviderItem::AccountSelectionComponent: variant: (:kit by default, :classic), read by classic?, cancel_data, submit_disabled?, blank_name_border_classes and blank_name_text_class. The form's contents are captured once and wrapped either in form_with or in the hand-written tag.
  • ProviderItem::ApiErrorComponent: notice: (:icon by default, :alert), and optional heading:, issues: (label and description pairs) and link_text:. With none given it reads Brex's keys exactly as before.
  • ProviderItem::SetupRequiredComponent: the same, with description:, steps_title: and steps:.
  • LunchflowItemsHelper#lunchflow_account_options (new): the row content the two templates computed inline.
  • The four Lunch Flow views keep their names, ivars and locals; the controller is unchanged. No locale file changes: Lunch Flow's own keys are passed in.

Screenshots

The move changes nothing else visible. The Cancel link is now the secondary DS::Link from jaysbeekay/sure#723's DS commit (8fb320136): a slightly darker grey fill. Lunch Flow's API error and setup-required dialogs render the same before and after (snapshots match), so they are not shown. Before is the base branch up/lunchflow-kit-panel (0b0c28ba8); after is this head (eb5d5d6c1). Desktop 1280px; phone at Chrome's 500px minimum window width.

BeforeAfter
Select accounts, desktop
Select accounts, phone

Demo data

No demo data needed.

Migration notes

No migration.

Verification

  • Snapshots recorded first: five renders of the old views were written (PROVIDER_ITEM_SNAPSHOTS=write) before anything changed:

    • select accounts: an account with an IBAN, one without, and one with no name (an institution name with &, to cover escaping);
    • select accounts where nothing has a name, with no return_to;
    • select an existing account;
    • the API error, given a return path (which Lunch Flow's dialog ignores);
    • setup required.

    "The Lunch Flow selection pages and dialogs render through the shared components" failed then (expected at least once, invoked never for all three components), and passes after. Lunch Flow's form writes its own token field, whose attributes put an id between the name and the value, so the test normalises that token itself. Brex's five snapshots still match.

  • Snapshot provenance (checked 2026-11-17): this slice's five snapshot tests were run against the old Lunch Flow views on up/lunchflow-kit-panel (a02536c10), before this slice.

    • With the snapshots as first recorded (5eea4afe6): 5 runs, 0 failures. So the recordings are the old views' output.
    • With the current snapshots: 3 failures (select_accounts, select_accounts_without_names, select_existing_account). Each differs only in the Cancel link's classes: the old views' hand-styled button-bg-secondary anchor against the secondary DS::Link. That is the deliberate DS change re-recorded in 02a249d78. api_error and setup_required still match.
  • Existing tests unedited: LunchflowItemsControllerTest, the Brex selection tests and the helper tests pass.

  • Mutations, each caught (15): the classic form built with form_with; the classic Cancel not closing the dialog; the classic submit disabled with nothing selectable; Brex's submit never disabled; the classic rows' border or text in destructive; the IBAN suffix dropped; currency and status swapped; Lunch Flow's API error following the return path; its notice beside an icon; a label's colon dropped; the setup-required notice beside an icon; Brex's API error losing an issue; Brex's setup steps reordered; the provider's link text ignored.

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

  • bin/rubocop, erb_lint on the changed files: no offenses. bin/brakeman: no warnings.

  • Size (git diff -C): non-test +188 / -226.

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

Blast radius

Who else hits these lines, and what do they pass?

  • ProviderItemsController renders lunchflow_items/select_accounts, select_existing_account, setup_required and api_error with the same ivars and locals as before.
  • The three components are also rendered by Brex's views, which pass none of the new arguments; Brex's snapshots pin that their output is unchanged.
  • Siblings: Mercury's selection and error dialogs move in their own slice (its notice is the icon form, with its own keys); the other providers keep their templates.