Skip to content

Commit 731f1d7

Browse files
committed
improvement(admin): align the role confirm and reset feedback with house patterns
1 parent d36229d commit 731f1d7

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

  • apps/sim/app/workspace/[workspaceId]/settings/components/admin

apps/sim/app/workspace/[workspaceId]/settings/components/admin/admin.tsx

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,9 @@ const USER_TABLE_HEADER = (
5656
)
5757

5858
/**
59-
* The row action awaiting confirmation in {@link ChipConfirmModal}. Carries the
60-
* id plus, for a role change, the role the admin chose to apply — never the
61-
* whole user row. A refetch while the modal is open therefore refreshes the
62-
* name it shows without ever redirecting the action the admin committed to.
59+
* The row action awaiting confirmation. Holds ids, never the user row, so a
60+
* refetch while the modal is open refreshes the name it shows without
61+
* redirecting the action the admin committed to.
6362
*/
6463
type PendingUserAction =
6564
| { type: 'ban'; userId: string }
@@ -211,7 +210,6 @@ export function Admin() {
211210
)
212211
}
213212

214-
/** Rows with an action in flight, whose remaining actions stay disabled. */
215213
const pendingUserIds = new Set<string>()
216214
for (const mutation of [setUserRole, banUser, unbanUser, impersonateUser, sendPasswordReset]) {
217215
if (mutation.isPending && mutation.variables?.userId)
@@ -233,6 +231,7 @@ export function Admin() {
233231
{u.id !== session?.user?.id && (
234232
<>
235233
<Chip
234+
aria-label={`Impersonate ${u.email}`}
236235
onClick={() => handleImpersonate(u.id, u.email)}
237236
disabled={pendingUserIds.has(u.id)}
238237
>
@@ -249,6 +248,13 @@ export function Admin() {
249248
{ userId: u.id, email: u.email },
250249
{
251250
onSuccess: () => toast.success(`Password reset email sent to ${u.email}`),
251+
onError: (error) =>
252+
toast.error(
253+
getErrorMessage(
254+
error,
255+
`Could not send a password reset email to ${u.email}`
256+
)
257+
),
252258
}
253259
)
254260
},
@@ -399,13 +405,10 @@ export function Admin() {
399405
</p>
400406
)}
401407

402-
{(unbanUser.error ||
403-
impersonateUser.error ||
404-
sendPasswordReset.error ||
405-
impersonationGuardError) && (
408+
{(unbanUser.error || impersonateUser.error || impersonationGuardError) && (
406409
<p className='text-[var(--text-error)] text-small'>
407410
{impersonationGuardError ||
408-
(unbanUser.error || impersonateUser.error || sendPasswordReset.error)?.message ||
411+
(unbanUser.error || impersonateUser.error)?.message ||
409412
'Action failed. Please try again.'}
410413
</p>
411414
)}
@@ -524,14 +527,12 @@ export function Admin() {
524527
' ',
525528
isDemotion
526529
? { text: 'revokes their platform admin access.', error: true }
527-
: {
528-
text: 'grants full platform admin access, including impersonating any user.',
529-
error: true,
530-
},
530+
: 'grants full platform admin access, including impersonating any user.',
531531
]}
532532
confirm={{
533533
label: isDemotion ? 'Demote' : 'Promote',
534534
onClick: handleConfirmRoleChange,
535+
variant: isDemotion ? 'destructive' : 'primary',
535536
pending: setUserRole.isPending,
536537
pendingLabel: isDemotion ? 'Demoting...' : 'Promoting...',
537538
}}

0 commit comments

Comments
 (0)