Generate provider views on the provider kit's components

Merged
JA
2d ago
+360-537

Summary

Provider kit Track B, B6d: provider:family writes views that render the provider kit's components, as Brex's, Lunch Flow's and Mercury's do. The old hand-built panel, card, setup and select templates go (decided 2026-11-15: templates the kit owns are deleted outright). With this slice a generated provider is a kit provider end to end: models (B6a), account flow (B6b), controller and routes (B6c), views (here).

Part of #5003 (Track B, step 6: the generator onto the kit, the last of four layer slices).

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

Before / after (what rails g provider:family writes)

BeforeAfter
settings/providers/_<key>_panel72-line hand-built single form (first_or_initialize), ERB built from strings, plus a "configured" dotPanelComponent in its list shape, as Brex's: each connection with sync, disconnect and edit, then an add form; setup steps from the generated locale
Credential fieldsinline in the panel; a secret echoed nothing but the edit placeholder said "Enter new … to update"<key>_items/_credential_fields, built from the declared fields: a secret is type: :password, value: nil and the edit form says a blank one keeps it; integers get a number field, booleans a toggle. Written even with --skip-view, since the panel renders it
Accounts-page card _<key>_item131-line hand-built cardCardComponent with the page's sync-stats map
select_accountsnot written (the old controller rendered none)AccountSelectionComponent
select_existing_account64-line hand-built dialogAccountSelectionComponent with account:
_api_error, _setup_requirednot writtenApiErrorComponent, SetupRequiredComponent
setup_accounts102-line hand-built pageAccountSetupComponent
app/helpers/<key>_items_helper.rbnot written<key>_account_options (id, name_for, currency_for) and <key>_account_setup_defaults ("Skip"), each under a TODO
Adapter listssettings_panel filtered to connections with their secret (for the old status dot)settings_page: %i[active ordered], settings_panel with Brex's preloads
Localepanel.*, card and dialog keys only the old templates readprovider_panel.*, api_error.*, setup_required.*, subtype_select.*, configure_name_in_<key>; the orphaned keys go

Screenshots

None: existing providers' UI is unchanged. A newly generated provider's pages now look like Brex's, which the kit's snapshots already pin.

Demo data

No demo data needed.

Migration notes

No migration.

Verification

  • Tests, fail-first. All new tests failed on the old templates (missing items_helper.rb.tt; the panel built from strings; four views not written; the adapter's old list) and pass after:
    • "every generated view is plain ERB", for a provider with secret, defaulted, integer and boolean fields;
    • five render tests, one per view family. Brex stands in for a generated provider (it has the model, routes and fixtures): the generated views, helper and translations replace Brex's while each renders, and Brex's own translations are removed first, so a key the generated locale lacks shows as missing instead of falling back. Each checks its component renders, the content, and no translation_missing; the panel also checks the stored token is not in the HTML and the edit placeholder says a blank one keeps it; the card checks it lists only the accounts it is given;
    • "the generated locale has every message the provider kit's views read": 68 keys, each with Brex's plural forms and interpolations, covering branches the renders don't reach;
    • "the generator writes the kit's views and helper, and the panel's with --skip-view" (9 files, or 2);
    • "the generated adapter's panel lists the family's active connections".
  • Tests replaced: the Redbark-backed card, setup and select-existing renders, and the card's account_groups assertion, pinned the deleted templates.
  • End-to-end smoke (not committed). In a scratch copy of this branch: rails g provider:family gocardless api_key:text:secret base_url:string --type=banking, migrate, then 10 integration tests against the generated provider: it is a ProviderItem with ProviderItem::Syncer; the kit's syncer runs its import; Settings > Providers renders its panel without the stored key and with no missing translation; an update stopped at the then-unwritten cache_sensitive_params stub (now generated from the declared fields in B6b), and with it stubbed a blank key keeps the stored one; create goes through the kit controller and names the connection from default_connection_name; the flow's hooks raise their TODOs; the setup page and /accounts (its card) render; destroy schedules deletion. bin/rubocop (11 files) and erb_lint (8 files) were clean on the generated code. The first run found a real defect, fixed in this slice: Settings > Providers hands the panel the settings_page list, whose default selects only ids, so the panel raised missing attribute 'name'; the generated adapter now declares settings_page: %i[active ordered], as Brex's does, and the adapter test pins it.
  • Mutations, each caught (17): no setup steps; the secret echoed; the edit form given the add placeholder; the card handed every account; the helper dropping the id; setup defaulting to Depository; the API error ignoring its return path; a card key, the API error heading, the subtype prompt or configure_name_in_<key> missing from the locale; the generator skipping the helper; the credential fields skipped with --skip-view; the adapter keeping the secret filter; the settings-page list left at its id-only default.
  • bin/rails test (full, at this commit): 16,535 runs, 0 failures; the same 8 ReleaseNotesWorkflowTest errors (no node in the test image).
  • bin/rubocop on the changed Ruby, bin/brakeman: no offenses or warnings.
  • Size (git diff -C): non-test +176 / -457.
  • The earlier merge-down commits' subjects ("Merge up/... into up/...") exceed 72 characters. They stay fork-only: Track B is rebased linear when it goes upstream, as Track A was, so they never reach we-promise/sure.
  • Checked against upstream AGENTS.md (blob 1a5dbebd, 2026-11-17): no deviations.

Blast radius

  • Only rails g provider:family; existing providers' views, adapters and locales are untouched.
  • What a newly generated provider gets differently: a list panel (several connections) instead of one form; the kit's selection, error and setup dialogs; and, until its flow hooks are written, NotImplementedError from listing accounts. Edits work: B6b now generates cache_sensitive_params from the declared fields.
  • Siblings: docs/api/rails_provider_generator.md still describes the pre-kit output (it already did before B6a, e.g. ApplicationRecord models); updating it is left as a follow-up rather than grown into this slice.

Summary by cubic

rails g provider:family now generates views that render the provider kit's components instead of hand-built templates, so newly generated providers' settings, selection, error, and setup UI match existing kit providers.

  • The settings panel is PanelComponent in its list shape: each connection gets sync, disconnect, and edit actions, then an add form with setup steps from the generated locale.
  • Credential fields come from a generated _credential_fields partial built from the declared fields: secrets render as blank password inputs (a blank edit keeps the stored value), integers as number fields, booleans as toggles. It is written even under --skip-view because the panel renders it.
  • The card, both selection dialogs, the API error and setup-required dialogs, and the setup page render CardComponent, AccountSelectionComponent, ApiErrorComponent, SetupRequiredComponent, and AccountSetupComponent.
  • A new <Key>ItemsHelper turns API payloads into selection rows and defaults each imported account to "Skip" in setup; both carry TODOs awaiting the flow hooks.
  • The adapter's settings panel now lists all active connections, including those without credentials, and its settings-page list loads whole records because the panel reads each connection's name.
  • Existing providers are unchanged; the old hand-built panel, card, setup, and selection templates are deleted.