Skip to content

Commit

Permalink
Move non-form elements on edit user page outside form
Browse files Browse the repository at this point in the history
In recent PRs we've been moving all actions into separate pages,
e.g. #2497, #2509, #2537 & #2540. This means that a bunch of form
elements have been replaced by links to other pages. There's no need for
these links to be rendered within the form.

I'm about to restructure this page as a step on the way to moving it to
use the GOV.UK Design System. Making this change first will make that
easier.

This diff is best viewed with the `--ignore-all-space` option [1].

[1]: https://git-scm.com/docs/diff-options#Documentation/diff-options.txt---ignore-all-space
  • Loading branch information
floehopper committed Dec 5, 2023
1 parent d3622a0 commit 3a6caf3
Showing 1 changed file with 74 additions and 74 deletions.
148 changes: 74 additions & 74 deletions app/views/users/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -40,94 +40,94 @@
</p>
<% end %>

<% if @user.errors.count > 0 %>
<div class="govuk-error-summary alert alert-danger" aria-labelledby="error-summary-title" role="alert" tabindex="-1" data-module="error-summary">
<div class="govuk-error-summary__body">
<ul class="govuk-list govuk-error-summary__list">
<% @user.errors.full_messages.each do |message| %>
<%= content_tag :li, message %>
<% end %>
</ul>
</div>
</div>
<% end %>
<p>
<strong>Name:</strong> <%= @user.name %>
<%= link_to edit_user_name_path(@user) do %>
Change<span class="invisible"> name</span>
<% end %>
</p>

<%= form_for @user, :html => {:class => 'well add-top-margin'} do |f| %>
<p>
<strong>Name:</strong> <%= @user.name %>
<%= link_to edit_user_name_path(@user) do %>
Change<span class="invisible"> name</span>
<% end %>
</p>
<p>
<strong>Email:</strong> <%= @user.email %>
<%= link_to edit_user_email_path(@user) do %>
Change<span class="invisible"> email</span>
<% end %>
</p>

<p>
<strong>Email:</strong> <%= @user.email %>
<%= link_to edit_user_email_path(@user) do %>
Change<span class="invisible"> email</span>
<p>
<strong>Role:</strong> <%= @user.role.humanize %>
<% if policy(User).assign_role? %>
<%= link_to edit_user_role_path(@user) do %>
Change<span class="invisible"> role</span>
<% end %>
</p>
<% end %>
</p>

<p>
<strong>Role:</strong> <%= @user.role.humanize %>
<% if policy(User).assign_role? %>
<%= link_to edit_user_role_path(@user) do %>
Change<span class="invisible"> role</span>
<% end %>
<p>
<strong>Organisation:</strong> <%= @user.organisation.present? ? @user.organisation.name : Organisation::NONE %>
<% if policy(User).assign_organisation? %>
<%= link_to edit_user_organisation_path(@user) do %>
Change<span class="invisible"> organisation</span>
<% end %>
</p>
<% end %>
</p>

<p>
<strong>Organisation:</strong> <%= @user.organisation.present? ? @user.organisation.name : Organisation::NONE %>
<% if policy(User).assign_organisation? %>
<%= link_to edit_user_organisation_path(@user) do %>
Change<span class="invisible"> organisation</span>
<% end %>
<dl>
<dt>Account security</dt>
<dd>
<% if @user.exempt_from_2sv? %>
<p>
The user has been made exempt from 2-step verification for the following reason: <%= @user.reason_for_2sv_exemption %>
<% if policy(@user).exempt_from_two_step_verification? %>
<br>
<%= link_to 'Edit reason or expiry date for 2-step verification exemption', edit_two_step_verification_exemption_path(@user) %>
<% end %>
</p>
<% elsif @user.has_2sv? %>
<p>2-step verification enabled</p>
<p>
<%= link_to 'Reset 2-step verification', edit_user_two_step_verification_reset_path(@user) %>
</p>
<% elsif @user.require_2sv? %>
<p>2-step verification required but not set up</p>
<% else %>
<p>2-step verification not set up</p>
<% end %>
</p>

<dl>
<dt>Account security</dt>
<dd>
<% if @user.exempt_from_2sv? %>
<% unless @user.require_2sv? %>
<% if policy(@user).mandate_2sv? %>
<p>
The user has been made exempt from 2-step verification for the following reason: <%= @user.reason_for_2sv_exemption %>
<% if policy(@user).exempt_from_two_step_verification? %>
<br>
<%= link_to 'Edit reason or expiry date for 2-step verification exemption', edit_two_step_verification_exemption_path(@user) %>
<% end %>
<%= link_to(
"Mandate 2-step verification for this user#{@user.exempt_from_2sv? ? ' (this will remove their exemption)' : nil}",
edit_user_two_step_verification_mandation_path(@user)
) %>
</p>
<% elsif @user.has_2sv? %>
<p>2-step verification enabled</p>
<p>
<%= link_to 'Reset 2-step verification', edit_user_two_step_verification_reset_path(@user) %>
</p>
<% elsif @user.require_2sv? %>
<p>2-step verification required but not set up</p>
<% else %>
<p>2-step verification not set up</p>
<% end %>
<% end %>

<% unless @user.require_2sv? %>
<% if policy(@user).mandate_2sv? %>
<p>
<%= link_to(
"Mandate 2-step verification for this user#{@user.exempt_from_2sv? ? ' (this will remove their exemption)' : nil}",
edit_user_two_step_verification_mandation_path(@user)
) %>
</p>
<% end %>
<% end %>
<% if policy(@user).exempt_from_two_step_verification? && !@user.exempt_from_2sv? %>
<p>
<%= link_to 'Exempt user from 2-step verification', edit_two_step_verification_exemption_path(@user) %>
<br/>
Exempt a user from 2-step verification (requires a reason to be supplied).
</p>
<% end %>
</dd>
</dl>

<% if policy(@user).exempt_from_two_step_verification? && !@user.exempt_from_2sv? %>
<p>
<%= link_to 'Exempt user from 2-step verification', edit_two_step_verification_exemption_path(@user) %>
<br/>
Exempt a user from 2-step verification (requires a reason to be supplied).
</p>
<% end %>
</dd>
</dl>
<% if @user.errors.count > 0 %>
<div class="govuk-error-summary alert alert-danger" aria-labelledby="error-summary-title" role="alert" tabindex="-1" data-module="error-summary">
<div class="govuk-error-summary__body">
<ul class="govuk-list govuk-error-summary__list">
<% @user.errors.full_messages.each do |message| %>
<%= content_tag :li, message %>
<% end %>
</ul>
</div>
</div>
<% end %>

<%= form_for @user, :html => {:class => 'well add-top-margin'} do |f| %>
<h2 class="add-vertical-margins"> <%= "Editable " if (current_user.publishing_manager? ) %>Permissions</h2>
<%= render partial: "shared/user_permissions", locals: { user_object: @user }%>

Expand Down

0 comments on commit 3a6caf3

Please sign in to comment.