Derive family panels from adapter panel declarations

Merged
JA
2d ago
+177-117

Summary

Provider kit Track A, A3: Settings::ProvidersController::FAMILY_PANELS is derived from a panel: argument on each adapter's declares_connection instead of hand-kept.

Part of #5003

Stacked on #5079 (A2), in Track A's native stack on #5005.

Fork pre-flight: jaysbeekay/sure#688 (same commits, against a mirror of upstream main; its CI, Gatekeeper and review history live there).

What changed

  • declares_connection(..., panel: { title:, turbo_id:, auto_open: }): turbo_id defaults to the key and the partial is always <key>_panel. Stored as panel_declaration, separate from the connection entry, so ProviderConnectionStatus::PROVIDERS is unchanged.
  • 26 adapters declare their panel with the exact title from the old list. Trade Republic declares turbo_id: "trade-republic", SnapTrade auto_open: "manage". Plaid and FinanceKit declare none.
  • Provider::Factory.panel_declarations; FAMILY_PANELS = Provider::Factory.panel_declarations.freeze.
  • Generator: no longer patches FAMILY_PANELS; the adapter template always declares panel: (--skip-view now skips only the item views: the adapter still declares its panel, the panel partial is written and the Bank sync wiring runs, so every account provider has a panel). When the generator did not write the adapter (it existed, or --skip-adapter), it prints the declaration to add, since the derived lists (this one, PANEL_SYNCABLE_TYPES, PROVIDERS) would otherwise leave the provider out. Docs updated.

No visible change. The list's internal order becomes key order; Bank sync sorts rows by title, and every other reader (connect_form, render_provider_panel, FAMILY_PANEL_KEYS) looks panels up by key.

Review fixes (2026-11-15)

  • --skip-view conflicted with the panel test (every account provider but Plaid and FinanceKit has a panel with its partial). The generator now always declares the panel, writes the panel partial and wires Bank sync; --skip-view skips only the item views. Tests: the adapter declares panel:, the partial is written and Bank sync is wired with and without --skip-view; mutations restoring either skip are caught.

Demo data

No demo data needed.

Migration notes

No migration.

Verification

  • Old vs new (Rails runner against the removed literal): 26 = 26, same set of hashes.
  • New tests: every account provider but Plaid and FinanceKit has a panel with an existing partial and a unique title; exact entries for Brex plus the Fio title, Trade Republic turbo_id and SnapTrade auto_open; the generated adapter declares panel:, and the panel partial and Bank sync wiring are generated, with and without --skip-view; panel_declared? recognises a declaring adapter and rejects one without a panel, without a declaration, or with a different key.
  • Fail-first: the derivation test failed before the change (no panel_declarations). The invariants test passed on the old list too; it is a regression guard.
  • Mutations, each caught: drop Trade Republic's turbo_id; drop SnapTrade's auto_open; drop Wise's panel; the template never declaring a panel; the wrong partial name; panel_declared? always true.
  • eager_load! then FAMILY_PANELS.size = 26.
  • bin/rails test (full): 15,868 runs, 0 failures; 8 errors in ReleaseNotesWorkflowTest from node missing in the test image. After rebasing the stack onto upstream main (dbeebf14c), the full suite at the top of the stack (A9): 16,246 runs, 0 failures, the same 8 environment errors.
  • bin/rubocop on changed files: no offenses. bin/brakeman: no warnings.

Blast radius

  • FAMILY_PANELS readers: connect_form (find), ApplicationController#render_provider_panel (FAMILY_PANELS_BY_KEY.fetch), FAMILY_PANEL_KEYS (include?/any?), build_provider_entries (sorted by title). None depends on order or hash key order.
  • PANEL_SYNCABLE_TYPES (A2) filters by FAMILY_PANEL_KEYS, now also derived; it is unchanged (its test still passes).

Summary by cubic

Derives Settings::ProvidersController::FAMILY_PANELS from each adapter's declares_connection panel: declaration instead of a hand-kept list of 26 entries. The derived list keeps the same entries — no visible behavior changes, and readers already look panels up by key or sort by title.

  • declares_connection now accepts panel: { title:, turbo_id: (defaults to key), auto_open: }; the partial is always <key>_panel.
  • All 26 adapters declare their panel; Plaid and FinanceKit still don't.
  • The provider:family generator no longer patches FAMILY_PANELS: its adapter template declares panel: and the panel partial is written even with --skip-view, which now skips only the item views. When the generator did not write the adapter (it existed, or --skip-adapter), it prints the declaration to add, since the derived lists would otherwise leave the provider out.

Part of #5003.

Summary by CodeRabbit

  • New Features
    • Provider settings panels now display provider-specific titles and can support custom panel IDs and automatic opening.
    • Newly generated providers include a settings panel even when item views are skipped.
  • Documentation
    • Updated the provider generator guide with revised panel setup and troubleshooting instructions.