From 1daf5236956bc2e4640fcd11670e26a0d1656768 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Thu, 28 Mar 2019 11:33:45 +0100 Subject: [PATCH] layout: extract part of the header to a partial --- app/views/layouts/_account_dropdown.haml | 33 ++++++++++++++++++++++++ app/views/layouts/_new_header.haml | 33 +----------------------- 2 files changed, 34 insertions(+), 32 deletions(-) create mode 100644 app/views/layouts/_account_dropdown.haml diff --git a/app/views/layouts/_account_dropdown.haml b/app/views/layouts/_account_dropdown.haml new file mode 100644 index 000000000..4044885c4 --- /dev/null +++ b/app/views/layouts/_account_dropdown.haml @@ -0,0 +1,33 @@ +%span.dropdown.header-menu-opener + %button.button.dropdown-button.header-menu-button + = image_tag "icons/account-circle.svg", title: "Mon compte" + %ul.header-menu.dropdown-content + %li + .menu-item{ title: current_email } + = current_email + - if administration_signed_in? + %li + = link_to manager_root_path, class: "menu-item menu-link" do + = image_tag "icons/super-admin.svg" + Passer en super-admin + - if SwitchDeviseProfileService.new(warden).multiple_devise_profile_connect? + - if user_signed_in? && nav_bar_profile != :user + %li + = link_to dossiers_path, class: "menu-item menu-link" do + = image_tag "icons/switch-profile.svg" + Passer en usager + - if gestionnaire_signed_in? && nav_bar_profile != :gestionnaire + %li + = link_to gestionnaire_procedures_path, class: "menu-item menu-link" do + = image_tag "icons/switch-profile.svg" + Passer en instructeur + - if administrateur_signed_in? && nav_bar_profile != :administrateur + %li + = link_to admin_procedures_path, class: "menu-item menu-link" do + = image_tag "icons/switch-profile.svg" + Passer en administrateur + + %li + = link_to destroy_user_session_path, method: :delete, class: "menu-item menu-link" do + = image_tag "icons/sign-out.svg" + Se déconnecter diff --git a/app/views/layouts/_new_header.haml b/app/views/layouts/_new_header.haml index 2038dbbae..8bb1ca264 100644 --- a/app/views/layouts/_new_header.haml +++ b/app/views/layouts/_new_header.haml @@ -47,39 +47,8 @@ - if gestionnaire_signed_in? || user_signed_in? %li - %span.dropdown.header-menu-opener - %button.button.dropdown-button.header-menu-button - = image_tag "icons/account-circle.svg", title: "Mon compte" - %ul.header-menu.dropdown-content - %li - .menu-item{ title: current_email } - = current_email - - if administration_signed_in? - %li - = link_to manager_root_path, class: "menu-item menu-link" do - = image_tag "icons/super-admin.svg" - Passer en super-admin - - if SwitchDeviseProfileService.new(warden).multiple_devise_profile_connect? - - if user_signed_in? && nav_bar_profile != :user - %li - = link_to dossiers_path, class: "menu-item menu-link" do - = image_tag "icons/switch-profile.svg" - Passer en usager - - if gestionnaire_signed_in? && nav_bar_profile != :gestionnaire - %li - = link_to gestionnaire_procedures_path, class: "menu-item menu-link" do - = image_tag "icons/switch-profile.svg" - Passer en instructeur - - if administrateur_signed_in? && nav_bar_profile != :administrateur - %li - = link_to admin_procedures_path, class: "menu-item menu-link" do - = image_tag "icons/switch-profile.svg" - Passer en administrateur + = render partial: 'layouts/account_dropdown', locals: { nav_bar_profile: nav_bar_profile } - %li - = link_to destroy_user_session_path, method: :delete, class: "menu-item menu-link" do - = image_tag "icons/sign-out.svg" - Se déconnecter - elsif request.path != new_user_session_path - if request.path == new_user_registration_path %li