Skip to content

Commit

Permalink
dm-4749 add user roles to report (#863)
Browse files Browse the repository at this point in the history
* update admin/users

adds "Admin" and "PageGroup Editor Roles" rows to show config block

* update admin/users

adds csv block with selected columns and added "Admin" and "PageGroup Editor Roles" columns

* update admin/users

returns page_group names for "PageGroup Editor Roles" row and column in show and csv configs

* update comment in admin/users form

* update admin_spec feature test
  • Loading branch information
PhilipDeFraties authored May 9, 2024
1 parent f0d7bdf commit be11d06
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
33 changes: 30 additions & 3 deletions app/admin/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,15 @@
row :visn
row :created_at
row :confirmed_at
row :roles
row "Admin" do |user|
user.has_role?(:admin)
end
row "PageGroup Editor Roles" do |user|
page_group_roles = user.roles.where(name: 'page_group_editor').map do |role|
role.resource.try(:name)
end.compact
page_group_roles.empty? ? nil : page_group_roles.join(', ')
end
row :disabled
end
active_admin_comments
Expand All @@ -47,8 +55,8 @@
f.input :skip_va_validation
f.input :password
f.input :password_confirmation
# instance-scoped editor roles should be left out of the collection as they are handled in the
# given instance's edit form:
# instance-scoped editor roles should be left out of the collection as they are managed in the
# given page_group's edit form:
f.input :roles, as: :check_boxes, collection: Role.where(name: ['admin'])
f.input :disabled
end
Expand All @@ -65,4 +73,23 @@ def update
super
end
end

csv do
column :email
column :last_sign_in_at
column :created_at
column :sign_in_count
column :first_name
column :last_name
column :job_title
column "Admin" do |user|
user.has_role?(:admin) ? 'TRUE' : 'FALSE'
end
column "PageGroup Editor Roles" do |user|
roles = user.roles.where(name: 'page_group_editor').map do |role|
role.resource.name
end
roles.compact.empty? ? '' : roles.join(', ')
end
end
end
2 changes: 1 addition & 1 deletion spec/features/admin/admin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ def visit_practice_show
execute_script("document.getElementById('user_role_ids_1').checked = true;")
click_button('Update User')
expect(page).to have_current_path(admin_user_path(User.last))
expect(page).to have_content('admin')
expect(page).to have_css('tr.row.row-admin', text: 'YES')
end
end

Expand Down

0 comments on commit be11d06

Please sign in to comment.