Merge pull request #3646 from betagouv/add-administration-contact-to-commencer-help

Ajout des contacts administrations au menu Aide des pages /commencer
This commit is contained in:
LeSim 2019-03-28 11:46:51 +01:00 committed by GitHub
commit 33a5f13f98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 173 additions and 120 deletions

View file

@ -34,6 +34,10 @@ module Users
redirect_to new_user_registration_path
end
def procedure_for_help
Procedure.publiees.find_by(path: params[:path]) || Procedure.brouillons.find_by(path: params[:path])
end
private
def store_user_location!

View file

@ -1,20 +0,0 @@
.dropdown.help-dropdown
.button.primary.dropdown-button Aide
.dropdown-content.fade-in-down
%ul.dropdown-items
-# Use the help website
%li
= link_to FAQ_URL, target: "_blank", rel: "noopener" do
%span.icon.help
.dropdown-description
%h4.help-dropdown-title Un problème avec le site ?
%p Trouvez votre réponse dans laide en ligne.
-# Technical contact
%li
= mail_to CONTACT_EMAIL do
%span.icon.mail
.dropdown-description
%h4.help-dropdown-title Contact technique
%p Envoyez nous un message à #{CONTACT_EMAIL}.

View file

@ -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

View file

@ -1,6 +1,7 @@
-# We can't use &. because the controller may not implement #nav_bar_profile
- nav_bar_profile = controller.try(:nav_bar_profile)
- nav_bar_profile = controller.try(:nav_bar_profile) || :guest
- dossier = controller.try(:dossier_for_help)
- procedure = controller.try(:procedure_for_help)
.new-header{ class: current_page?(root_path) ? nil : "new-header-with-border" }
.header-inner-content
@ -46,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
@ -88,9 +58,14 @@
%li
.header-help
- if nav_bar_profile == :user && dossier.present?
= render partial: 'users/dossier_help_dropdown', locals: { dossier: dossier }
- 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 == :gestionnaire
= render partial: 'gestionnaires/help_dropdown'
= render partial: 'shared/help/help_dropdown_gestionnaire'
- else
= link_to 'Aide', FAQ_URL, class: "button primary"
= render partial: 'shared/help/help_button'

View file

@ -0,0 +1 @@
= link_to 'Aide', FAQ_URL, class: 'button primary'

View file

@ -0,0 +1,14 @@
.dropdown.help-dropdown
.button.primary.dropdown-button Aide
.dropdown-content.fade-in-down
%ul.dropdown-items
- title = dossier.brouillon? ? "Besoin daide pour remplir votre dossier ?" : "Une question sur votre dossier ?"
- if dossier.messagerie_available?
= render partial: 'shared/help/dropdown_items/messagerie_item',
locals: { dossier: dossier, title: title }
- elsif dossier.procedure.service.present?
= render partial: 'shared/help/dropdown_items/service_item',
locals: { service: dossier.procedure.service, title: title }
= render partial: 'shared/help/dropdown_items/faq_item'

View file

@ -0,0 +1,6 @@
.dropdown.help-dropdown
.button.primary.dropdown-button Aide
.dropdown-content.fade-in-down
%ul.dropdown-items
= render partial: 'shared/help/dropdown_items/faq_item'
= render partial: 'shared/help/dropdown_items/email_item'

View file

@ -0,0 +1,9 @@
.dropdown.help-dropdown
.button.primary.dropdown-button Aide
.dropdown-content.fade-in-down
%ul.dropdown-items
- if procedure.service.present?
= render partial: 'shared/help/dropdown_items/service_item',
locals: { service: procedure.service, title: "Une question sur cette démarche ?" }
= render partial: 'shared/help/dropdown_items/faq_item'

View file

@ -0,0 +1,6 @@
%li
= mail_to CONTACT_EMAIL do
%span.icon.mail
.dropdown-description
%h4.help-dropdown-title Contact technique
%p Envoyez nous un message à #{CONTACT_EMAIL}.

View file

@ -0,0 +1,6 @@
%li
= link_to FAQ_URL, target: "_blank", rel: "noopener" do
%span.icon.help
.dropdown-description
%h4.help-dropdown-title Un problème avec le site ?
%p Trouvez votre réponse dans laide en ligne.

