demarches-normaliennes/app/views/layouts/_header.haml

92 lines
5 KiB
Text
Raw Normal View History

-# We can't use &. or as helper methods because the controllers from view specs does not implement these methods
- nav_bar_profile = controller.try(:nav_bar_profile) || controller.try(:fallback_nav_bar_profile) || :guest
- dossier = controller.try(:dossier_for_help)
- procedure = controller.try(:procedure_for_help)
- is_instructeur_context = nav_bar_profile == :instructeur && instructeur_signed_in?
- is_administrateur_context = nav_bar_profile == :administrateur && administrateur_signed_in?
- is_expert_context = nav_bar_profile == :expert && expert_signed_in?
- is_user_context = nav_bar_profile == :user
- is_search_enabled = [params[:controller] == 'recherche', is_instructeur_context, is_expert_context, is_user_context && current_user.dossiers.count].any?
%header{ class: ["fr-header", content_for?(:notice_info) && "fr-header__with-notice-info"], role: "banner", "data-controller": "dsfr-header" }
%nav{ :role => "navigation", "aria-label" => t('layouts.header.main_menu') }
.fr-header__body
.fr-container
.fr-header__body-row
.fr-header__brand.fr-enlarge-link
.fr-header__brand-top
.fr-header__logo
%p.fr-logo{ lang: "fr" }
République
= succeed "Française" do
%br/
.fr-header__navbar
- if is_search_enabled
%button.fr-btn--search.fr-btn{ "aria-controls" => "search-modal", "data-fr-opened" => "false", :title => t('views.users.dossiers.search.search_file') }= t('views.users.dossiers.search.search_file')
%button#navbar-burger-button.fr-btn--menu.fr-btn{ "aria-controls" => "modal-header__menu", "data-fr-opened" => "false", title: "Menu" } Menu
.fr-header__service
- root_profile_link, root_profile_libelle = root_path_info_for_profile(nav_bar_profile)
= link_to root_profile_link, title: "#{root_profile_libelle} — #{Current.application_name}" do
%span.fr-header__service-title{ lang: "fr" }= Current.application_name
.fr-header__tools
.fr-header__tools-links.relative
%ul.fr-btns-group.flex.align-center
- if instructeur_signed_in? || user_signed_in?
%li
= render partial: 'layouts/account_dropdown', locals: { nav_bar_profile: nav_bar_profile, dossier: dossier }
- elsif (request.path != new_user_session_path && request.path !=agent_connect_path)
- if request.path == new_user_registration_path
%li.fr-hidden-sm.fr-unhidden-lg.fr-link--sm.fr-mb-2w.fr-mr-1v= t('views.shared.account.already_user_question')
%li= link_to 'Agent', agent_connect_path, class: "fr-btn fr-btn--tertiary fr-icon-government-fill fr-btn--icon-left"
%li= link_to t('views.shared.account.signin'), new_user_session_path, class: "fr-btn fr-btn--tertiary fr-icon-account-circle-fill fr-btn--icon-left"
%li
- if dossier.present? && nav_bar_profile == :user
= render partial: 'shared/help/help_dropdown_dossier', locals: { dossier: dossier }
- elsif procedure.present? && (nav_bar_profile == :user || nav_bar_profile == :guest)
= render partial: 'shared/help/help_dropdown_procedure', locals: { procedure: procedure }
- elsif nav_bar_profile == :instructeur
= render partial: 'shared/help/help_dropdown_instructeur'
- else
-# NB: on mobile in order to have links correctly aligned, we need a left icon #
2024-06-18 14:39:08 +02:00
= link_to t('help'), t("links.common.faq.url"), class: 'fr-btn dropdown-button'
- if localization_enabled?
%li= render partial: 'layouts/locale_dropdown'
- if is_instructeur_context
= render partial: 'layouts/search_dossiers_form', locals: { context: :instructeur }
- elsif is_expert_context
= render partial: 'layouts/search_dossiers_form', locals: { context: :expert }
- elsif params[:controller] == 'recherche'
= render partial: 'layouts/search_dossiers_form'
= render SwitchDomainBannerComponent.new(user: current_user)
#modal-header__menu.fr-header__menu.fr-modal{ "aria-labelledby": "navbar-burger-button" }
.fr-container
%button.fr-btn--close.fr-btn{ "aria-controls" => "modal-header__menu", title: t('close_modal', scope: [:layouts, :header]) }= t('close_modal', scope: [:layouts, :header])
.fr-header__menu-links
-# populated by dsfr js
- if content_for?(:main_navigation)
= yield(:main_navigation)
- elsif is_administrateur_context
= render 'administrateurs/main_navigation'
- elsif is_instructeur_context || is_expert_context
= render MainNavigation::InstructeurExpertNavigationComponent.new
- elsif is_user_context
= render 'users/main_navigation'
= yield(:notice_info)