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

Allow listing user's projects when adding to an org #1119

Merged
merged 22 commits into from
Oct 21, 2024

Conversation

rmunn
Copy link
Contributor

@rmunn rmunn commented Oct 11, 2024

Fix #1096.

When a user is selected from the typeahead in the "add members" modal on the org page, that user's projects are also shown in the modal, with any projects that the user manages automatically pre-checked. There's a new GraphQL mutation called AddProjectsToOrg (projects, plural) which will add all the projects at once.

The modal currently does not attempt to check which projects are already in the org; instead, the backend handles projects that are already in the org and doesn't try to add them again.

Screenshot:

add-projects-with-member

Will be used for adding users to org, and letting users add their own
projects to an org.
@rmunn rmunn self-assigned this Oct 11, 2024
@rmunn rmunn linked an issue Oct 11, 2024 that may be closed by this pull request
Copy link

github-actions bot commented Oct 11, 2024

UI unit Tests

12 tests  ±0   12 ✅ ±0   0s ⏱️ ±0s
 4 suites ±0    0 💤 ±0 
 1 files   ±0    0 ❌ ±0 

Results for commit c503366. ± Comparison against base commit 987d902.

♻️ This comment has been updated with latest results.

@rmunn
Copy link
Contributor Author

rmunn commented Oct 11, 2024

Design decision from meeting: component will not make GQL query, but will be handed the list of projects in a prop. The "add member to org" dialog is doing a query on the user you select, so we'll edit that query in order to pull the user's project list and hand it to the component. The component will end up as a pure display component, which simply formats the data and presents a bindable prop for the checkbox group.

rmunn added 2 commits October 17, 2024 14:15
Now takes list of projects and roles, and doesn't need to do any GQL
queries of its own.
@rmunn rmunn force-pushed the feat/add-projects-to-org-along-with-member branch from 81d9ee9 to d5d7c6f Compare October 18, 2024 03:45
This includes removing the list entirely if the user is deselected or
the newly-selected user doesn't have any projects (e.g., Test Admin).
@rmunn rmunn force-pushed the feat/add-projects-to-org-along-with-member branch from 6eadf42 to 0751ecd Compare October 18, 2024 04:11
Copy link

github-actions bot commented Oct 18, 2024

C# Unit Tests

75 tests   75 ✅  5s ⏱️
13 suites   0 💤
 1 files     0 ❌

Results for commit c503366.

♻️ This comment has been updated with latest results.

@rmunn rmunn marked this pull request as ready for review October 18, 2024 06:05
@rmunn rmunn requested a review from hahn-kev October 18, 2024 06:05
@rmunn
Copy link
Contributor Author

rmunn commented Oct 18, 2024

The lint failure is four lint errors all focused on the same line of code:

    await _addProjectsToOrg({ orgId, projectIds: [...withProjects.map(p => p.id)]})

_addProjectsToOrg expects projectIds to be of type string[]. The withProjects parameter is of type Project[], and the Project type I'm pulling in has an id: string property. Hovering over the types in the IDE shows that the .map() call is returning string[], yet eslint seems unable to figure that out. All the eslint errors are complaining about any typed values: unsafe to access .id on an any type, unsafe to assign type any[] to a variable of type string[], and so on.

I may just add a comment telling eslint to ignore errors on this line, since it's apparently not quite smart enough to figure out the types passing through the .map call.

Copy link
Collaborator

@hahn-kev hahn-kev left a comment

Choose a reason for hiding this comment

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

Partial review, there's a couple things to change.

backend/LexBoxApi/GraphQL/OrgMutations.cs Outdated Show resolved Hide resolved
backend/LexBoxApi/GraphQL/OrgMutations.cs Outdated Show resolved Hide resolved
frontend/src/lib/components/Users/UserProjects.svelte Outdated Show resolved Hide resolved
rmunn and others added 4 commits October 18, 2024 16:07
Permission check will already have thrown if the project ID doesn't
exist — unless the calling user was a site admin, and site admins are
not likely to be handcrafting GQL queries with invalid IDs.
@rmunn
Copy link
Contributor Author

rmunn commented Oct 18, 2024

@hahn-kev - Addressed your review comments so far, and added screenshot.

@myieye - If you have suggestions for UI improvements, go ahead and make them, or even push a commit to the branch, I don't mind.

@rmunn rmunn requested a review from hahn-kev October 18, 2024 09:32
Copy link
Collaborator

@hahn-kev hahn-kev left a comment

Choose a reason for hiding this comment

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

First thing I noticed is that the project list doesn't update when adding a member, should be able to be fixed be selecting the projects in the mutation.

I'm not sure where the bug is but when I try to add a user all their projects get added. Looking at the network it looks like all the id's are passed, so the backend is fine.

  1. type in user email and select, user is [email protected]
  2. all projects are selected because they're a manager
  3. use the checkbox at the top to uncheck all of them
  4. check sena 3
  5. submit
  6. go to project list and refresh
  7. all the projects from that user are in the list

backend/LexBoxApi/GraphQL/OrgMutations.cs Outdated Show resolved Hide resolved
backend/LexBoxApi/GraphQL/OrgMutations.cs Outdated Show resolved Hide resolved
backend/LexBoxApi/GraphQL/OrgMutations.cs Outdated Show resolved Hide resolved
frontend/src/routes/(authenticated)/org/[org_id]/+page.ts Outdated Show resolved Hide resolved
rmunn added 4 commits October 21, 2024 09:53
Since addProjectsToOrg bails out immediately if the projects list is
empty, this will not add significant time to the query if a user is
being added with no projects at all.
@rmunn rmunn requested a review from hahn-kev October 21, 2024 03:19
@rmunn rmunn enabled auto-merge (squash) October 21, 2024 06:46
@rmunn rmunn merged commit abb6dce into develop Oct 21, 2024
14 checks passed
@rmunn rmunn deleted the feat/add-projects-to-org-along-with-member branch October 21, 2024 06:48
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.

list and add member projects when adding a new member
2 participants