mirror of
https://github.com/supabase/supabase.git
synced 2026-07-01 01:25:54 +08:00
Update org roles confirmation to fire requests sequentially (#33695)
* Update org roles confirmation to fire requests sequentially * Add missing await * Add skip invalidation flags
This commit is contained in:
@@ -100,28 +100,28 @@ export const UpdateRolesConfirmationModal = ({
|
||||
const { toRemove, toAssign, toUpdate } = deriveRoleChangeActions(existingRoles, changesToRoles)
|
||||
|
||||
try {
|
||||
await Promise.all([
|
||||
...toAssign.map(({ roleId, projectIds }) =>
|
||||
assignRole({
|
||||
slug,
|
||||
gotrueId,
|
||||
roleId,
|
||||
projects: projectIds.map((id) => projects?.find((p) => p.id === id)?.ref) as string[],
|
||||
})
|
||||
),
|
||||
])
|
||||
await Promise.all([
|
||||
...toRemove.map((roleId) => removeRole({ slug, gotrueId, roleId })),
|
||||
...toUpdate.map(({ roleId, projectIds }) =>
|
||||
updateRole({
|
||||
slug,
|
||||
gotrueId,
|
||||
roleId,
|
||||
roleName: project_scoped_roles.find((r) => r.id === roleId)?.name as string,
|
||||
projects: projectIds.map((id) => projects?.find((p) => p.id === id)?.ref) as string[],
|
||||
})
|
||||
),
|
||||
])
|
||||
for (const { roleId, projectIds } of toAssign) {
|
||||
await assignRole({
|
||||
slug,
|
||||
gotrueId,
|
||||
roleId,
|
||||
projects: projectIds.map((id) => projects?.find((p) => p.id === id)?.ref) as string[],
|
||||
skipInvalidation: true,
|
||||
})
|
||||
}
|
||||
for (const roleId of toRemove) {
|
||||
await removeRole({ slug, gotrueId, roleId, skipInvalidation: true })
|
||||
}
|
||||
for (const { roleId, projectIds } of toUpdate) {
|
||||
await updateRole({
|
||||
slug,
|
||||
gotrueId,
|
||||
roleId,
|
||||
roleName: project_scoped_roles.find((r) => r.id === roleId)?.name as string,
|
||||
projects: projectIds.map((id) => projects?.find((p) => p.id === id)?.ref) as string[],
|
||||
skipInvalidation: true,
|
||||
})
|
||||
}
|
||||
|
||||
await Promise.all([
|
||||
queryClient.invalidateQueries(organizationKeys.rolesV2(slug)),
|
||||
|
||||
Reference in New Issue
Block a user