Lunchflow settings family (#363)

* Move provider config to family

* remove global settings

* Remove turbo auto  submit

* Fix flash location

* Fix mssing syncer for lunchflow

* Update schema.rb

* FIX tests and encryption config

* FIX make rabbit happy

* FIX run migration in SQL

* FIX turbo frame modal

* Branding fixes

* FIX rabbit

* OCD with product names

* More OCD

* No other console.log|warn in codebase

---------

Co-authored-by: Juan José Mata <juanjo.mata@gmail.com>
This commit is contained in:
soky srm
2025-11-22 02:14:29 +01:00
committed by GitHub
parent 983fb177fc
commit be0b20dfd9
25 changed files with 532 additions and 127 deletions

View File

@@ -0,0 +1,62 @@
<div class="space-y-4">
<div class="prose prose-sm text-secondary">
<p class="text-primary font-medium">Setup instructions:</p>
<ol>
<li>Visit <a href="https://www.lunchflow.app" target="_blank" rel="noopener noreferrer" class="link">Lunch Flow</a> to get your API key</li>
<li>Paste your API key below and click the Save button</li>
<li>After a successful connection, go to the Accounts tab to set up new accounts and link them to your existing ones</li>
</ol>
<p class="text-primary font-medium">Field descriptions:</p>
<ul>
<li><strong>API Key:</strong> Your Lunch Flow API key for authentication (required)</li>
<li><strong>Base URL:</strong> Base URL for Lunch Flow API (optional, defaults to https://lunchflow.app/api/v1)</li>
</ul>
</div>
<% error_msg = local_assigns[:error_message] || @error_message %>
<% if error_msg.present? %>
<div class="p-2 rounded-md bg-destructive/10 text-destructive text-sm">
<%= error_msg %>
</div>
<% end %>
<%
# Get or initialize a lunchflow_item for this family
# - If family has an item WITH credentials, use it (for updates)
# - If family has an item WITHOUT credentials, use it (to add credentials)
# - If family has no items at all, create a new one
lunchflow_item = Current.family.lunchflow_items.first_or_initialize(name: "Lunch Flow Connection")
is_new_record = lunchflow_item.new_record?
%>
<%= styled_form_with model: lunchflow_item,
url: is_new_record ? lunchflow_items_path : lunchflow_item_path(lunchflow_item),
scope: :lunchflow_item,
method: is_new_record ? :post : :patch,
data: { turbo: true },
class: "space-y-3" do |form| %>
<%= form.text_field :api_key,
label: "API Key",
placeholder: is_new_record ? "Paste API key here" : "Enter new API key to update",
type: :password %>
<%= form.text_field :base_url,
label: "Base URL (Optional)",
placeholder: "https://lunchflow.app/api/v1 (default)",
value: lunchflow_item.base_url %>
<div class="flex justify-end">
<%= form.submit is_new_record ? "Save Configuration" : "Update Configuration",
class: "inline-flex items-center justify-center rounded-lg px-4 py-2 text-sm font-medium text-white bg-gray-900 hover:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-gray-900 focus:ring-offset-2 transition-colors" %>
</div>
<% end %>
<% items = local_assigns[:lunchflow_items] || @lunchflow_items || Current.family.lunchflow_items.where.not(api_key: nil) %>
<% if items&.any? %>
<div class="flex items-center gap-2">
<div class="w-2 h-2 bg-success rounded-full"></div>
<p class="text-sm text-secondary">Configured and ready to use. Visit the <a href="<%= accounts_path %>" class="link">Accounts</a> tab to manage and set up accounts.</p>
</div>
<% end %>
</div>

View File

@@ -32,11 +32,7 @@
<%= styled_form_with model: Setting.new,
url: settings_providers_path,
method: :patch,
data: {
controller: "auto-submit-form",
"auto-submit-form-trigger-event-value": "blur"
} do |form| %>
method: :patch do |form| %>
<div class="space-y-4">
<% configuration.fields.each do |field| %>
<%
@@ -67,9 +63,13 @@
type: input_type,
placeholder: field.default || (field.required ? "" : "Optional"),
value: display_value,
disabled: disabled,
data: { "auto-submit-form-target": "auto" } %>
disabled: disabled %>
<% end %>
<div class="flex justify-end">
<%= form.submit "Save Configuration",
class: "inline-flex items-center justify-center rounded-lg px-4 py-2 text-sm font-medium text-white bg-gray-900 hover:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-gray-900 focus:ring-offset-2 transition-colors" %>
</div>
</div>
<% end %>

View File

@@ -2,14 +2,14 @@
<div class="prose prose-sm text-secondary">
<p class="text-primary font-medium">Setup instructions:</p>
<ol>
<li>Visit <a href="https://beta-bridge.simplefin.org" target="_blank" rel="noopener noreferrer" class="link">SimpleFin Bridge</a> to get your one-time setup token</li>
<li>Paste the token below to enable SimpleFin bank data sync</li>
<li>Visit <a href="https://beta-bridge.simplefin.org" target="_blank" rel="noopener noreferrer" class="link">SimpleFIN Bridge</a> to get your one-time setup token</li>
<li>Paste the token below and click the Save button to enable SimpleFIN bank data sync</li>
<li>After a successful connection, go to the Accounts tab to set up new accounts and link them to your existing ones</li>
</ol>
<p class="text-primary font-medium">Field descriptions:</p>
<ul>
<li><strong>Setup Token:</strong> Your SimpleFin one-time setup token from SimpleFin Bridge (consumed on first use)</li>
<li><strong>Setup Token:</strong> Your SimpleFIN one-time setup token from SimpleFIN Bridge (consumed on first use)</li>
</ul>
</div>
@@ -23,13 +23,17 @@
url: simplefin_items_path,
scope: :simplefin_item,
method: :post,
data: { controller: "auto-submit", action: "keydown.enter->auto-submit#submit blur->auto-submit#submit", turbo: true },
data: { turbo: true },
class: "space-y-3" do |form| %>
<%= form.text_field :setup_token,
label: "Setup Token",
placeholder: "Paste SimpleFin setup token and press Enter",
type: :password,
data: { auto_submit_target: "input" } %>
placeholder: "Paste SimpleFIN setup token",
type: :password %>
<div class="flex justify-end">
<%= form.submit "Save Configuration",
class: "inline-flex items-center justify-center rounded-lg px-4 py-2 text-sm font-medium text-white bg-gray-900 hover:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-gray-900 focus:ring-offset-2 transition-colors" %>
</div>
<% end %>
<% if @simplefin_items&.any? %>
@@ -38,6 +42,6 @@
<p class="text-sm text-secondary">Configured and ready to use. Visit the <a href="<%= accounts_path %>" class="link">Accounts</a> tab to manage and set up accounts.</p>
</div>
<% else %>
<div class="text-sm text-secondary">No SimpleFin connections yet.</div>
<div class="text-sm text-secondary">No SimpleFIN connections yet.</div>
<% end %>
</div>

View File

@@ -14,7 +14,13 @@
<% end %>
<% end %>
<%= settings_section title: "Simplefin" do %>
<%= settings_section title: "Lunch Flow" do %>
<turbo-frame id="lunchflow-providers-panel">
<%= render "settings/providers/lunchflow_panel" %>
</turbo-frame>
<% end %>
<%= settings_section title: "SimpleFIN" do %>
<turbo-frame id="simplefin-providers-panel">
<%= render "settings/providers/simplefin_panel" %>
</turbo-frame>