Merge pull request #9872 from demarches-simplifiees/add-badge-for-role-ldu
ETQ utilisateur avec plusieurs rôles, je m'y retrouve plus facilement
This commit is contained in:
commit
f553f3c408
8 changed files with 34 additions and 5 deletions
|
@ -88,6 +88,7 @@ class ApplicationController < ActionController::Base
|
|||
gestionnaire: current_gestionnaire,
|
||||
administrateur: current_administrateur,
|
||||
instructeur: current_instructeur,
|
||||
expert: current_expert,
|
||||
user: current_user
|
||||
}.compact
|
||||
end
|
||||
|
|
|
@ -16,6 +16,9 @@ class Users::SessionsController < Devise::SessionsController
|
|||
end
|
||||
|
||||
super
|
||||
if current_account.count > 1
|
||||
flash[:notice] = t("devise.sessions.signed_in_multiple_profile", roles: current_account.keys.map { |role| t("layouts.#{role}") }.join(', '))
|
||||
end
|
||||
end
|
||||
|
||||
def reset_link_sent
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
module ReleaseNotesHelper
|
||||
def announce_category_badge(category)
|
||||
color_class = case category.to_sym
|
||||
color_class = color_by_role(category)
|
||||
|
||||
content_tag(:span, ReleaseNote.human_attribute_name("categories.#{category}"), class: "fr-badge #{color_class}")
|
||||
end
|
||||
|
||||
def color_by_role(role)
|
||||
case role.to_sym
|
||||
when :administrateur
|
||||
'fr-badge--blue-cumulus'
|
||||
when :instructeur
|
||||
|
@ -12,8 +18,6 @@ module ReleaseNotesHelper
|
|||
when :api
|
||||
'fr-badge--pink-macaron'
|
||||
end
|
||||
|
||||
content_tag(:span, ReleaseNote.human_attribute_name("categories.#{category}"), class: "fr-badge #{color_class}")
|
||||
end
|
||||
|
||||
def infer_default_announce_categories
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
%nav.fr-translate.fr-nav{ role: "navigation", "aria-label"=> t('menu_aria_label', scope: [:layouts]) }
|
||||
.fr-nav__item
|
||||
%button.account-btn.fr-translate__btn.fr-btn{ "aria-controls" => "account", "aria-expanded" => "false", :title => t('my_account', scope: [:layouts]) }
|
||||
|
||||
= " #{current_email}"
|
||||
%div{ class: "fr-badge fr-badge--sm fr-ml-1w #{color_by_role(nav_bar_profile)}" }
|
||||
= t("layouts.#{nav_bar_profile}")
|
||||
#account.fr-collapse.fr-menu
|
||||
%ul.fr-menu__list.max-content
|
||||
- if multiple_devise_profile_connect?
|
||||
|
|
|
@ -3,3 +3,5 @@ en:
|
|||
passwords:
|
||||
new:
|
||||
request_new_password: Request new password
|
||||
sessions:
|
||||
signed_in_multiple_profile: "You are connected ! You can switch between your multiple profiles : %{roles}."
|
||||
|
|
|
@ -3,3 +3,5 @@ fr:
|
|||
passwords:
|
||||
new:
|
||||
request_new_password: Demander un nouveau mot de passe
|
||||
sessions:
|
||||
signed_in_multiple_profile: "Vous êtes connecté(e) ! Vous pouvez à tout moment alterner entre vos différents profils : %{roles}."
|
||||
|
|
|
@ -36,7 +36,7 @@ describe 'Inviting an expert:' do
|
|||
visit new_user_session_path
|
||||
sign_in_with avis.expert.email, password
|
||||
|
||||
expect(page).to have_content('Connecté(e).')
|
||||
expect(page).to have_content('Vous pouvez à tout moment alterner entre vos différents profils : expert, usager.')
|
||||
expect(page).to have_current_path(expert_all_avis_path)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,6 +12,22 @@ describe 'Signin in:' do
|
|||
|
||||
sign_in_with user.email, password
|
||||
expect(page).to have_current_path dossiers_path
|
||||
expect(page).to have_content('Connecté(e).')
|
||||
expect(page).not_to have_content('Vous pouvez à tout moment alterner')
|
||||
end
|
||||
|
||||
context 'user has multiple profiles' do
|
||||
let!(:instructeur) { create(:instructeur, user: user) }
|
||||
let!(:admin) { create(:administrateur, user: user, instructeur: instructeur) }
|
||||
|
||||
scenario 'he can sign-in and he is notified in flash' do
|
||||
visit root_path
|
||||
click_on 'Se connecter', match: :first
|
||||
|
||||
sign_in_with user.email, password
|
||||
expect(page).to have_current_path admin_procedures_path
|
||||
expect(page).to have_content('Vous êtes connecté(e) ! Vous pouvez à tout moment alterner entre vos différents profils : administrateur, instructeur, usager.')
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'an existing user can lock its account' do
|
||||
|
|
Loading…
Reference in a new issue