From 5cdf127ad19cb0aa2f6c75cfb99cc556fb1bdc6f Mon Sep 17 00:00:00 2001 From: Rasmus Kjellberg <2277443+kjellberg@users.noreply.github.com> Date: Tue, 16 Jul 2024 23:22:29 +0200 Subject: [PATCH] feat: breadcrumbs --- app/controllers/dashboard_controller.rb | 3 ++- app/controllers/kiqr/accounts_controller.rb | 8 ++++++++ app/controllers/kiqr_controller.rb | 7 +++++++ config/locales/kiqr/en.yml | 4 ++-- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index b5083b3..5803b20 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -1,4 +1,5 @@ -class DashboardController < ApplicationController +class DashboardController < KiqrController def show + add_breadcrumb "Dashboard", dashboard_path end end diff --git a/app/controllers/kiqr/accounts_controller.rb b/app/controllers/kiqr/accounts_controller.rb index 7e5a6ad..86e2ede 100644 --- a/app/controllers/kiqr/accounts_controller.rb +++ b/app/controllers/kiqr/accounts_controller.rb @@ -1,6 +1,7 @@ module Kiqr class AccountsController < KiqrController before_action :ensure_team_and_setup_account, only: %i[edit update] + before_action :setup_breadcrumbs, only: %i[edit update] def new @account = Account.new @@ -19,6 +20,7 @@ def create end def edit + add_breadcrumb "Team settings", edit_account_path(current_account) end def update @@ -53,5 +55,11 @@ def form_method @account.persisted? ? :patch : :post end helper_method :form_method + + def setup_breadcrumbs + return unless current_account.present? + + add_breadcrumb current_account.name, edit_account_path(current_account) + end end end diff --git a/app/controllers/kiqr_controller.rb b/app/controllers/kiqr_controller.rb index f1075c7..46da975 100644 --- a/app/controllers/kiqr_controller.rb +++ b/app/controllers/kiqr_controller.rb @@ -1,6 +1,13 @@ class KiqrController < ApplicationController + before_action :setup_dashboard_breadcrumb + private + # Add the dashboard breadcrumb + def setup_dashboard_breadcrumb + add_breadcrumb helpers.irelia_icon { "fa fa-home" }, dashboard_path + end + # Get the options for the locale form select field def options_for_locale I18n.available_locales.map do |locale| diff --git a/config/locales/kiqr/en.yml b/config/locales/kiqr/en.yml index 12001ca..651c43a 100644 --- a/config/locales/kiqr/en.yml +++ b/config/locales/kiqr/en.yml @@ -25,8 +25,8 @@ en: title: "Create a new team account" description: "Complete the form below to create a new team account" edit: - title: "Profile settings" - description: "Edit your account profile." + title: "Team settings" + description: "Edit your team's profile." select: title: "Select account" description: "Select a team account to manage."