Files
sure/app/views/simplefin_items/_replacement_prompt.html.erb
Guillem Arias Fauste b2b89437b0 fix(ds): route remaining literal yellow warning surfaces onto --color-warning (#2250)
* fix(ds): route remaining literal yellow warning surfaces onto --color-warning

Completes the #2198 warning consolidation for view-level surfaces:

- rules/index recent-runs status badges → DS::Pill (warning / success / error).
- accounts/_account_sidebar_tabs missing-data notice: bg-yellow-tint-10 /
  text-yellow-600 → bg-warning/10 / text-warning.
- import/confirms/_mappings unassigned-account notice → bg-warning/10 /
  border-warning/20 (also fixes a missing dark variant — it was light-yellow
  in dark mode).
- simplefin/_replacement_prompt card → bg-warning/10 / border-warning/20,
  dropping the now-redundant theme-dark: companions (the token is theme-aware).

rules' blue/purple execution-type badges and the red failed-row highlight are
left as-is (not warning surfaces).

Part of #2198.

* fix(ds): neutral text in sidebar missing-data notice (match DS::Alert recipe)

Warning surfaces follow the DS::Alert recipe — warning tint + warning-colored
icon, but neutral body text (text-primary / text-secondary). The sidebar
missing-data notice was the lone holdout still painting its text (and link)
with text-warning. Switch to neutral text; keep the bg-warning/10 tint and the
warning-colored triangle/chevron as the accent. More readable (color-on-tint
text is low-contrast) and consistent with the DS::Alert migrations.

* fix(ds): missing-data sidebar notice → static DS::Alert (drop disclosure)

The notice was a raw collapsible <details> styled as a warning — a hybrid
that hid its own primary action (the "Configure providers" link) and its
explanation behind a chevron click. A warning's job is to surface a problem
and its fix; a disclosure's job is to hide secondary detail. The two fought
each other (triangle-alert "act on this" vs chevron "optional, expand").

Replace with a static DS::Alert(:warning): icon + title + body + the
Configure link, always visible. Fixes the affordance, surfaces the action,
canonicalizes the last warning-styled raw <details>, and matches the other
DS::Alert notices.

* fix(ds): grey body text in missing-data alert for title/body hierarchy

DS::Alert renders its body in text-primary (same dark as the title). For
this notice, drop the description to text-secondary so the title (primary,
semibold) reads above the supporting body (grey) — clearer hierarchy. Still
neutral (no colored text); the Configure link stays primary + underline so
the action remains the prominent element.

* fix(ds): bump account_sidebar_tabs cache version v1→v2

Flush stale <details>-markup fragments on deploy. The sidebar
missing-data notice migrated from <details> to a static DS::Alert,
but the fragment is cached with a 12h TTL — without a key change,
old markup renders until expiry (and inconsistently across
staggered multi-server cache warmups). Bumping the version string
changes the cache-key namespace so every cached fragment is
bypassed immediately.
2026-06-11 15:30:08 +02:00

70 lines
3.7 KiB
Plaintext

<%# locals: (simplefin_item:, suggestions:)
Banner rendered at the top of the SimpleFIN item card when the importer
detects a likely card-replacement pair (old card + new card, same
institution, same type). "Relink" reuses the existing link_existing_account
controller action to atomically swap the AccountProvider on the linked
Sure account. "Dismiss" persists a per-(dormant_sfa_id) dismissal on the
latest sync's sync_stats so the banner stops showing for that pair.
Suggestions are also auto-suppressed once the relink has already landed. %>
<% latest_sync = simplefin_item.syncs.order(created_at: :desc).first %>
<% dismissed_ids = Array(latest_sync&.sync_stats&.dig("dismissed_replacement_suggestions")) %>
<div class="space-y-2">
<% suggestions.each do |suggestion| %>
<% old_sfa = simplefin_item.simplefin_accounts.find_by(id: suggestion["dormant_sfa_id"]) %>
<% new_sfa = simplefin_item.simplefin_accounts.find_by(id: suggestion["active_sfa_id"]) %>
<% sure_account = Current.family.accounts.find_by(id: suggestion["sure_account_id"]) %>
<% next unless old_sfa && new_sfa && sure_account %>
<%# Hide once the relink has landed: new sfa already linked to the target account. %>
<% next if new_sfa.current_account&.id == sure_account.id %>
<%# Hide if the user has dismissed this specific pair. %>
<% dismissal_key = "#{old_sfa.id}:#{new_sfa.id}" %>
<% next if dismissed_ids.include?(dismissal_key) %>
<div class="bg-warning/10 border border-warning/20 rounded-lg p-4">
<div class="flex items-start gap-3">
<%= icon "credit-card", size: "sm", color: "warning", class: "shrink-0 mt-0.5" %>
<div class="flex-1 space-y-2">
<div class="flex items-start justify-between gap-2">
<p class="text-sm font-medium text-primary">
<%= t("simplefin_items.replacement_prompt.title",
institution: suggestion["institution_name"].presence || simplefin_item.name) %>
</p>
<%= button_to dismiss_replacement_suggestion_simplefin_item_path(simplefin_item),
params: { dormant_sfa_id: old_sfa.id, active_sfa_id: new_sfa.id },
method: :post,
form: { class: "inline shrink-0" },
class: "-mt-1 -mr-1 p-1 rounded hover:bg-warning/20 text-secondary",
aria: { label: t("simplefin_items.replacement_prompt.dismiss_aria") } do %>
<%= icon "x", size: "sm" %>
<% end %>
</div>
<p class="text-xs text-secondary">
<%= t("simplefin_items.replacement_prompt.description",
account_name: sure_account.name,
old_name: old_sfa.name,
new_name: new_sfa.name) %>
</p>
<div class="pt-1">
<% confirm = CustomConfirm.new(
title: t("simplefin_items.replacement_prompt.confirm_title"),
body: t("simplefin_items.replacement_prompt.confirm_body",
account_name: sure_account.name,
new_name: new_sfa.name),
btn_text: t("simplefin_items.replacement_prompt.relink")
) %>
<%= render DS::Button.new(
text: t("simplefin_items.replacement_prompt.relink"),
href: link_existing_account_simplefin_items_path(
account_id: sure_account.id,
simplefin_account_id: new_sfa.id
),
variant: :primary,
data: { turbo_method: :post, turbo_confirm: confirm.to_data_attribute }
) %>
</div>
</div>
</div>
</div>
<% end %>
</div>