diff --git a/app/components/procedure/card/api_entreprise_component/api_entreprise_component.fr.yml b/app/components/procedure/card/api_entreprise_component/api_entreprise_component.fr.yml index 688cb12c0..1dc20806f 100644 --- a/app/components/procedure/card/api_entreprise_component/api_entreprise_component.fr.yml +++ b/app/components/procedure/card/api_entreprise_component/api_entreprise_component.fr.yml @@ -1,3 +1,3 @@ --- fr: - title: Jeton Entreprise + title: Jeton API Entreprise diff --git a/app/components/procedure/card/api_entreprise_component/api_entreprise_component.html.haml b/app/components/procedure/card/api_entreprise_component/api_entreprise_component.html.haml index 32797f8bd..39fdeb27f 100644 --- a/app/components/procedure/card/api_entreprise_component/api_entreprise_component.html.haml +++ b/app/components/procedure/card/api_entreprise_component/api_entreprise_component.html.haml @@ -10,5 +10,5 @@ %p.fr-badge.fr-badge--info À configurer %div %h3.fr-h6.fr-mt-10v= t('.title') - %p.fr-tile-subtitle Configurer le jeton API entreprise + %p.fr-tile-subtitle Configurer le jeton API Entreprise %p.fr-btn.fr-btn--tertiary= t('views.shared.actions.edit') diff --git a/app/components/procedure/errors_summary.rb b/app/components/procedure/errors_summary.rb index 6eb065052..ff1dfc8aa 100644 --- a/app/components/procedure/errors_summary.rb +++ b/app/components/procedure/errors_summary.rb @@ -47,8 +47,6 @@ class Procedure::ErrorsSummary < ApplicationComponent when :initiated_mail, :received_mail, :closed_mail, :refused_mail, :without_continuation_mail, :re_instructed_mail klass = "Mails::#{error.attribute.to_s.classify}".constantize edit_admin_procedure_mail_template_path(@procedure, klass.const_get(:SLUG)) - when :api_entreprise_token - jeton_admin_procedure_path(@procedure) end end diff --git a/app/models/concerns/api_entreprise_token_concern.rb b/app/models/concerns/api_entreprise_token_concern.rb index debb559c6..ad1d0a41e 100644 --- a/app/models/concerns/api_entreprise_token_concern.rb +++ b/app/models/concerns/api_entreprise_token_concern.rb @@ -7,7 +7,6 @@ module APIEntrepriseTokenConcern included do validates :api_entreprise_token, jwt_token: true, allow_blank: true - validate :api_entreprise_token_expiration_valid?, on: [:publication] before_save :set_api_entreprise_token_expires_at, if: :will_save_change_to_api_entreprise_token? @@ -19,12 +18,6 @@ module APIEntrepriseTokenConcern self[:api_entreprise_token].presence || Rails.application.secrets.api_entreprise[:key] end - def api_entreprise_token_expiration_valid? - if api_entreprise_token_expired_or_expires_soon? - errors.add(:api_entreprise_token, "expiré ou expirant bientôt") - end - end - def api_entreprise_token_expired? APIEntrepriseToken.new(api_entreprise_token).expired? end diff --git a/app/views/administrateurs/_breadcrumbs.html.haml b/app/views/administrateurs/_breadcrumbs.html.haml index 41a20952a..9264a128e 100644 --- a/app/views/administrateurs/_breadcrumbs.html.haml +++ b/app/views/administrateurs/_breadcrumbs.html.haml @@ -30,7 +30,7 @@ .flex.fr-mt-1w - if @procedure.api_entreprise_token_expired_or_expires_soon? - %span.fr-badge.fr-badge--warning.fr-mr-1w + %span.fr-badge.fr-badge--error.fr-mr-1w = t('to_modify', scope: [:layouts, :breadcrumb]) %span.fr-badge.fr-badge--success.fr-mr-1w diff --git a/app/views/administrateurs/procedures/_procedures_list.html.haml b/app/views/administrateurs/procedures/_procedures_list.html.haml index dcf4d7c9c..99eecd912 100644 --- a/app/views/administrateurs/procedures/_procedures_list.html.haml +++ b/app/views/administrateurs/procedures/_procedures_list.html.haml @@ -61,7 +61,7 @@ - elsif procedure.publiee? - if procedure.api_entreprise_token_expired_or_expires_soon? - %span.fr-badge.fr-badge--sm.fr-badge--warning + %span.fr-badge.fr-badge--sm.fr-badge--error = t('to_modify', scope: [:layouts, :breadcrumb]) %span.fr-badge.fr-badge--sm.fr-badge--success = t('published', scope: [:layouts, :breadcrumb]) diff --git a/app/views/administrateurs/procedures/jeton.html.haml b/app/views/administrateurs/procedures/jeton.html.haml index 862a989a0..f51fbaba7 100644 --- a/app/views/administrateurs/procedures/jeton.html.haml +++ b/app/views/administrateurs/procedures/jeton.html.haml @@ -1,10 +1,10 @@ = render partial: 'administrateurs/breadcrumbs', locals: { steps: [['Démarches', admin_procedures_back_path(@procedure)], [@procedure.libelle.truncate_words(10), admin_procedure_path(@procedure)], - ['Jeton Entreprise']] } + ['Jeton API Entreprise']] } .fr-container - %h1.fr-h2 Jeton Entreprise + %h1.fr-h2 Jeton API Entreprise = form_with model: @procedure, url: url_for({ controller: 'administrateurs/procedures', action: :update_jeton }) do |f| .fr-container @@ -14,14 +14,16 @@ Démarches Simplifiées utilise = link_to 'API Entreprise', "https://entreprise.api.gouv.fr/" qui permet de récupérer les informations administratives des entreprises et des associations. - Si votre démarche nécessite des autorisations spécifiques que Démarches Simplifiées n’a pas par défaut, merci de renseigner ici le jeton - = link_to 'API Entreprise', "https://api.gouv.fr/les-api/api-entreprise/demande-acces" + Si votre démarche nécessite des autorisations spécifiques que Démarches Simplifiées n’a pas par défaut, merci de renseigner ci dessous + %strong le jeton API Entreprise propre à votre démarche. + %p + Si besoin, vous pouvez demander une habilitation API Entreprise sur le site + = link_to 'api.gouv.fr.', "https://api.gouv.fr/les-api/api-entreprise/demande-acces" + = render partial: 'administrateurs/procedures/api_entreprise_token_expiration_alert', locals: { procedure: @procedure } - .fr-input-group - = f.label :api_entreprise_token, "Jeton", class: 'fr-label' - = f.password_field :api_entreprise_token, value: @procedure.read_attribute(:api_entreprise_token), class: 'fr-input' + = render Dsfr::InputComponent.new(form: f, attribute: :api_entreprise_token, input_type: :password_field, required: false, opts: { value: @procedure.read_attribute(:api_entreprise_token)}) = render Procedure::FixedFooterComponent.new(procedure: @procedure, form: f) diff --git a/app/views/administrateurs/procedures/show.html.haml b/app/views/administrateurs/procedures/show.html.haml index 8cdfc01c2..4724df9ff 100644 --- a/app/views/administrateurs/procedures/show.html.haml +++ b/app/views/administrateurs/procedures/show.html.haml @@ -27,6 +27,14 @@ = link_to 'Clore', admin_procedure_close_path(procedure_id: @procedure.id), class: 'fr-btn fr-btn--tertiary fr-btn--icon-left fr-icon-calendar-close-fill', id: "close-procedure-link" .fr-container + - if @procedure.api_entreprise_token_expired_or_expires_soon? + = render Dsfr::AlertComponent.new(state: :error, title: t(:technical_issues, scope: [:administrateurs, :procedures]), extra_class_names: 'fr-mb-2w') do |c| + - c.with_body do + %ul.fr-mb-0 + %li + = link_to "Jeton API Entreprise", jeton_admin_procedure_path(@procedure), class: 'error-anchor' + est expiré ou va expirer prochainement + - if @procedure.draft_changed? = render Dsfr::CalloutComponent.new(title: t(:has_changes, scope: [:administrateurs, :revision_changes]), icon: "fr-fi-information-line") do |c| - c.with_body do diff --git a/config/locales/models/procedure/en.yml b/config/locales/models/procedure/en.yml index 489d0baa0..98d27a1f4 100644 --- a/config/locales/models/procedure/en.yml +++ b/config/locales/models/procedure/en.yml @@ -7,6 +7,7 @@ en: attributes: procedure: hints: + api_entreprise_token: 'For example: eyJhbGciOiJIUzI1NiJ9.eyJ1...' description: Describe in a few lines the context, the aim etc. description_target_audience: Describe in a few lines the final recipients of the process, the eligibility criteria if there are any, the prerequisites, etc. description_pj: Describe the required attachments list if there is any diff --git a/config/locales/models/procedure/fr.yml b/config/locales/models/procedure/fr.yml index 6a020049f..9cc851e1f 100644 --- a/config/locales/models/procedure/fr.yml +++ b/config/locales/models/procedure/fr.yml @@ -7,6 +7,7 @@ fr: attributes: procedure: hints: + api_entreprise_token: 'Exemple : eyJhbGciOiJIUzI1NiJ9.eyJ1...' description: Décrivez en quelques lignes le contexte, la finalité, etc. description_target_audience: Décrivez en quelques lignes les destinataires finaux de la démarche, les conditions d’éligibilité s’il y en a, les pré-requis, etc. description_pj: Décrivez la liste des pièces jointes à fournir s’il y en a diff --git a/config/locales/views/administrateurs/procedures/en.yml b/config/locales/views/administrateurs/procedures/en.yml index c1776e841..2f471930d 100644 --- a/config/locales/views/administrateurs/procedures/en.yml +++ b/config/locales/views/administrateurs/procedures/en.yml @@ -67,6 +67,7 @@ en: dpd_part_4: How to do ? You can either send him the link to the procedure on test stage by email, or name him "administrator". In any case, publish your approach only after having had his opinion. back_to_procedure: 'Cancel and return to the procedure page' submit: Publish + technical_issues: "Issues are affecting the proper functioning of the process" check_path: path_not_available: owner: This URL is identical to another of your published procedures. If you publish this procedure, the old one will be unpublished and will no longer be accessible to the public. diff --git a/config/locales/views/administrateurs/procedures/fr.yml b/config/locales/views/administrateurs/procedures/fr.yml index f86a93276..036a90daa 100644 --- a/config/locales/views/administrateurs/procedures/fr.yml +++ b/config/locales/views/administrateurs/procedures/fr.yml @@ -67,6 +67,7 @@ fr: dpd_part_4: Comment faire ? Vous pouvez soit lui communiquer par email le lien vers la démarche en test, ou bien le nommer « administrateur ». Dans tous les cas, ne publiez votre démarche qu’après avoir eu son avis. back_to_procedure: 'Annuler et revenir à la page de la démarche' submit: Publier + technical_issues: Des problèmes impactent le bon fonctionnement de la démarche check_path: path_not_available: owner: Cette url est identique à celle d’une autre de vos démarches publiées. Si vous publiez cette démarche, l’ancienne sera dépubliée et ne sera plus accessible au public. diff --git a/spec/components/procedures/errors_summary_spec.rb b/spec/components/procedures/errors_summary_spec.rb index e673244f9..9ff3edadb 100644 --- a/spec/components/procedures/errors_summary_spec.rb +++ b/spec/components/procedures/errors_summary_spec.rb @@ -83,8 +83,7 @@ describe Procedure::ErrorsSummary, type: :component do include Logic let(:validation_context) { :publication } - let(:expired_token) { JWT.encode({ exp: 2.days.ago.to_i }, nil, 'none') } - let(:procedure) { create(:procedure, attestation_template:, initiated_mail:, api_entreprise_token: expired_token) } + let(:procedure) { create(:procedure, attestation_template:, initiated_mail:) } let(:attestation_template) { build(:attestation_template) } let(:initiated_mail) { build(:initiated_mail) } @@ -98,7 +97,6 @@ describe Procedure::ErrorsSummary, type: :component do expect(page).to have_selector("a", text: "Les règles d’inéligibilité") expect(page).to have_selector("a", text: "Le modèle d’attestation") expect(page).to have_selector("a", text: "L’email de notification de passage de dossier en instruction") - expect(page).to have_selector("a", text: "Jeton API Entreprise") expect(page).to have_text("n'est pas valide", count: 2) end end