Skip to content

Add filter for SignonUsers to AdminUI#206

Merged
davidgisbey merged 5 commits into
mainfrom
2449-add-api-user-details-to-admin-ui
May 7, 2025
Merged

Add filter for SignonUsers to AdminUI#206
davidgisbey merged 5 commits into
mainfrom
2449-add-api-user-details-to-admin-ui

Conversation

@davidgisbey
Copy link
Copy Markdown
Contributor

@davidgisbey davidgisbey commented May 6, 2025

Description

This PR adds a filter for signon users to the questions show page and exposes the signon user details on the question show page.

It follows roughly the same pattern implemented for EarlyAccessUser in that you can only access the filter by clicking the link to View all questions for the user on the question show page. If the signon_user_id params isn't present then no filter/user info will be rendered.

I've made a few choices that might be worth discussing:

  • I've used the SignonUsers name rather than email as i think it will be more useful/easy to distinguish the user based on that. Signon API users will likely be created by a dev from the various teams that will consume the API, but will be named in a way that will make it clear which team is using the API key
  • I've not worried too much about duplication and instead prioritised that code can be easily removed so it's as easy as possible to strip out EarlyAccess and WaitingList users
  • I've only allowed you to filter by SignonUser if the user_id params isn't present since the filters are mutually exclusive. It might be that we want to do the inverse since we will be stripping out EarlyAccessUser soon. Or just not worry about is since EarlyAccess user will be stripped out soon. But for now since EarlyAccessUsers are knocking about and the mechanism required for web app users to use the app, i thought it was better to give that priority

Screenshots

Show question page

image

Question index page

image

Filtered by conversation

image

Out of scope

The Trello card mentions adding a source filter so we can filter on :api or web based on if the convo was created by the API or not. That will be added in a follow up PR.

Trello card

https://trello.com/b/BoPNvU55/stand-up-board-ai-govuk-llm-team-user-experience-govuk

@govuk-ci govuk-ci temporarily deployed to govuk-chat-2449-add-api-bkof4n May 6, 2025 10:51 Inactive
@davidgisbey davidgisbey force-pushed the 2449-add-api-user-details-to-admin-ui branch from 9aeec18 to 6fa7fae Compare May 6, 2025 11:06
@govuk-ci govuk-ci temporarily deployed to govuk-chat-2449-add-api-bkof4n May 6, 2025 11:06 Inactive
@davidgisbey davidgisbey force-pushed the 2449-add-api-user-details-to-admin-ui branch from 6fa7fae to 90fba60 Compare May 6, 2025 11:12
@govuk-ci govuk-ci temporarily deployed to govuk-chat-2449-add-api-bkof4n May 6, 2025 11:13 Inactive
@davidgisbey davidgisbey force-pushed the 2449-add-api-user-details-to-admin-ui branch from 90fba60 to 73006b5 Compare May 6, 2025 11:43
@govuk-ci govuk-ci temporarily deployed to govuk-chat-2449-add-api-bkof4n May 6, 2025 11:44 Inactive
@davidgisbey davidgisbey force-pushed the 2449-add-api-user-details-to-admin-ui branch from 73006b5 to cf640fb Compare May 6, 2025 12:06
@govuk-ci govuk-ci temporarily deployed to govuk-chat-2449-add-api-bkof4n May 6, 2025 12:07 Inactive
@davidgisbey davidgisbey marked this pull request as ready for review May 6, 2025 12:12
Copy link
Copy Markdown
Member

@kevindew kevindew left a comment

Choose a reason for hiding this comment

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

Nice work. I'm a bit confused about the conversation_id select field, so happy to chat over that. Also I think we may need to flag this more specifically as an API user or consider changing the web code a bit for consistency with signon_user storage.

Comment thread app/helpers/admin/questions_helper.rb Outdated
signon_user = conversation.signon_user
if signon_user.present?
rows << {
field: "Signon user",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shall we name this API user to reflect our expectation that this is used for API?

(aside: I hadn't thought about it before, but we do actually have a slightly odd situation with reference to signon user where you need signon access to use the web chat one but we're not storing that it was done by a signon user)

Copy link
Copy Markdown
Contributor Author

@davidgisbey davidgisbey May 6, 2025

Choose a reason for hiding this comment

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

Yea it's an awkward one, because for now that's true but it's unlikely to be the case going were we to go live. I like the idea of naming this API user in the UI at least so there's a clear distinction. I guess an option would be to update the association to be

  belongs_to :api_user, optional: true, class_name: "SignonUser", foreign_key: :signon_user_id

but it still feels a little awkward. Would def be less ambiguous though.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah I agree it feels a bit awkward - particularly with not knowing quite how the web version will iterate.

I think we'll leave the association as signon user for now, but we'll add an extra conditional for this showing and filtering of admin user that it also has an api source? how does that sound?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yea sounds good to me. I'll merge this and apply those changes to the other PR then 👍

Comment thread app/views/admin/questions/_question_filters.html.erb
Comment thread app/models/admin/filters/questions_filter.rb
I think name is actually going to be more informative to us here provided
the user has given it a reasonable name on creation of the API user on
Signon. If we use the email it will likely end up being a devs email
address which is less useful than something like "GOV.UK App team API user".
This pretty much copy and pastes the existing code for EarlyAccessUser.
If an id is passed in it uses that to modify the scope to only include
conversations associated with that signon user.

I've chosen not to filter by signon user if an early access user id is
passed in via user_id, as both filters are mutually exclusive.
This updates the QuestionsFilter to include a signon_user method. This
will be used in the UI, much like the user and conversation methods.
@davidgisbey davidgisbey force-pushed the 2449-add-api-user-details-to-admin-ui branch from cf640fb to e0af480 Compare May 6, 2025 16:03
@govuk-ci govuk-ci temporarily deployed to govuk-chat-2449-add-api-bkof4n May 6, 2025 16:03 Inactive
@davidgisbey davidgisbey force-pushed the 2449-add-api-user-details-to-admin-ui branch from e0af480 to 18ddcca Compare May 6, 2025 16:10
@govuk-ci govuk-ci temporarily deployed to govuk-chat-2449-add-api-bkof4n May 6, 2025 16:10 Inactive
This adds the SignonUser details to the questions page when a
QuestionsFilter#signon_user is present and QuestionsFilter#user is not.

It also scopes the conversation filter to the SignonUsers conversations
when one is present.

I've added a new system spec for the filters.
When a question belongs to a conversation that has an assoiciated
SignonUser, we should display the SignonUser details on the question.

We also want to link to the questions show page with the SignonUsers id
as a filter param like we do for EarlyAccessUsers.
@davidgisbey davidgisbey force-pushed the 2449-add-api-user-details-to-admin-ui branch from 18ddcca to 2e77b97 Compare May 6, 2025 16:19
@govuk-ci govuk-ci temporarily deployed to govuk-chat-2449-add-api-bkof4n May 6, 2025 16:20 Inactive
Copy link
Copy Markdown
Member

@kevindew kevindew left a comment

Choose a reason for hiding this comment

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

Looks good to me, though, given my comment, I imagine we want a little bit of follow up work after merging where things intersect with: #209

@davidgisbey davidgisbey merged commit 0d13a01 into main May 7, 2025
8 checks passed
@davidgisbey davidgisbey deleted the 2449-add-api-user-details-to-admin-ui branch May 7, 2025 08:15
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.

3 participants