mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-19 13:19:39 +02:00
Since the very first 0.1.0-alpha.1 release, we've been moving quickly to add new features to the Maybe app. In doing so, some parts of the codebase have become outdated, unnecessary, or overly-complex as a natural result of this feature prioritization. Now that "core" Maybe is complete, we're moving into a second phase of development where we'll be working hard to improve the accuracy of existing features and build additional features on top of "core". This PR is a quick overhaul of the existing codebase aimed to: - Establish the brand new and simplified dashboard view (pictured above) - Establish and move towards the conventions introduced in Cursor rules and project design overview #1788 - Consolidate layouts and improve the performance of layout queries - Organize the core models of the Maybe domain (i.e. Account::Entry, Account::Transaction, etc.) and break out specific traits of each model into dedicated concerns for better readability - Remove stale / dead code from codebase - Remove overly complex code paths in favor of simpler ones
48 lines
2.2 KiB
Ruby
48 lines
2.2 KiB
Ruby
module SettingsHelper
|
|
SETTINGS_ORDER = [
|
|
{ name: I18n.t("settings.settings_nav.profile_label"), path: :settings_profile_path },
|
|
{ name: I18n.t("settings.settings_nav.preferences_label"), path: :settings_preferences_path },
|
|
{ name: I18n.t("settings.settings_nav.security_label"), path: :settings_security_path },
|
|
{ name: I18n.t("settings.settings_nav.self_hosting_label"), path: :settings_hosting_path, condition: :self_hosted? },
|
|
{ name: I18n.t("settings.settings_nav.billing_label"), path: :settings_billing_path },
|
|
{ name: I18n.t("settings.settings_nav.accounts_label"), path: :accounts_path },
|
|
{ name: I18n.t("settings.settings_nav.imports_label"), path: :imports_path },
|
|
{ name: I18n.t("settings.settings_nav.tags_label"), path: :tags_path },
|
|
{ name: I18n.t("settings.settings_nav.categories_label"), path: :categories_path },
|
|
{ name: I18n.t("settings.settings_nav.merchants_label"), path: :merchants_path },
|
|
{ name: I18n.t("settings.settings_nav.whats_new_label"), path: :changelog_path },
|
|
{ name: I18n.t("settings.settings_nav.feedback_label"), path: :feedback_path }
|
|
]
|
|
|
|
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/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
|