Files
sure/app/views/settings/providers/_indexa_capital_panel.html.erb
Guillem Arias Fauste 8de14ed2a5 feat(design-system): DS::Disclosure :inline variant + migrate indexa_capital + snaptrade panels (#1715 §6) (#1858)
* feat(design-system): add :inline variant + migrate indexa_capital + snaptrade panels

Adds an `:inline` variant to `DS::Disclosure` for plain text-link-style
toggles that have no surface, no padding, no shadow — the disclosure
reads as a clickable summary text + revealed content, nothing more.

Use case: "Alternative auth" form section toggle in the Indexa Capital
provider panel; "Manage connections" lazy-loaded toggle in the
Snaptrade provider panel. Both were the last raw-`<details>` callsites
in `app/views/settings/providers/`.

Migrations:

- `_indexa_capital_panel.html.erb` — single inline `<details>` revealing
  username / document / password form fields under an "Alternative auth"
  summary text.
- `_snaptrade_panel.html.erb` — lazy-load `<details>` with
  `data-controller="lazy-load"` etc. The new `tag.details ... **opts`
  forwarding from #1857 lets the Stimulus controller attrs flow
  through cleanly via DS::Disclosure's `data:` keyword.

Chevron rotation on snaptrade gets the standard
`motion-safe:transition-transform motion-safe:duration-150` treatment
(was `transition-transform` without the motion-safe gate).

Variant summary now:

| Variant | Details surface | Use case |
|---|---|---|
| `:default` | none / bg-surface summary | inline expander inside parent card |
| `:card` | `bg-container shadow-border-xs rounded-xl p-4` | provider rows, settings sections |
| `:card_inset` | `bg-surface-inset rounded-xl p-4` | inset sub-panels |
| `:inline` | no surface | text-link-style toggles |

* fix(review): guard variant.to_sym against nil in DS::Disclosure

CodeRabbit on #1858 flagged that `variant: nil` crashed with
`NoMethodError` at `variant.to_sym` before the explicit `VARIANTS`
check could run. Use safe navigation (`variant&.to_sym`) so nil
falls through to the validation, and inspect `@variant` in the
error message so nil / non-symbol inputs render readably.

Verified manually via runner: `DS::Disclosure.new(variant: nil)` now
raises `ArgumentError: Invalid variant: nil. Must be one of
[:default, :card, :card_inset, :inline]`.
2026-05-22 02:14:44 +02:00

63 lines
3.3 KiB
Plaintext

<div class="space-y-4">
<%= render "settings/providers/setup_steps",
steps: [
t("indexa_capital_items.panel.step_1"),
t("indexa_capital_items.panel.step_2"),
t("indexa_capital_items.panel.step_3")
] %>
<% error_msg = local_assigns[:error_message] || @error_message %>
<% if error_msg.present? %>
<%= render DS::Alert.new(message: error_msg, variant: :error) %>
<% end %>
<%
indexa_capital_item = Current.family.indexa_capital_items.first_or_initialize(name: "Indexa Capital Connection")
is_new_record = indexa_capital_item.new_record?
%>
<%= styled_form_with model: indexa_capital_item,
url: is_new_record ? indexa_capital_items_path : indexa_capital_item_path(indexa_capital_item),
scope: :indexa_capital_item,
method: is_new_record ? :post : :patch,
data: { turbo: true },
class: "space-y-3" do |form| %>
<%= form.text_field :api_token,
label: t("indexa_capital_items.panel.fields.api_token.label"),
placeholder: is_new_record ? t("indexa_capital_items.panel.fields.api_token.placeholder_new") : t("indexa_capital_items.panel.fields.api_token.placeholder_update"),
type: :password %>
<p class="text-xs text-secondary px-1 -mt-1"><%= t("indexa_capital_items.panel.fields.api_token.description") %></p>
<%= render DS::Disclosure.new(variant: :inline) do |disclosure| %>
<% disclosure.with_summary_content do %>
<span class="text-sm text-secondary hover:text-primary transition-colors">
<%= t("indexa_capital_items.panel.alternative_auth") %>
</span>
<% end %>
<div class="mt-3 space-y-3 pt-3 border-t border-primary">
<%= form.text_field :username,
label: t("indexa_capital_items.panel.fields.username.label"),
placeholder: is_new_record ? t("indexa_capital_items.panel.fields.username.placeholder_new") : t("indexa_capital_items.panel.fields.username.placeholder_update"),
value: indexa_capital_item.username %>
<%= form.text_field :document,
label: t("indexa_capital_items.panel.fields.document.label"),
placeholder: is_new_record ? t("indexa_capital_items.panel.fields.document.placeholder_new") : t("indexa_capital_items.panel.fields.document.placeholder_update"),
value: indexa_capital_item.document %>
<%= form.text_field :password,
label: t("indexa_capital_items.panel.fields.password.label"),
placeholder: is_new_record ? t("indexa_capital_items.panel.fields.password.placeholder_new") : t("indexa_capital_items.panel.fields.password.placeholder_update"),
type: :password %>
</div>
<% end %>
<div class="flex justify-end">
<%= form.submit is_new_record ? t("indexa_capital_items.panel.save_button") : t("indexa_capital_items.panel.update_button"),
class: "inline-flex items-center justify-center rounded-lg px-4 py-2 text-sm font-medium" %>
</div>
<% end %>
</div>