Skip to content

Commit

Permalink
display buttons to reopen stages
Browse files Browse the repository at this point in the history
  • Loading branch information
JeSuisUnCaillou committed Jan 21, 2025
1 parent efe94dd commit 6290aeb
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 5 deletions.
18 changes: 18 additions & 0 deletions app/assets/stylesheets/components/reopen_authorizations.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.reopen-stage-buttons-container {
width: 100%;
display: flex;
align-items: flex-start;
}

.reopen-stage-buttons {
flex: 1;
display: flex;
flex-direction: column;
gap: 1rem;
}

.reopen-stage-cancel {
display: flex;
align-items: flex-end;
height: 100%;
}
4 changes: 4 additions & 0 deletions app/models/authorization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ def definition
authorization_request_class.constantize.definition
end

def can_reopen_to_another_stage?
authorization_request.available_classes_for_reopen.count > 1
end

private

def affect_snapshot_documents(request_as_validated)
Expand Down
31 changes: 26 additions & 5 deletions app/views/reopen_authorizations/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,38 @@
<h1 class="fr-modal__title">
<%= t('.title', authorization_name: @authorization.name) %>
</h1>

<p>
<%= t('.disclaimer').html_safe %>
</p>

<% if @authorization.can_reopen_to_another_stage? %>
<div class="fr-alert fr-alert--warning">
<h3 class="fr-alert__title">Vous avez la possibilité de mettre à jour deux versions de cette habilitation</h3>
<p>Cette habilitation existe en version bac à sable et production.</p>
</div>
<% end %>
</div>

<div class="fr-modal__footer">
<div class="fr-btns-group fr-btns-group--right fr-btns-group--inline-reverse fr-btns-group--inline-lg fr-btns-group--icon-left">
<%= link_to t('.cancel'), '#', class: %w(fr-btn fr-btn--secondary), aria: { controls: 'main-modal' } %>
<%= button_to t('.reopen'), url_for(controller: 'reopen_authorizations', action: 'create', authorization_request_id: @authorization.request_id, authorization_id: @authorization.id), class: %w(fr-btn fr-btn--primary fr-icon-success-line fr-btn--icon-left) %>
</div>
<% if @authorization.can_reopen_to_another_stage? %>
<div class="reopen-stage-buttons-container">
<div class="reopen-stage-buttons">
<% @authorization.request.available_classes_for_reopen.each do |authorization_request_class| %>
<%= button_to t(".reopen_to_stage.#{authorization_request_class.definition.stage.type}"), url_for(controller: 'reopen_authorizations', action: 'create', authorization_request_class:, authorization_request_id: @authorization.request_id, authorization_id: @authorization.id), class: "fr-btn fr-btn--primary fr-icon-success-line fr-btn--icon-left reopen-stage-button" %>
<% end %>
</div>

<div class="reopen-stage-cancel">
<%= link_to t('.cancel'), '#', class: %w(fr-btn fr-btn--secondary), aria: { controls: 'main-modal' } %>
</div>
</div>

<% else %>
<div class="fr-btns-group fr-btns-group--right fr-btns-group--inline fr-btns-group--inline-lg fr-btns-group--icon-left">
<%= button_to t('.reopen'), url_for(controller: 'reopen_authorizations', action: 'create', authorization_request_id: @authorization.request_id, authorization_id: @authorization.id), class: %w(fr-btn fr-btn--primary fr-icon-success-line fr-btn--icon-left) %>
<%= link_to t('.cancel'), '#', class: %w(fr-btn fr-btn--secondary), aria: { controls: 'main-modal' } %>
</div>
<% end %>
</div>
</turbo-frame>
</div>
Expand Down
3 changes: 3 additions & 0 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,9 @@ fr:
Votre habilitation restera valide quelque soit l'issue de la demande de mise à jour.
cancel: Annuler
reopen: Mettre à jour l'habilitation
reopen_to_stage:
sandbox: Mettre à jour l'habilitation bac à sable
production: Mettre à jour l'habilitation de production
create:
success:
title: L'habilitation %{name} a bien été réouverte
Expand Down

0 comments on commit 6290aeb

Please sign in to comment.