View file

@ -0,0 +1,6 @@
%li
= link_to messagerie_dossier_path(dossier) do
%span.icon.mail
.dropdown-description
%h4.help-dropdown-title= title
%p Envoyez directement un message à linstructeur.

View file

@ -0,0 +1,15 @@
%li.help-dropdown-service
%span.icon.person
.dropdown-description
%h4.help-dropdown-title= title
.help-dropdown-service-action
%p Contactez directement ladministration :
%p.help-dropdown-service-item
%span.icon.small.mail
= link_to service.email, "mailto:#{service.email}"
%p.help-dropdown-service-item
%span.icon.small.phone
= link_to service.telephone, "tel:#{service.telephone}"
%p.help-dropdown-service-item
%span.icon.small.clock
= service.horaires

View file

@ -1,42 +0,0 @@
.dropdown.help-dropdown
.button.primary.dropdown-button Aide
.dropdown-content.fade-in-down
%ul.dropdown-items
- title = dossier.brouillon? ? "Besoin daide pour remplir votre dossier ?" : "Une question sur votre dossier ?"
- if dossier.messagerie_available?
-# Contact the administration using the messagerie
%li
= link_to messagerie_dossier_path(dossier) do
%span.icon.mail
.dropdown-description
%h4.help-dropdown-title= title
%p Envoyez directement un message à linstructeur.
- elsif dossier.procedure.service.present?
- service = dossier.procedure.service
-# Contact the administration using email or phone
%li.help-dropdown-service
%span.icon.person
.dropdown-description
%h4.help-dropdown-title= title
.help-dropdown-service-action
%p Contactez directement ladministration :
%p.help-dropdown-service-item
%span.icon.small.mail
= link_to service.email, "mailto:#{service.email}"
%p.help-dropdown-service-item
%span.icon.small.phone
= link_to service.telephone, "tel:#{service.telephone}"
%p.help-dropdown-service-item
%span.icon.small.clock
= service.horaires
-# Use the help website
%li
= link_to FAQ_URL, target: "_blank", rel: "noopener" do
%span.icon.help
.dropdown-description
%h4.help-dropdown-title Un problème avec le site ?
%p Trouvez votre réponse dans laide en ligne.

View file

@ -8,6 +8,24 @@ feature 'Getting help:' do
end
end
context 'on pages related to a procedure' do
let(:procedure) { create(:procedure, :published, :with_service) }
scenario 'a Help menu provides administration contacts and a link to the FAQ' do
visit commencer_path(path: procedure.path)
within('.new-header') do
expect(page).to have_help_menu
end
within('.help-dropdown') do
expect(page).to have_content(procedure.service.email)
expect(page).to have_content(procedure.service.telephone)
expect(page).to have_link(nil, href: FAQ_URL)
end
end
end
context 'as a signed-in user' do
let(:user) { create(:user) }
let(:procedure) { create(:procedure, :with_service) }

View file

@ -1,14 +1,37 @@
require 'spec_helper'
describe 'layouts/_new_header.html.haml', type: :view do
describe 'logo link' do
before do
if user
sign_in user
allow(controller).to receive(:nav_bar_profile).and_return(profile)
render
end
end
subject { rendered }
subject { render }
context 'when rendering without context' do
let(:user) { nil }
let(:profile) { nil }
it { is_expected.to have_css("a.header-logo[href=\"#{root_path}\"]") }
it 'displays the Help link' do
expect(subject).to have_link('Aide', href: FAQ_URL)
end
context 'when on a procedure page' do
let(:procedure) { create(:procedure, :with_service) }
before do
allow(controller).to receive(:procedure_for_help).and_return(procedure)
end
it 'displays the Help dropdown menu' do
expect(subject).to have_css(".help-dropdown")
end
end
end
context 'when rendering for user' do
let(:user) { create(:user) }
@ -29,8 +52,7 @@ describe 'layouts/_new_header.html.haml', type: :view do
it { is_expected.to have_css("a.header-logo[href=\"#{gestionnaire_procedures_path}\"]") }
it 'displays the Help dropdown menu' do
expect(rendered).to have_css(".help-dropdown")
end
expect(subject).to have_css(".help-dropdown")
end
end
end