The personal finance app for everyone (by everyone)
Ruby
<%# locals: (path:, accountable_type:, provider_configs:) %>
<%= render layout: "accounts/new/container", locals: { title: t(".title"), back_path: new_account_path } do %>
<div class="text-sm"
<% if provider_configs.any? { |c| c[:key] == "lunchflow" } %>
data-controller="lunchflow-preload"
data-lunchflow-preload-accountable-type-value="<%= h(accountable_type) %>"
<% if params[:return_to] %>
data-lunchflow-preload-return-to-value="<%= h(params[:return_to]) %>"
<% end %>
<% end %>>
<%# Manual entry option %>
<%= link_to path, class: "group flex items-center gap-4 w-full text-center text-primary focus:outline-hidden focus:bg-surface-hover border border-transparent focus:border focus:border-secondary px-2 hover:bg-surface-hover rounded-lg p-2" do %>
<span class="flex w-8 h-8 shrink-0 grow-0 items-center justify-center rounded-lg bg-alpha-black-50 shadow-[inset_0_0_0_1px_rgba(0,0,0,0.02)]">
<%= icon("keyboard") %>
</span>
<%= t("accounts.new.method_selector.manual_entry") %>
<%= icon("chevron-right", size: "sm", class: "ml-auto shrink-0 text-subdued transition-colors group-hover:text-secondary") %>
<% end %>
<%# Dynamic provider links. Admins may connect anything; a member may only
connect providers whose credential is scoped to the single connection
they authenticate (see ProviderItemOwnable). %>
<% provider_configs.each do |config| %>
<%# The controller gate is `member_connectable? && Current.user&.member?`
(ConnectorAuthorizable#require_connector_create!). Without the role
check here a GUEST is offered the link and refused on submit, which
reads as a broken control rather than an absent one. %>
<% next unless Current.user&.admin? || (Current.user&.member? && config[:member_connectable]) %>
<% link_path = config[:new_account_path].call(accountable_type, params[:return_to]) %>
<% is_lunchflow = config[:key] == "lunchflow" %>
<%= link_to link_path,
class: "group text-primary flex items-center gap-4 w-full text-center focus:outline-hidden focus:bg-surface-hover border border-transparent focus:border focus:border-primary px-2 hover:bg-surface-hover rounded-lg p-2",
data: is_lunchflow ? {
turbo_frame: "modal",
lunchflow_preload_target: "link"
} : { turbo_frame: "modal", turbo_prefetch: "false" } do %>
<span class="flex w-8 h-8 shrink-0 grow-0 items-center justify-center rounded-lg bg-alpha-black-50 shadow-[inset_0_0_0_1px_rgba(0,0,0,0.02)]">
<%= icon("link-2") %>
</span>
<% if is_lunchflow %>
<span class="flex items-center gap-2">
<%= t("accounts.new.method_selector.link_with_provider", provider: config[:name]) %>
<span data-lunchflow-preload-target="spinner" class="hidden">
<%= icon("loader-2", class: "animate-spin") %>
</span>
</span>
<% else %>
<%= t("accounts.new.method_selector.link_with_provider", provider: config[:name]) %>
<% end %>
<%= icon("chevron-right", size: "sm", class: "ml-auto shrink-0 text-subdued transition-colors group-hover:text-secondary") %>
<% end %>
<% end %>
</div>
<% end %>