-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat: implement <AddUsersMenu /> generic component
#23557
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
Changes from all commits
c21e000
2f72731
cca5680
48336a1
b2be80b
7300d26
da9c3cc
a8c9677
c20dcaf
3208234
6ec30aa
8ecc4de
8b2d5cf
0e69ccf
aa58a01
7056295
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,12 +63,17 @@ export const group = ( | |
| }; | ||
| }; | ||
|
|
||
| export const groupMembersByOrganizationQueryKey = ( | ||
| organization: string, | ||
| groupName: string, | ||
| ) => ["organization", organization, "group", groupName, "members"]; | ||
|
|
||
| export const getGroupMembersQueryKey = ( | ||
| organization: string, | ||
| groupName: string, | ||
| req?: UsersRequest, | ||
| ) => { | ||
| const base = [...getRootGroupQueryKey(organization, groupName), "members"]; | ||
| const base = groupMembersByOrganizationQueryKey(organization, groupName); | ||
| return req ? [...base, req] : base; | ||
| }; | ||
|
|
||
|
|
@@ -200,17 +205,10 @@ export const deleteGroup = (queryClient: QueryClient, organization: string) => { | |
| }; | ||
| }; | ||
|
|
||
| export const addMembers = (queryClient: QueryClient, organization: string) => { | ||
| export const addMember = () => { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the switch from the bulk add endpoint to the single add endpoint? idk if this is related, but when I try to add two members, one gets added and the other gets an error: But sometimes it does work. 🤔 Organization members always seems to work, I only get this on the group for some reason. Maybe a backend race with trying to add individual members in parallel? idk if it would be worth trying to fix that though when we could just add them all at once. Another tricky thing about the single add endpoint is that if some succeed and some do not, we should probably update the list with the ones that did succeed. Otherwise it looks like nothing got added, and also if they try again it will error saying some have already been added. At that point I think the only way the user can fix the page is by reloading it. Also does each user add query invalidate the group/org? When adding two members to an org for example I see three parallel requests for the members list which seems unfortunate. Ideally we could just do one update after all members were added (or were failed to be added). But maybe it is easier to use the bulk endpoint (idk if org members has one though).
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The race condition with parallel single-add mutations is now mitigated by switching to Switching back to the bulk endpoint would avoid the parallel mutation issue entirely — leaving that decision to @jakehwll. 🤖 Generated by Coder Agents
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could we specify the |
||
| return { | ||
| mutationFn: ({ | ||
| groupId, | ||
| userIds, | ||
| }: { | ||
| groupId: string; | ||
| userIds: string[]; | ||
| }) => API.addMembers(groupId, userIds), | ||
| onSuccess: async (updatedGroup: Group) => | ||
| invalidateGroup(queryClient, organization, updatedGroup.name), | ||
| mutationFn: ({ groupId, userId }: { groupId: string; userId: string }) => | ||
| API.addMember(groupId, userId), | ||
| }; | ||
| }; | ||
|
|
||
|
|
||
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it ok that there's a query key collision here?