Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby

fix(providers): use ProviderLogo for CoinSpot, Fio and the generator (#3581)

Justin McBridee112c9aa7c32
diff --git a/app/views/coinspot_items/_coinspot_item.html.erb b/app/views/coinspot_items/_coinspot_item.html.erb
index c79842c3c5..efc4757f22 100644
--- a/app/views/coinspot_items/_coinspot_item.html.erb
+++ b/app/views/coinspot_items/_coinspot_item.html.erb
@@ -6,9 +6,7 @@
<div class="flex items-center gap-2 w-full">
<%= icon "chevron-right", class: "group-open:rotate-90 motion-safe:transition-transform motion-safe:duration-150" %>
- <div class="flex items-center justify-center h-8 w-8 rounded-full bg-surface-inset">
- <%= icon "coins", size: "sm", class: "text-primary" %>
- </div>
+ <%= render ProviderLogo.new(provider_key: :coinspot) %>
<div class="pl-1 text-sm flex-1">
<div class="flex items-center gap-2">
diff --git a/app/views/fio_items/_fio_item.html.erb b/app/views/fio_items/_fio_item.html.erb
index c22c9591b7..5f89335245 100644
--- a/app/views/fio_items/_fio_item.html.erb
+++ b/app/views/fio_items/_fio_item.html.erb
@@ -7,9 +7,7 @@
<div class="flex items-center gap-2">
<%= icon "chevron-right", class: "group-open:rotate-90 motion-safe:transition-transform motion-safe:duration-150" %>
- <div class="flex items-center justify-center h-8 w-8 bg-surface rounded-full">
- <p class="text-primary text-xs font-medium"><%= fio_item.name.to_s.first.to_s.upcase %></p>
- </div>
+ <%= render ProviderLogo.new(provider_key: :fio) %>
<div class="pl-1 text-sm">
<div class="flex items-center gap-2">
diff --git a/app/views/settings/providers/_coinspot_panel.html.erb b/app/views/settings/providers/_coinspot_panel.html.erb
index 14c6a9dd5b..661ac81511 100644
--- a/app/views/settings/providers/_coinspot_panel.html.erb
+++ b/app/views/settings/providers/_coinspot_panel.html.erb
@@ -28,9 +28,7 @@
<% disclosure.with_summary_content do %>
<div class="flex items-center justify-between gap-3 w-full">
<div class="flex items-center gap-3 min-w-0">
- <div class="flex items-center justify-center h-8 w-8 rounded-full bg-surface-inset">
- <%= icon "coins", size: "sm", class: "text-primary" %>
- </div>
+ <%= render ProviderLogo.new(provider_key: :coinspot) %>
<div class="min-w-0">
<p class="font-medium text-primary truncate"><%= item.name %></p>
<p class="text-xs text-secondary">
diff --git a/app/views/settings/providers/_fio_panel.html.erb b/app/views/settings/providers/_fio_panel.html.erb
index add916267d..12fcbbded1 100644
--- a/app/views/settings/providers/_fio_panel.html.erb
+++ b/app/views/settings/providers/_fio_panel.html.erb
@@ -22,9 +22,7 @@
<% disclosure.with_summary_content do %>
<div class="flex items-center justify-between gap-2 w-full">
<div class="flex items-center gap-3">
- <div class="flex items-center justify-center h-8 w-8 bg-surface rounded-full">
- <p class="text-primary text-xs font-medium"><%= item.name.to_s.first.to_s.upcase %></p>
- </div>
+ <%= render ProviderLogo.new(provider_key: :fio) %>
<div>
<p class="font-medium text-primary"><%= item.name %></p>
<p class="text-xs text-secondary">
diff --git a/docs/api/rails_provider_generator.md b/docs/api/rails_provider_generator.md
index 6700798e08..c130a1d53d 100644
--- a/docs/api/rails_provider_generator.md
+++ b/docs/api/rails_provider_generator.md
@@ -86,6 +86,13 @@ This single command generates:
- ✅ Routes
- ✅ Updates to settings controller and view
+The generated item partial renders the provider's logo with `ProviderLogo`. That reads the
+provider's `Provider::Metadata::REGISTRY` entry, which the generator does not create, so add
+one in `app/models/provider/metadata.rb`. See
+[provider logos](../llm-guides/providers.md#provider-logos) for the fields it reads
+(`domain`, `logo_text`, `logo_color`, `logo_icon`) and which are used when Brandfetch has no
+icon or is not configured.
+
### Key Characteristics
- **Credentials**: Stored in `my_bank_items` table (encrypted)
- **Isolation**: Each family has completely separate credentials
diff --git a/docs/llm-guides/providers.md b/docs/llm-guides/providers.md
index 9145120302..0fee7a2f7e 100644
--- a/docs/llm-guides/providers.md
+++ b/docs/llm-guides/providers.md
@@ -5,6 +5,22 @@ selection and `Provided` concerns. For a new securities price provider, follow
[the complete workflow](adding-a-securities-provider.md), including response
types, MIC mapping, currency handling, settings encryption, UI, locales and tests.
+## Provider logos
+
+A provider's logo comes from [`ProviderLogo`](../../app/components/provider_logo.rb): the
+Brandfetch icon for the `domain` in its
+[`Provider::Metadata::REGISTRY`](../../app/models/provider/metadata.rb) entry, falling back
+to `logo_icon`, then `logo_text` initials on `logo_color`. Anything identifying a provider
+renders `render ProviderLogo.new(provider_key: :<x>)` — the `_<x>_item` card on Accounts,
+the Bank Sync cards and connection rows, and the connection rows in
+`settings/providers/_<x>_panel` — rather than a hand-built badge or the first letter of a
+connection name. A panel's setup form and instructions carry no logo.
+
+Give each new provider a registry entry with a brand domain. Only a provider with no single
+brand behind it (on-chain wallets) omits the domain and sets `logo_icon` instead.
+Institution logos are a separate concept and belong on accounts through
+`Account#logo_url`, never on a provider.
+
## Support diagnostics
When a provider sync/import path encounters a recoverable error, suspicious partial
diff --git a/lib/generators/provider/family/templates/item_partial.html.erb.tt b/lib/generators/provider/family/templates/item_partial.html.erb.tt
index 9ca152933c..d79dcd4834 100644
--- a/lib/generators/provider/family/templates/item_partial.html.erb.tt
+++ b/lib/generators/provider/family/templates/item_partial.html.erb.tt
@@ -6,11 +6,7 @@
<div class="flex items-center gap-2">
<%%= "<" + "%= icon \"chevron-right\", class: \"group-open:transform group-open:rotate-90\" %" + ">" %>
- <div class="flex items-center justify-center h-8 w-8 bg-primary/10 rounded-full">
- <div class="flex items-center justify-center">
- <%%= "<" + "%= tag.p #{file_name}_item.name.first.upcase, class: \"text-primary text-xs font-medium\" %" + ">" %>
- </div>
- </div>
+ <%%= "<" + "%= render ProviderLogo.new(provider_key: :#{file_name}) %" + ">" %>
<div class="pl-1 text-sm">
<div class="flex items-center gap-2">