The personal finance app for everyone (by everyone)
Ruby
Add a 'Bank Sync' page in Settings (#111)
Amr Awad26c18427c7ac
diff --git a/app/controllers/settings/api_keys_controller.rb b/app/controllers/settings/api_keys_controller.rbindex 4804cdf58a..c7258a454c 100644--- a/app/controllers/settings/api_keys_controller.rb+++ b/app/controllers/settings/api_keys_controller.rb@@ -6,6 +6,10 @@ class Settings::ApiKeysController < ApplicationControllerbefore_action :set_api_key, only: [ :show, :destroy ]def show+ @breadcrumbs = [+ [ "Home", root_path ],+ [ "API Keys", nil ]+ ]@current_api_key = @api_keyenddiff --git a/app/controllers/settings/bank_sync_controller.rb b/app/controllers/settings/bank_sync_controller.rbnew file mode 100644index 0000000000..21f3cda31b--- /dev/null+++ b/app/controllers/settings/bank_sync_controller.rb@@ -0,0 +1,27 @@+class Settings::BankSyncController < ApplicationController+ layout "settings"++ def show+ @providers = [+ {+ name: "Lunch Flow",+ description: "US, Canada, UK, EU, Brazil and Asia through multiple open banking providers.",+ path: "https://lunchflow.app/features/sure-integration",+ target: "_blank",+ rel: "noopener noreferrer"+ },+ {+ name: "Plaid",+ description: "US & Canada bank connections with transactions, investments, and liabilities.",+ path: "https://github.com/we-promise/sure/blob/main/docs/hosting/plaid.md",+ target: "_blank",+ rel: "noopener noreferrer"+ },+ {+ name: "SimpleFin",+ description: "US & Canada connections via SimpleFin protocol.",+ path: simplefin_items_path+ }+ ]+ end+enddiff --git a/app/controllers/settings/hostings_controller.rb b/app/controllers/settings/hostings_controller.rbindex 5fb2869b56..066e318ef4 100644--- a/app/controllers/settings/hostings_controller.rb+++ b/app/controllers/settings/hostings_controller.rb@@ -6,6 +6,10 @@ class Settings::HostingsController < ApplicationControllerbefore_action :ensure_admin, only: :clear_cachedef show+ @breadcrumbs = [+ [ "Home", root_path ],+ [ "Self-Hosting", nil ]+ ]twelve_data_provider = Provider::Registry.get_provider(:twelve_data)@twelve_data_usage = twelve_data_provider&.usageenddiff --git a/app/controllers/settings/securities_controller.rb b/app/controllers/settings/securities_controller.rbindex 9f8eac1c7d..756accf796 100644--- a/app/controllers/settings/securities_controller.rb+++ b/app/controllers/settings/securities_controller.rb@@ -2,5 +2,9 @@ class Settings::SecuritiesController < ApplicationControllerlayout "settings"def show+ @breadcrumbs = [+ [ "Home", root_path ],+ [ "Security", nil ]+ ]endenddiff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rbindex 0f8ab4710c..af237bfc9f 100644--- a/app/helpers/settings_helper.rb+++ b/app/helpers/settings_helper.rb@@ -3,7 +3,7 @@ module SettingsHelper{ name: "Account", path: :settings_profile_path },{ name: "Preferences", path: :settings_preferences_path },{ name: "Security", path: :settings_security_path },- { name: "Self hosting", path: :settings_hosting_path, condition: :self_hosted? },+ { name: "Self-Hosting", path: :settings_hosting_path, condition: :self_hosted? },{ name: "API Key", path: :settings_api_key_path },{ name: "Billing", path: :settings_billing_path, condition: :not_self_hosted? },{ name: "Accounts", path: :accounts_path },diff --git a/app/views/settings/_settings_nav.html.erb b/app/views/settings/_settings_nav.html.erbindex 7fb1b18d8e..9a6e0f15da 100644--- a/app/views/settings/_settings_nav.html.erb+++ b/app/views/settings/_settings_nav.html.erb@@ -6,10 +6,11 @@ nav_sections = [{ label: t(".profile_label"), path: settings_profile_path, icon: "circle-user" },{ label: t(".preferences_label"), path: settings_preferences_path, icon: "bolt" },{ label: t(".security_label"), path: settings_security_path, icon: "shield-check" },- { label: "API Key", path: settings_api_key_path, icon: "key" },+ { label: t(".api_keys_label"), path: settings_api_key_path, icon: "key" },{ label: t(".self_hosting_label"), path: settings_hosting_path, icon: "database", if: self_hosted? },{ label: t(".billing_label"), path: settings_billing_path, icon: "circle-dollar-sign", if: !self_hosted? },{ label: t(".accounts_label"), path: accounts_path, icon: "layers" },+ { label: t(".bank_sync_label"), path: settings_bank_sync_path, icon: "banknote" },{ label: "SimpleFin", path: simplefin_items_path, icon: "building-2" },{ label: t(".imports_label"), path: imports_path, icon: "download" }]diff --git a/app/views/settings/bank_sync/_provider_link.html.erb b/app/views/settings/bank_sync/_provider_link.html.erbnew file mode 100644index 0000000000..8a2d524cd8--- /dev/null+++ b/app/views/settings/bank_sync/_provider_link.html.erb@@ -0,0 +1,32 @@+<%# locals: (provider_link:) %>++<%# Assign distinct colors to each provider %>+<% provider_colors = {+ "Lunch Flow" => "#6471eb",+ "Plaid" => "#4da568",+ "SimpleFin" => "#e99537"+} %>+<% provider_color = provider_colors[provider_link[:name]] || "#6B7280" %>++<%= link_to provider_link[:path],+ target: provider_link[:target],+ rel: provider_link[:rel],+ class: "flex justify-between items-center p-4 bg-container hover:bg-container-hover transition-colors" do %>+ <div class="flex w-full items-center gap-2.5">+ <%= render partial: "shared/color_avatar", locals: { name: provider_link[:name], color: provider_color } %>++ <div class="flex flex-col">+ <p class="text-primary text-sm font-medium">+ <%= provider_link[:name] %>+ </p>+ <p class="text-secondary text-xs">+ <%= provider_link[:description] %>+ </p>+ </div>+ </div>+ <div class="justify-self-end">+ <%= icon("arrow-right", size: "sm", class: "text-secondary") %>+ </div>+<% end %>++diff --git a/app/views/settings/bank_sync/show.html.erb b/app/views/settings/bank_sync/show.html.erbnew file mode 100644index 0000000000..56f634743a--- /dev/null+++ b/app/views/settings/bank_sync/show.html.erb@@ -0,0 +1,29 @@+<%= content_for :page_title, "Bank Sync" %>+++<div class="bg-container rounded-xl shadow-border-xs p-4">+ <% if @providers.any? %>+ <div class="rounded-xl bg-container-inset space-y-1 p-1">+ <div class="flex items-center gap-1.5 px-4 py-2 text-xs font-medium text-secondary uppercase">+ <p>PROVIDERS</p>+ <span class="text-subdued">·</span>+ <p><%= @providers.count %></p>+ </div>++ <div class="bg-container rounded-lg shadow-border-xs">+ <div class="overflow-hidden rounded-lg">+ <%= render partial: "provider_link", collection: @providers, spacer_template: "shared/ruler" %>+ </div>+ </div>+ </div>+ <% else %>+ <div class="flex justify-center items-center py-20">+ <div class="text-center flex flex-col items-center max-w-[300px]">+ <p class="text-primary mb-1 font-medium text-sm">No providers configured</p>+ <p class="text-secondary text-sm">Configure providers to link your bank accounts.</p>+ </div>+ </div>+ <% end %>+</div>++diff --git a/config/locales/views/settings/en.yml b/config/locales/views/settings/en.ymlindex f13a16ad15..8e7b17b8d8 100644--- a/config/locales/views/settings/en.yml+++ b/config/locales/views/settings/en.yml@@ -84,10 +84,12 @@ en:profile_label: Accountrules_label: Rulessecurity_label: Security- self_hosting_label: Self hosting+ self_hosting_label: Self-Hostingtags_label: Tagstransactions_section_title: Transactionswhats_new_label: What's new+ api_keys_label: API Keys+ bank_sync_label: Bank Syncsettings_nav_link_large:next: Nextprevious: Backdiff --git a/config/routes.rb b/config/routes.rbindex 9a5a66d53b..d89dcdb47e 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -63,6 +63,7 @@ Rails.application.routes.draw doresource :billing, only: :showresource :security, only: :showresource :api_key, only: [ :show, :new, :create, :destroy ]+ resource :bank_sync, only: :show, controller: "bank_sync"endresource :subscription, only: %i[new show create] dodiff --git a/docs/hosting/logos.md b/docs/hosting/logos.mdindex 4a8aacfb2c..5e216568bd 100644--- a/docs/hosting/logos.md+++ b/docs/hosting/logos.md@@ -14,7 +14,7 @@ Logos are currently matched in the following ways:A Brand Fetch Client ID is required and to obtain a client ID, sign up for an account [here](https://brandfetch.com/developers/logo-api).-Once you enter the Client ID into the Sure settings under the `Self hosting` section, logos from Brand Fetch integration will be enabled.+Once you enter the Client ID into the Sure settings under the `Self-Hosting` section, logos from Brand Fetch integration will be enabled.Alternatively, you can provide the client id using the `BRAND_FETCH_CLIENT_ID` environment variable to the web and worker services.diff --git a/test/system/settings_test.rb b/test/system/settings_test.rbindex 7da571784f..c7d5efe444 100644--- a/test/system/settings_test.rb+++ b/test/system/settings_test.rb@@ -35,8 +35,8 @@ class SettingsTest < ApplicationSystemTestCaseRails.application.config.app_mode.stubs(:self_hosted?).returns(true)Provider::Registry.stubs(:get_provider).with(:twelve_data).returns(nil)open_settings_from_sidebar- assert_selector "li", text: "Self hosting"- click_link "Self hosting"+ assert_selector "li", text: "Self-Hosting"+ click_link "Self-Hosting"assert_current_path settings_hosting_pathassert_selector "h1", text: "Self-Hosting"check "setting[require_invite_for_signup]", allow_label_click: true