Skip to content
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

addProgramUser mutation #1500

Merged
merged 10 commits into from
Dec 3, 2024
Merged

addProgramUser mutation #1500

merged 10 commits into from
Dec 3, 2024

Conversation

swalker2m
Copy link
Contributor

This PR:

  • tracks the addition of UserProfile and refactoring of OrcidProfile from core
  • adds a fallback profile in ProgramUser which provides a location for name and email when not specified in the public ORCiD data
  • separates the ProgramUser parts of the ProgramService into a new ProgramUserService
  • adds a new addProgramUser mutation

The purpose of the mutation is to allow CoIs to be created and linked even before they have been extended / have accepted an invitation. There is additional work to do here, I believe, to support the UI suggested in ShortCut 3774. In particular there is no clear link between invitations and program users. This will be addressed in a future PR but I think for now this will keep the invitation system working as is.

def addProgramUser(
sso: SsoGraphQlClient[F],
input: AddProgramUserInput
)(using NoTransaction[F]): F[Result[(Program.Id, User.Id)]]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Most of this was just moved from ProgramService in order to group everything ProgramUser related. This mutation though, addProgramUser, is new.

): Option[AppliedFragment] =
user.role match
case GuestRole => existsUserAsPi(programId, user.id).some
case StandardRole.Pi(_) => (void"(" |+| existsUserAsPi(programId, user.id) |+| void" OR " |+| existsUserAsCoi(programId, user.id) |+| void")").some
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think perhaps we may want to say that a CoI only has access if they have accepted an invitation? At any rate, at the moment they will have access immediately if added via addProgramUser.

@@ -141,7 +141,7 @@ object UserInvitationService:
val xa = transaction
xa.savepoint.flatMap: sp =>
session
.prepareR(ProgramService.Statements.LinkUser.command)
.prepareR(ProgramUserService.Statements.LinkUser.command)
Copy link
Contributor Author

@swalker2m swalker2m Dec 2, 2024

Choose a reason for hiding this comment

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

Here in the UserInvitationService when a user accepts an invitation, we attempt to "link" them to the program (i.e., add them as a ProgramUser). If previously added explicitly via addProgramUser then the linking part will fail with a warning -- though this doesn't fail the invitation redemption as a whole. I think we'll want to handle this more smoothly.

Copy link
Member

@tpolecat tpolecat left a comment

Choose a reason for hiding this comment

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

This looks good. Can you add stories for the potential issues you identified in your comments? 👍

@swalker2m
Copy link
Contributor Author

Can you add stories for the potential issues you identified in your comments?

That's a good idea:

https://app.shortcut.com/lucuma/story/4141/handle-invitations-for-direct-program-users

https://app.shortcut.com/lucuma/story/4144/program-access-for-pre-acceptance-users

@swalker2m swalker2m merged commit 6b3eaeb into main Dec 3, 2024
6 checks passed
@swalker2m swalker2m deleted the pre-auth-user branch December 3, 2024 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants