Skip to content

Commit

Permalink
Merge pull request #10811 from colinux/fix-stats-nav-bar
Browse files Browse the repository at this point in the history
ETQ usager, pas d'erreur sur la page stats quand je viens de la page commencer (à cause de la navbar)
  • Loading branch information
colinux authored Sep 17, 2024
2 parents 3a7faea + 79a1d9b commit 39ebaad
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
10 changes: 10 additions & 0 deletions app/controllers/concerns/nav_bar_profile_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ def fallback_nav_bar_profile

private

def nav_bar_user_or_guest
# when instanciating manually the controller (see below),
# we don't have request and current_user would fail
request && current_user ? :user : :guest
end

# Shared controllers (search, errors, release notes…) don't have specific context
# Simple attempt to try to re-use the profile from the previous page
# so user does'not feel lost.
Expand All @@ -28,6 +34,10 @@ def nav_bar_profile_from_referrer

controller_instance = controller_class.new
controller_instance.try(:nav_bar_profile)
rescue StandardError => e # we don't want broken logic in nav bar profile to fail the request
Sentry.capture_exception(e)

nil
end

# Fallback for shared controllers from user account
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/users/commencer_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ def procedure_for_help
retrieve_procedure
end

def nav_bar_profile
current_user ? :user : :guest
end
def nav_bar_profile = nav_bar_user_or_guest

def closing_details
@procedure = Procedure.find_by(path: params[:path])
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/users/statistiques_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

module Users
class StatistiquesController < ApplicationController
def nav_bar_profile = nav_bar_user_or_guest

def statistiques
@procedure = procedure
return procedure_not_found if @procedure.blank? || @procedure.brouillon?
Expand Down

0 comments on commit 39ebaad

Please sign in to comment.