Skip to content

Commit

Permalink
Replace api_users/application/index table with component
Browse files Browse the repository at this point in the history
This ensures the markup generated reflects the latest changes in the
design system. I've decided to retain the `govuk-visually-hidden`
Permissions header and to display an empty cell for the update
permissions link, rather than the "Not set" default[1] when no link is
required.

[1] https://github.com/alphagov/govuk_publishing_components/blob/1df657ae5483552cf735396174c38eed134ba433/spec/components/table_spec.rb#L47
  • Loading branch information
chrislo committed Jan 11, 2024
1 parent 7967f55 commit d561fd7
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions app/views/api_users/applications/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,18 @@
<% end %>
<% end %>
<table class="govuk-table">
<caption class="govuk-table__caption govuk-table__caption--m">Apps <%= @api_user.name %> has access to</caption>
<thead class="govuk-table__head">
<tr class="govuk-table__row">
<th scope="col" class="govuk-table__header govuk-!-width-one-quarter">Name</th>
<th scope="col" class="govuk-table__header govuk-!-width-one-third">Description</th>
<th scope="col" class="govuk-table__header"><span class="govuk-visually-hidden">Permissions</span></th>
</tr>
</thead>
<tbody class="govuk-table__body">
<% @applications.each do |application| %>
<tr class="govuk-table__row">
<td class="govuk-table__cell"><%= application.name %></td>
<td class="govuk-table__cell"><%= application.description %></td>
<td class="govuk-table__cell govuk-!-text-align-right"><%= update_permissions_link(application, @api_user) %></td>
</tr>
<% end %>
</tbody>
</table>
<%= render "govuk_publishing_components/components/table", {
caption: "Apps #{@api_user.name} has access to",
head: [
{ text: "Name" },
{ text: "Description" },
{ text: content_tag(:span, "Permissions", class: "govuk-visually-hidden") },
],
rows: @applications.map do |application|
[
{ text: application.name },
{ text: application.description },
{ text: update_permissions_link(application, @api_user) || "" }
]
end,
} %>

0 comments on commit d561fd7

Please sign in to comment.