feat: /commencer alert about draft procedure
This commit is contained in:
parent
28e8c786fa
commit
ba6fdc4748
6 changed files with 98 additions and 3 deletions
21
app/components/procedure_draft_warning_component.rb
Normal file
21
app/components/procedure_draft_warning_component.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ProcedureDraftWarningComponent < ApplicationComponent
|
||||
attr_reader :revision
|
||||
attr_reader :current_administrateur
|
||||
attr_reader :extra_class_names
|
||||
|
||||
def initialize(revision:, current_administrateur:, extra_class_names: nil)
|
||||
@revision = revision
|
||||
@current_administrateur = current_administrateur
|
||||
@extra_class_names = extra_class_names
|
||||
end
|
||||
|
||||
def render?
|
||||
revision.draft?
|
||||
end
|
||||
|
||||
def admin?
|
||||
current_administrateur.present? && revision.procedure.administrateurs.include?(current_administrateur)
|
||||
end
|
||||
end
|
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
en:
|
||||
title: Procedure in testing
|
||||
intro_procedure_brouillon_html: This procedure is currently in <b>testing</b>
|
||||
intro_revision_draft_html: This page allows you to <b>test</b> a new version of the procedure
|
||||
body_general_html: |
|
||||
and this page is reserved for the administration in charge of its deployment.
|
||||
If you start or submit a file, it may be <b>deleted at any time</b> without notice, even if it is accepted later.
|
||||
body_user: |
|
||||
If this link was shared with you, please contact the service in charge of this procedure
|
||||
to obtain the public link for the procedure in order to submit your application.
|
||||
body_admin_procedure_brouillon: Do not share this link with your users. When you publish the procedure, you will access the public link for the procedure to be shared.
|
||||
body_admin_revision_draft: Do not share this link with your users, but rather the public link for the procedure displayed in your administrator dashboard.
|
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
fr:
|
||||
title: Démarche en test
|
||||
intro_procedure_brouillon_html: Cette démarche est actuellement en <b>test</b>
|
||||
intro_revision_draft_html: Cette page permet de <b>tester</b> une nouvelle version de la démarche
|
||||
body_general_html: |
|
||||
et cette page est réservée à l’administration en charge de son déploiement.
|
||||
Si vous commencez ou déposez un dossier, il pourra être <b>supprimé à tout moment</b> et sans préavis, même après avoir été accepté.
|
||||
body_user: |
|
||||
Si ce lien vous a été communiqué, contactez le service en charge de cette démarche
|
||||
pour obtenir le lien public de la démarche afin de déposer votre dossier.
|
||||
body_admin_procedure_brouillon: Ne communiquez pas ce lien à vos usagers. Lorsque vous publierez la démarche, vous accéderez au lien public de la démarche à communiquer.
|
||||
body_admin_revision_draft: Ne communiquez pas ce lien à vos usagers, mais le lien public de la démarche affiché dans votre tableau de bord administrateur.
|
|
@ -0,0 +1,10 @@
|
|||
= render Dsfr::AlertComponent.new(state: :warning, extra_class_names:, title: t(".title")) do |c|
|
||||
- c.with_body do
|
||||
%p
|
||||
= revision.procedure.brouillon? ? t(".intro_procedure_brouillon_html") : t(".intro_revision_draft_html")
|
||||
= t(".body_general_html")
|
||||
|
||||
- if admin?
|
||||
%p= revision.procedure.brouillon? ? t(".body_admin_procedure_brouillon") : t(".body_admin_revision_draft")
|
||||
- else
|
||||
%p= t(".body_user")
|
|
@ -13,7 +13,11 @@
|
|||
#{Current.application_name}
|
||||
%li= link_to t('views.shared.account.already_user'), commencer_sign_in_path(path: @procedure.path, prefill_token: @prefilled_dossier&.prefill_token), class: 'fr-btn fr-btn--secondary'
|
||||
|
||||
= render ProcedureDraftWarningComponent.new(revision: @revision, current_administrateur:, extra_class_names: "fr-mb-2w")
|
||||
|
||||
- else
|
||||
= render ProcedureDraftWarningComponent.new(revision: @revision, current_administrateur:, extra_class_names: "fr-mb-2w")
|
||||
|
||||
- if @prefilled_dossier
|
||||
= render Dsfr::CalloutComponent.new(title: t(".prefilled_draft"), heading_level: 'h2') do |c|
|
||||
- c.with_body do
|
||||
|
|
|
@ -7,10 +7,15 @@ RSpec.describe 'commencer/show', type: :view do
|
|||
let(:drafts) { [] }
|
||||
let(:not_drafts) { [] }
|
||||
let(:preview_dossiers) { dossiers.take(3) }
|
||||
let(:user) { nil }
|
||||
|
||||
before do
|
||||
allow(view).to receive(:current_administrateur).and_return(user&.administrateur)
|
||||
end
|
||||
|
||||
before do
|
||||
assign(:procedure, procedure)
|
||||
assign(:revision, procedure.published_revision)
|
||||
assign(:revision, procedure.active_revision)
|
||||
assign(:dossiers, dossiers)
|
||||
assign(:drafts, drafts)
|
||||
assign(:not_drafts, not_drafts)
|
||||
|
@ -25,8 +30,6 @@ RSpec.describe 'commencer/show', type: :view do
|
|||
subject { render }
|
||||
|
||||
context 'when no user is signed in' do
|
||||
let(:user) { nil }
|
||||
|
||||
it 'renders sign-in and sign-up links' do
|
||||
subject
|
||||
expect(rendered).to have_link('Créer un compte')
|
||||
|
@ -98,4 +101,35 @@ RSpec.describe 'commencer/show', type: :view do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "procedure is draft" do
|
||||
let(:procedure) { create(:procedure, :draft) }
|
||||
let(:user) { create :user }
|
||||
|
||||
it 'renders a warning' do
|
||||
subject
|
||||
expect(rendered).to have_text("Cette démarche est actuellement en test")
|
||||
end
|
||||
|
||||
context "when user is admin" do
|
||||
let(:user) { procedure.administrateurs.first.user }
|
||||
|
||||
it "renders warning about draft" do
|
||||
subject
|
||||
expect(rendered).to have_text("Cette démarche est actuellement en test")
|
||||
expect(rendered).to have_text("Ne communiquez pas ce lien")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "revision is draft" do
|
||||
before {
|
||||
assign(:revision, procedure.draft_revision)
|
||||
}
|
||||
|
||||
it "renders warning about draft" do
|
||||
subject
|
||||
expect(rendered).to have_text("Démarche en test")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue