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:
Joshen Lim
2025-02-19 21:52:08 +08:00
committed by GitHub
parent f553065a2e
commit 0b9a59325c

View File

@@ -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)),