From c05ee9b5725afe3dd566fa6a939634dbccdcdfcc Mon Sep 17 00:00:00 2001 From: Zach Gollwitzer Date: Tue, 27 Aug 2024 17:10:31 -0400 Subject: [PATCH] Remove unused settings temporarily (#1136) --- .../settings/billings_controller.rb | 7 ---- .../settings/notifications_controller.rb | 7 ---- .../settings/securities_controller.rb | 7 ---- app/helpers/settings_helper.rb | 42 ++++++++++++++++--- app/views/accounts/index.html.erb | 9 +--- app/views/categories/index.html.erb | 5 +-- app/views/imports/index.html.erb | 6 +-- app/views/merchants/index.html.erb | 7 +--- app/views/pages/changelog.html.erb | 15 ++++--- app/views/pages/feedback.html.erb | 7 ++-- app/views/pages/invites.html.erb | 14 ------- app/views/settings/_nav.html.erb | 13 ------ app/views/settings/billings/show.html.erb | 19 --------- app/views/settings/hostings/show.html.erb | 18 ++++---- .../settings/notifications/show.html.erb | 15 ------- app/views/settings/preferences/show.html.erb | 7 ++-- app/views/settings/profiles/show.html.erb | 5 +-- app/views/settings/securities/show.html.erb | 15 ------- app/views/tags/index.html.erb | 5 +-- config/locales/views/settings/en.yml | 9 +--- config/routes.rb | 8 ---- .../settings/billings_controller_test.rb | 0 .../settings/notifications_controller_test.rb | 11 ----- .../settings/securities_controller_test.rb | 11 ----- test/system/settings_test.rb | 29 ++++++------- 25 files changed, 84 insertions(+), 207 deletions(-) delete mode 100644 app/controllers/settings/billings_controller.rb delete mode 100644 app/controllers/settings/notifications_controller.rb delete mode 100644 app/controllers/settings/securities_controller.rb delete mode 100644 app/views/pages/invites.html.erb delete mode 100644 app/views/settings/billings/show.html.erb delete mode 100644 app/views/settings/notifications/show.html.erb delete mode 100644 app/views/settings/securities/show.html.erb delete mode 100644 test/controllers/settings/billings_controller_test.rb delete mode 100644 test/controllers/settings/notifications_controller_test.rb delete mode 100644 test/controllers/settings/securities_controller_test.rb diff --git a/app/controllers/settings/billings_controller.rb b/app/controllers/settings/billings_controller.rb deleted file mode 100644 index c4bdd1f5..00000000 --- a/app/controllers/settings/billings_controller.rb +++ /dev/null @@ -1,7 +0,0 @@ -class Settings::BillingsController < SettingsController - def edit - end - - def update - end -end diff --git a/app/controllers/settings/notifications_controller.rb b/app/controllers/settings/notifications_controller.rb deleted file mode 100644 index bb458dc7..00000000 --- a/app/controllers/settings/notifications_controller.rb +++ /dev/null @@ -1,7 +0,0 @@ -class Settings::NotificationsController < SettingsController - def edit - end - - def update - end -end diff --git a/app/controllers/settings/securities_controller.rb b/app/controllers/settings/securities_controller.rb deleted file mode 100644 index 9d3bac42..00000000 --- a/app/controllers/settings/securities_controller.rb +++ /dev/null @@ -1,7 +0,0 @@ -class Settings::SecuritiesController < SettingsController - def edit - end - - def update - end -end diff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rb index eca2075c..3f4be356 100644 --- a/app/helpers/settings_helper.rb +++ b/app/helpers/settings_helper.rb @@ -1,14 +1,46 @@ module SettingsHelper - def next_setting(title, path) - render partial: "settings/nav_link_large", locals: { path: path, direction: "next", title: title } - end + SETTINGS_ORDER = [ + { name: I18n.t("settings.nav.profile_label"), path: :settings_profile_path }, + { name: I18n.t("settings.nav.preferences_label"), path: :settings_preferences_path }, + { name: I18n.t("settings.nav.self_hosting_label"), path: :settings_hosting_path, condition: :self_hosted? }, + { name: I18n.t("settings.nav.accounts_label"), path: :accounts_path }, + { name: I18n.t("settings.nav.tags_label"), path: :tags_path }, + { name: I18n.t("settings.nav.categories_label"), path: :categories_path }, + { name: I18n.t("settings.nav.merchants_label"), path: :merchants_path }, + { name: I18n.t("settings.nav.imports_label"), path: :imports_path }, + { name: I18n.t("settings.nav.whats_new_label"), path: :changelog_path }, + { name: I18n.t("settings.nav.feedback_label"), path: :feedback_path } + ] - def previous_setting(title, path) - render partial: "settings/nav_link_large", locals: { path: path, direction: "previous", title: title } + def adjacent_setting(current_path, offset) + visible_settings = SETTINGS_ORDER.select { |setting| setting[:condition].nil? || send(setting[:condition]) } + current_index = visible_settings.index { |setting| send(setting[:path]) == current_path } + return nil unless current_index + + adjacent_index = current_index + offset + return nil if adjacent_index < 0 || adjacent_index >= visible_settings.size + + adjacent = visible_settings[adjacent_index] + + render partial: "settings/nav_link_large", locals: { + path: send(adjacent[:path]), + direction: offset > 0 ? "next" : "previous", + title: adjacent[:name] + } end def settings_section(title:, subtitle: nil, &block) content = capture(&block) render partial: "settings/section", locals: { title: title, subtitle: subtitle, content: content } end + + def settings_nav_footer + previous_setting = adjacent_setting(request.path, -1) + next_setting = adjacent_setting(request.path, 1) + + content_tag :div, class: "flex justify-between gap-4" do + concat(previous_setting) + concat(next_setting) + end + end end diff --git a/app/views/accounts/index.html.erb b/app/views/accounts/index.html.erb index 6ef4a852..ec9294a9 100644 --- a/app/views/accounts/index.html.erb +++ b/app/views/accounts/index.html.erb @@ -42,12 +42,5 @@ <% end %> -
- <% if self_hosted? %> - <%= previous_setting("Self-Hosting", settings_hosting_path) %> - <% else %> - <%= previous_setting("Billing", settings_billing_path) %> - <% end %> - <%= next_setting("Tags", tags_path) %> -
+ <%= settings_nav_footer %> diff --git a/app/views/categories/index.html.erb b/app/views/categories/index.html.erb index f06a59fe..6e79fa13 100644 --- a/app/views/categories/index.html.erb +++ b/app/views/categories/index.html.erb @@ -40,8 +40,5 @@ <% end %> - + <%= settings_nav_footer %> diff --git a/app/views/imports/index.html.erb b/app/views/imports/index.html.erb index c6be1f0f..c62d3b61 100644 --- a/app/views/imports/index.html.erb +++ b/app/views/imports/index.html.erb @@ -24,8 +24,6 @@ <% end %> -
- <%= previous_setting("Rules", rules_transactions_path) %> - <%= next_setting("What's new", changelog_path) %> -
+ + <%= settings_nav_footer %> diff --git a/app/views/merchants/index.html.erb b/app/views/merchants/index.html.erb index 6a31839a..e5fcfbfa 100644 --- a/app/views/merchants/index.html.erb +++ b/app/views/merchants/index.html.erb @@ -40,8 +40,5 @@ <% end %> - - + <%= settings_nav_footer %> + diff --git a/app/views/pages/changelog.html.erb b/app/views/pages/changelog.html.erb index ba2302a7..df40a0af 100644 --- a/app/views/pages/changelog.html.erb +++ b/app/views/pages/changelog.html.erb @@ -1,6 +1,7 @@ <% content_for :sidebar do %> <%= render "settings/nav" %> <% end %> +

<%= t(".title") %>

@@ -11,12 +12,12 @@
<%= image_tag release_notes[:avatar], class: "rounded-full w-full h-full object-cover" %>
-
-
<%= release_notes[:name] %>
-
<%= release_notes[:published_at].strftime("%B %d, %Y") %>
+
+
<%= release_notes[:name] %>
+
<%= release_notes[:published_at].strftime("%B %d, %Y") %>
+
-

<%= release_notes[:name] %>

<%= release_notes[:body].html_safe %> @@ -24,8 +25,6 @@
<% end %> -
- <%= previous_setting("Imports", imports_path) %> - <%= next_setting("Feedback", feedback_path) %> -
+ + <%= settings_nav_footer %> diff --git a/app/views/pages/feedback.html.erb b/app/views/pages/feedback.html.erb index af242487..2953316a 100644 --- a/app/views/pages/feedback.html.erb +++ b/app/views/pages/feedback.html.erb @@ -1,6 +1,7 @@ <% content_for :sidebar do %> <%= render "settings/nav" %> <% end %> +

Feedback

@@ -8,8 +9,6 @@

Feedback coming soon...

-
- <%= previous_setting("What's New", changelog_path) %> - <%= next_setting("Invite friends", invites_path) %> -
+ + <%= settings_nav_footer %> diff --git a/app/views/pages/invites.html.erb b/app/views/pages/invites.html.erb deleted file mode 100644 index a838cecc..00000000 --- a/app/views/pages/invites.html.erb +++ /dev/null @@ -1,14 +0,0 @@ -<% content_for :sidebar do %> - <%= render "settings/nav" %> -<% end %> -
-

Invite friends

-
-
-

Invite friends coming soon...

-
-
-
- <%= previous_setting("Feedback", feedback_path) %> -
-
diff --git a/app/views/settings/_nav.html.erb b/app/views/settings/_nav.html.erb index dda0e9db..3ed3c58b 100644 --- a/app/views/settings/_nav.html.erb +++ b/app/views/settings/_nav.html.erb @@ -20,15 +20,6 @@
  • <%= sidebar_link_to t(".preferences_label"), settings_preferences_path, icon: "bolt" %>
  • -
  • - <%= sidebar_link_to t(".notifications_label"), settings_notifications_path, icon: "bell-dot" %> -
  • -
  • - <%= sidebar_link_to t(".security_label"), settings_security_path, icon: "shield-check" %> -
  • -
  • - <%= sidebar_link_to t(".billing_label"), settings_billing_path, icon: "circle-dollar-sign" %> -
  • <% if self_hosted? %>
  • <%= sidebar_link_to t(".self_hosting_label"), settings_hosting_path, icon: "database" %> @@ -55,9 +46,6 @@
  • <%= sidebar_link_to t(".merchants_label"), merchants_path, icon: "store" %>
  • -
  • - <%= sidebar_link_to t(".rules_label"), rules_transactions_path, icon: "list-checks" %> -
  • <%= sidebar_link_to t(".imports_label"), imports_path, icon: "download" %>
  • @@ -72,7 +60,6 @@
  • <%= sidebar_link_to t(".whats_new_label"), changelog_path, icon: "box" %> <%= sidebar_link_to t(".feedback_label"), feedback_path, icon: "megaphone" %> - <%= sidebar_link_to t(".invite_label"), invites_path, icon: "gift" %>
  • diff --git a/app/views/settings/billings/show.html.erb b/app/views/settings/billings/show.html.erb deleted file mode 100644 index 62f0a19f..00000000 --- a/app/views/settings/billings/show.html.erb +++ /dev/null @@ -1,19 +0,0 @@ -<% content_for :sidebar do %> - <%= render "settings/nav" %> -<% end %> -
    -

    Billing

    -
    -
    -

    Billing settings coming soon...

    -
    -
    -
    - <%= previous_setting("Security", settings_security_path) %> - <% if self_hosted? %> - <%= next_setting("Self-Hosting", settings_hosting_path) %> - <% else %> - <%= next_setting("Accounts", accounts_path) %> - <% end %> -
    -
    diff --git a/app/views/settings/hostings/show.html.erb b/app/views/settings/hostings/show.html.erb index 4b9dff76..b785a757 100644 --- a/app/views/settings/hostings/show.html.erb +++ b/app/views/settings/hostings/show.html.erb @@ -1,6 +1,7 @@ <% content_for :sidebar do %> <%= render "settings/nav" %> <% end %> +

    <%= t(".page_title") %>

    <%= settings_section title: t(".general_settings_title") do %> @@ -17,8 +18,8 @@ <%= t(".upgrades.manual.title") %>
    - <%= t(".upgrades.manual.description") %> - + <%= t(".upgrades.manual.description") %> + <% end %>
    @@ -27,8 +28,8 @@ <%= t(".upgrades.latest_release.title") %>
    - <%= t(".upgrades.latest_release.description") %> - + <%= t(".upgrades.latest_release.description") %> + <% end %>
    @@ -37,8 +38,8 @@ <%= t(".upgrades.latest_commit.title") %>
    - <%= t(".upgrades.latest_commit.description") %> - + <%= t(".upgrades.latest_commit.description") %> + <% end %>
    @@ -82,8 +83,5 @@ <% end %> <% end %> -
    - <%= previous_setting("Billing", settings_billing_path) %> - <%= next_setting("Accounts", accounts_path) %> -
    + <%= settings_nav_footer %> diff --git a/app/views/settings/notifications/show.html.erb b/app/views/settings/notifications/show.html.erb deleted file mode 100644 index 3a217fc6..00000000 --- a/app/views/settings/notifications/show.html.erb +++ /dev/null @@ -1,15 +0,0 @@ -<% content_for :sidebar do %> - <%= render "settings/nav" %> -<% end %> -
    -

    Notifications

    -
    -
    -

    Notifications coming soon...

    -
    -
    -
    - <%= previous_setting("Preferences", settings_preferences_path) %> - <%= next_setting("Security", settings_security_path) %> -
    -
    diff --git a/app/views/settings/preferences/show.html.erb b/app/views/settings/preferences/show.html.erb index 0a6609ca..7230cc50 100644 --- a/app/views/settings/preferences/show.html.erb +++ b/app/views/settings/preferences/show.html.erb @@ -1,6 +1,7 @@ <% content_for :sidebar do %> <%= render "settings/nav" %> <% end %> +

    <%= t(".page_title") %>

    <%= settings_section title: t(".general_title"), subtitle: t(".general_subtitle") do %> @@ -39,8 +40,6 @@ <% end %>
    <% end %> -
    - <%= previous_setting("Account", settings_profile_path) %> - <%= next_setting("Notifications", settings_notifications_path) %> -
    + + <%= settings_nav_footer %> diff --git a/app/views/settings/profiles/show.html.erb b/app/views/settings/profiles/show.html.erb index edcab295..b2eda05c 100644 --- a/app/views/settings/profiles/show.html.erb +++ b/app/views/settings/profiles/show.html.erb @@ -89,7 +89,6 @@ <% end %> -
    - <%= next_setting("Preferences", settings_preferences_path) %> -
    + + <%= settings_nav_footer %> diff --git a/app/views/settings/securities/show.html.erb b/app/views/settings/securities/show.html.erb deleted file mode 100644 index 38fb8db5..00000000 --- a/app/views/settings/securities/show.html.erb +++ /dev/null @@ -1,15 +0,0 @@ -<% content_for :sidebar do %> - <%= render "settings/nav" %> -<% end %> -
    -

    Security

    -
    -
    -

    Security settings coming soon...

    -
    -
    -
    - <%= previous_setting("Notifications", settings_notifications_path) %> - <%= next_setting("Billing", settings_billing_path) %> -
    -
    diff --git a/app/views/tags/index.html.erb b/app/views/tags/index.html.erb index 610939bf..5ba44963 100644 --- a/app/views/tags/index.html.erb +++ b/app/views/tags/index.html.erb @@ -40,8 +40,5 @@ <% end %> - + <%= settings_nav_footer %> diff --git a/config/locales/views/settings/en.yml b/config/locales/views/settings/en.yml index b1b9d267..5484cf82 100644 --- a/config/locales/views/settings/en.yml +++ b/config/locales/views/settings/en.yml @@ -51,23 +51,18 @@ en: success: Settings updated successfully. nav: accounts_label: Accounts - billing_label: Billing categories_label: Categories feedback_label: Feedback general_section_title: General imports_label: Imports - invite_label: Invite friends merchants_label: Merchants - notifications_label: Notifications other_section_title: More preferences_label: Preferences profile_label: Account - rules_label: Rules - security_label: Security - self_hosting_label: Self-Hosting + self_hosting_label: Self hosting tags_label: Tags transactions_section_title: Transactions - whats_new_label: What's New + whats_new_label: What's new nav_link_large: next: Next previous: Back diff --git a/config/routes.rb b/config/routes.rb index c6eff485..63380659 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,7 +3,6 @@ Rails.application.routes.draw do get "changelog" => "pages#changelog", as: :changelog get "feedback" => "pages#feedback", as: :feedback - get "invites" => "pages#invites", as: :invites resource :registration resource :session @@ -17,12 +16,9 @@ Rails.application.routes.draw do namespace :settings do resource :profile, only: %i[show update destroy] resource :preferences, only: %i[show update] - resource :notifications, only: %i[show update] - resource :billing, only: %i[show update] resource :hosting, only: %i[show update] do post :send_test_email, on: :collection end - resource :security, only: %i[show update] end resources :imports, except: :show do @@ -58,10 +54,6 @@ Rails.application.routes.draw do namespace :account do resources :transfers, only: %i[new create destroy] - - namespace :transaction do - resources :rules, only: %i[index] - end end resources :accounts do diff --git a/test/controllers/settings/billings_controller_test.rb b/test/controllers/settings/billings_controller_test.rb deleted file mode 100644 index e69de29b..00000000 diff --git a/test/controllers/settings/notifications_controller_test.rb b/test/controllers/settings/notifications_controller_test.rb deleted file mode 100644 index bbd63ffb..00000000 --- a/test/controllers/settings/notifications_controller_test.rb +++ /dev/null @@ -1,11 +0,0 @@ -require "test_helper" - -class Settings::NotificationsControllerTest < ActionDispatch::IntegrationTest - setup do - sign_in users(:family_admin) - end - test "get" do - get settings_notifications_url - assert_response :success - end -end diff --git a/test/controllers/settings/securities_controller_test.rb b/test/controllers/settings/securities_controller_test.rb deleted file mode 100644 index eb5cc481..00000000 --- a/test/controllers/settings/securities_controller_test.rb +++ /dev/null @@ -1,11 +0,0 @@ -require "test_helper" - -class Settings::SecuritiesControllerTest < ActionDispatch::IntegrationTest - setup do - sign_in users(:family_admin) - end - test "get" do - get settings_security_url - assert_response :success - end -end diff --git a/test/system/settings_test.rb b/test/system/settings_test.rb index d090b848..07a9434b 100644 --- a/test/system/settings_test.rb +++ b/test/system/settings_test.rb @@ -5,20 +5,15 @@ class SettingsTest < ApplicationSystemTestCase sign_in @user = users(:family_admin) @settings_links = [ - [ "Account", "Account", settings_profile_path ], - [ "Preferences", "Preferences", settings_preferences_path ], - [ "Notifications", "Notifications", settings_notifications_path ], - [ "Security", "Security", settings_security_path ], - [ "Billing", "Billing", settings_billing_path ], - [ "Accounts", "Accounts", accounts_path ], - [ "Tags", "Tags", tags_path ], - [ "Categories", "Categories", categories_path ], - [ "Merchants", "Merchants", merchants_path ], - [ "Rules", "Rules", rules_transactions_path ], - [ "Imports", "Imports", imports_path ], - [ "What's New", "What's New", changelog_path ], - [ "Feedback", "Feedback", feedback_path ], - [ "Invite friends", "Invite friends", invites_path ] + [ "Account", settings_profile_path ], + [ "Preferences", settings_preferences_path ], + [ "Accounts", accounts_path ], + [ "Tags", tags_path ], + [ "Categories", categories_path ], + [ "Merchants", merchants_path ], + [ "Imports", imports_path ], + [ "What's new", changelog_path ], + [ "Feedback", feedback_path ] ] end @@ -26,6 +21,12 @@ class SettingsTest < ApplicationSystemTestCase open_settings_from_sidebar assert_selector "h1", text: "Account" assert_current_path settings_profile_path + + @settings_links.each do |name, path| + click_link name + assert_selector "h1", text: name + assert_current_path path + end end private