Files
supabase/apps/studio/components/interfaces/Auth/Users/DeleteUserModal.tsx
Joshen Lim 6d08d66b7d Add eslint rule for google translate dynamic spans + address all issues (#52949)
## Context

We've been seeing many `NotFoundError: Failed to execute 'removeChild'
on 'Node'` and `NotFoundError: Failed to execute 'insertBefore' on
'Node'` events on Sentry which are historically known to be caused by
Google Translate in the browser.

There's technically no _right way_ to address this unfortunately, but
one of the solutions which should address most of these issues is to
wrap any dynamic text within a span - we've considered that quite a
while back tbh but never took the time to do this until today with the
help of Claude. Although just a heads up that it might not necessarily
completely eradicate those issues.

Also added an eslint rule which should prevent future occurences of this
<img width="1264" height="192" alt="image"
src="https://github.com/user-attachments/assets/b2c32ea0-45a2-4ccd-82fe-1a859905fc29"
/>
2026-11-05 23:28:46 +08:00

61 lines
1.7 KiB
TypeScript

import { useParams } from 'common'
import { toast } from 'sonner'
import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
import { useUserDeleteMutation } from '@/data/auth/user-delete-mutation'
import { User } from '@/data/auth/users-infinite-query'
interface DeleteUserModalProps {
visible: boolean
selectedUser?: User
onClose: () => void
onDeleteSuccess?: () => void
}
export const DeleteUserModal = ({
visible,
selectedUser,
onClose,
onDeleteSuccess,
}: DeleteUserModalProps) => {
const { ref: projectRef } = useParams()
const { mutate: deleteUser, isPending: isDeleting } = useUserDeleteMutation({
onSuccess: () => {
toast.success(`Successfully deleted ${selectedUser?.email}`)
onDeleteSuccess?.()
},
})
const handleDeleteUser = async () => {
if (!projectRef) return console.error('Project ref is required')
if (selectedUser?.id === undefined) {
return toast.error(`Failed to delete user: User ID not found`)
}
deleteUser({ projectRef, userId: selectedUser.id })
}
return (
<ConfirmationModal
visible={visible}
variant="destructive"
title="Confirm to delete user"
loading={isDeleting}
confirmLabel="Delete"
onCancel={() => onClose()}
onConfirm={() => handleDeleteUser()}
alert={{
title: 'Deleting a user is irreversible',
description:
'This will remove the selected the user from the project and all associated data.',
}}
>
<p className="text-sm text-foreground-light">
This is permanent! Are you sure you want to delete the user{' '}
{selectedUser?.email ?? selectedUser?.phone ?? <span>this user</span>}
<span>?</span>
</p>
</ConfirmationModal>
)
}