Skip to content

Asap 173 admin user UI #222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 24 commits into
base: dev
Choose a base branch
from
Open

Asap 173 admin user UI #222

wants to merge 24 commits into from

Conversation

lkacenja
Copy link
Collaborator

@lkacenja lkacenja commented Jul 14, 2025

We need an interface to add and manage users. This includes a listing and the ability to add/edit users.

This PR adds the follow:

  • Splits the user is_admin flag into a is_site_admin and is_user_admin flag with separate permissions.
  • Adds a user listing
  • Adds add and edit views for users
  • Adds a test to cover the new screens and access

Here are a few screenshots:

Admin user list:

Screenshot 2025-07-15 at 10 08 04 AM

Admin add/edit form:

Screenshot 2025-07-15 at 10 08 16 AM
  • What additional steps are required to test this branch locally?

This branch will require a schema update: rails db:drop ; rails db:migrate ; rails db:setup

  • Are there any areas you would like extra review?

Try adding/editing users from the admin user listing.

  • Are there any rake tasks to run on production?

No

@lkacenja lkacenja changed the base branch from main to dev July 14, 2025 22:50
@lkacenja lkacenja self-assigned this Jul 15, 2025
env:
RAILS_ENV: test
DATABASE_URL: postgres://postgres:postgres@localhost:5432/access_pdf_test
run: bundle exec rspec
run: bundle exec rspec spec/models spec/requests
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to see if splitting up our JS and non-JS tests into separate steps improves the flaps. Sometimes it's best to not run them all at once.

@lkacenja lkacenja marked this pull request as ready for review July 15, 2025 16:23
@@ -5,7 +5,9 @@ export default class extends Controller {

connect() {
super.connect();
this.wrapperTarget.addEventListener('close', this.onModalClose.bind(this))
if (this.hasWrapperTarget) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes a random javascript error we've had for quite a while now.

Copy link
Collaborator

@allisonmorgan allisonmorgan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few wording suggestions and also had a few meta questions about the distinctions between user admins and site admins that I'd be happy to chat about more.

Maybe on more high-level comments: Will current users of our demo site need to be added by an admin manually after this is deployed? Or will current users' emails and passwords be automatically added? I saw the DB migration for admin users but didn't see anything for current users.

<%= @user.errors.full_message(:password_confirmation, @user.errors[:password_confirmation].first) %>
</div>
<% end %>
</div>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not actually sure this comment is relevant to this code block, but I think it might be clearer if the UI refers to passwords as "current" and "new". In other words, rename "Password" to "New password" and "Password confirmation" to "New password confirmation".
image

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also noting this language is a bit awkward when the user's password confirmation doesn't match the new password. I think renaming to "new password" will help but maybe also if you can lowercase it?
image

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those seem like good changes to me. What do you think about this labeling and error combination?

Screenshot 2025-07-16 at 4 39 30 PM

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I like this better! Thank you!

</div>
<% end %>
</div>
</div>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting funny behavior here. I thought I needed to supply the current password on a user to edit the checkboxes, but maybe I don't? I was logged in as the listed user, which had user admin access.

Screen.Recording.2025-07-16.at.1.50.49.PM.mov

Copy link
Collaborator Author

@lkacenja lkacenja Jul 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you only have to supply the current password if you are changing the password. This is a common security pattern to prevent cross site request forgery attacks, amongst other evils. Maybe we should make that more obvious?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, maybe just "We need your current password to confirm any password changes"? I think this error doesn't happen if you just select / unselect the admin boxes without supplying the current password.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! I did this in ef1cdd1.

@lkacenja
Copy link
Collaborator Author

lkacenja commented Jul 16, 2025

Maybe on more high-level comments: Will current users of our demo site need to be added by an admin manually after this is deployed? Or will current users' emails and passwords be automatically added? I saw the DB migration for admin users but didn't see anything for current users.

When I setup Devise on the previous branch, I set it to use our existing user table for the "account" record. So the migrations have all been focused on adding or renaming fields to that table. Everyone should already be in the system and should have the same email, password and admin status. Or at least that's my goal.

We will need to manually add the is_user_admin flag to CfA accounts.

@allisonmorgan allisonmorgan self-requested a review July 16, 2025 23:55
Copy link
Collaborator

@allisonmorgan allisonmorgan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for iterating on these comments! This adds some great functionality!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants