Skip to content

Commit

Permalink
Show user status as tag instead of strikethrough
Browse files Browse the repository at this point in the history
The strikethrough is not part of the design system, so we've decided to
use the govuk-tag style instead.

The design on the card showed green for active users, grey for suspended
users, but there were no examples of locked or invited users.

I've chosen to only use green for active users, and grey for all other
statuses.

The CSV export of the users needs to stay in plain text.
  • Loading branch information
CristinaRO committed Feb 14, 2024
1 parent c5ae9b5 commit 61c1ec5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
11 changes: 8 additions & 3 deletions app/helpers/users_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ module UsersHelper
include Pundit::Authorization

def status(user)
user.status.humanize
css_classes = if user.status == User::USER_STATUS_ACTIVE
"govuk-tag--green"
else
"govuk-tag--grey"
end

govuk_tag(user.status.humanize, css_classes)
end

def two_step_status(user)
Expand Down Expand Up @@ -63,8 +69,7 @@ def filtered_users_heading(users)
end

def user_name(user)
anchor_tag = link_to(user.name, edit_user_path(user), class: "govuk-link")
user.suspended? ? content_tag(:del, anchor_tag) : anchor_tag
link_to(user.name, edit_user_path(user), class: "govuk-link")
end

def options_for_role_select(selected: nil)
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/user_export_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def row(user)
user.sign_in_count,
user.current_sign_in_at.try(:to_formatted_s, :db),
user.created_at.try(:to_formatted_s, :db),
status(user),
user.status.humanize,
two_step_status(user),
user.expiry_date_for_2sv_exemption.try(:strftime, "%d/%m/%Y"),
].concat(app_permissions_for(user))
Expand Down
14 changes: 8 additions & 6 deletions test/helpers/users_helper_test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require "test_helper"

class UsersHelperTest < ActionView::TestCase
include ApplicationHelper

test "sync_needed? should work with user permissions not synced yet" do
application = create(:application)
user = create(:user)
Expand All @@ -9,11 +11,11 @@ class UsersHelperTest < ActionView::TestCase
assert_nothing_raised { sync_needed?(user.application_permissions) }
end

test "status should humanize User#status" do
assert_equal "Invited", status(build(:invited_user))
assert_equal "Active", status(build(:active_user))
assert_equal "Locked", status(build(:locked_user))
assert_equal "Suspended", status(build(:suspended_user))
test "status should tag and humanize User#status" do
assert_equal "<strong class=\"govuk-tag govuk-tag--grey\">Invited</strong>", status(build(:invited_user))
assert_equal "<strong class=\"govuk-tag govuk-tag--green\">Active</strong>", status(build(:active_user))
assert_equal "<strong class=\"govuk-tag govuk-tag--grey\">Locked</strong>", status(build(:locked_user))
assert_equal "<strong class=\"govuk-tag govuk-tag--grey\">Suspended</strong>", status(build(:suspended_user))
end

test "two_step_status should reflect the user's status accurately when the user is exempted from 2sv" do
Expand Down Expand Up @@ -239,7 +241,7 @@ class UsersHelperTest < ActionView::TestCase
user = build(:active_user, id: 123)
item = summary_list_item_for_status(user)
assert_equal item[:field], "Status"
assert_equal item[:value], "Active"
assert_equal item[:value], "<strong class=\"govuk-tag govuk-tag--green\">Active</strong>"
assert_nil item[:edit]
end
end
Expand Down

0 comments on commit 61c1ec5

Please sign in to comment.