Generate provider views on the provider kit's components
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 (owner decision, 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 jaysbeekay/sure#670 (Track B, step 6: the generator onto the kit, the last of four layer slices). Stacked on B6c (jaysbeekay/sure#756) in fork stack #687.
Upstream draft PR: https://github.com/we-promise/sure/pull/5266 (same branch, same commit), in native stack we-promise/sure#5268 on refactor/provider-kit.
Before / after (what rails g provider:family writes)
| Before | After | |
|---|---|---|
settings/providers/_<key>_panel | 72-line hand-built single form (first_or_initialize), ERB built from strings, plus a "configured" dot | PanelComponent 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 fields | inline 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>_item | 131-line hand-built card | CardComponent with the page's sync-stats map |
select_accounts | not written (the old controller rendered none) | AccountSelectionComponent |
select_existing_account | 64-line hand-built dialog | AccountSelectionComponent with account: |
_api_error, _setup_required | not written | ApiErrorComponent, SetupRequiredComponent |
setup_accounts | 102-line hand-built page | AccountSetupComponent |
app/helpers/<key>_items_helper.rb | not written | <key>_account_options (id, name_for, currency_for) and <key>_account_setup_defaults ("Skip"), each under a TODO |
| Adapter lists | settings_panel filtered to connections with their secret (for the old status dot) | settings_page: %i[active ordered], settings_panel with Brex's preloads |
| Locale | panel.*, card and dialog keys only the old templates read | provider_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_groupsassertion, 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 aProviderItemwithProviderItem::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-unwrittencache_sensitive_paramsstub (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 fromdefault_connection_name; the flow's hooks raise their TODOs; the setup page and/accounts(its card) render; destroy schedules deletion.bin/rubocop(11 files) anderb_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 thesettings_pagelist, whose default selects only ids, so the panel raisedmissing attribute 'name'; the generated adapter now declaressettings_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 8ReleaseNotesWorkflowTesterrors (nonodein the test image).bin/rubocopon 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,
NotImplementedErrorfrom listing accounts. Edits work: B6b now generatescache_sensitive_paramsfrom the declared fields. - Siblings:
docs/api/rails_provider_generator.mdstill describes the pre-kit output (it already did before B6a, e.g.ApplicationRecordmodels); updating it is left as a follow-up rather than grown into this slice.