mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
## 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" />
62 lines
2.2 KiB
TypeScript
62 lines
2.2 KiB
TypeScript
import type { Table } from '@tanstack/react-table'
|
|
import { CopyIcon, XIcon } from 'lucide-react'
|
|
import { AnimatePresence, motion } from 'motion/react'
|
|
import { toast } from 'sonner'
|
|
import { copyToClipboard } from 'ui'
|
|
|
|
import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
|
|
import type { AuditLog } from '@/data/organizations/organization-audit-logs-query'
|
|
|
|
interface AuditLogsSelectionHeaderProps {
|
|
table: Table<AuditLog>
|
|
}
|
|
|
|
export const AuditLogsSelectionHeader = ({ table }: AuditLogsSelectionHeaderProps) => {
|
|
const selectedRows = table.getSelectedRowModel().rows.map((row) => row.original)
|
|
const hasSelection = selectedRows.length > 0
|
|
|
|
const handleCopy = () => {
|
|
const text = JSON.stringify(selectedRows, null, 2)
|
|
copyToClipboard(text, () => {
|
|
toast.success(`Copied ${selectedRows.length} log${selectedRows.length !== 1 ? 's' : ''}`)
|
|
})
|
|
}
|
|
|
|
return (
|
|
<AnimatePresence>
|
|
{hasSelection && (
|
|
<motion.div
|
|
initial={{ height: 0, opacity: 0 }}
|
|
animate={{ height: '40px', opacity: 1 }}
|
|
exit={{ height: 0, opacity: 0 }}
|
|
transition={{ type: 'spring', stiffness: 420, damping: 30, mass: 0.4 }}
|
|
className="pl-10 pr-4 flex items-center justify-between border-b bg-surface-75 w-full overflow-hidden absolute top-0 left-0 right-0 z-20"
|
|
>
|
|
<p className="text-xs">
|
|
{selectedRows.length} row{selectedRows.length > 1 ? <span>s</span> : ''}{' '}
|
|
<span>selected</span>
|
|
</p>
|
|
|
|
<div className="flex items-center justify-center gap-x-2">
|
|
<ButtonTooltip
|
|
size="tiny"
|
|
icon={<CopyIcon size={12} />}
|
|
className="w-7"
|
|
onClick={handleCopy}
|
|
tooltip={{ content: { side: 'bottom', text: 'Copy selected logs' } }}
|
|
/>
|
|
<ButtonTooltip
|
|
size="tiny"
|
|
variant="text"
|
|
icon={<XIcon />}
|
|
className="px-1"
|
|
onClick={() => table.resetRowSelection()}
|
|
tooltip={{ content: { side: 'bottom', text: 'Clear selection' } }}
|
|
/>
|
|
</div>
|
|
</motion.div>
|
|
)}
|
|
</AnimatePresence>
|
|
)
|
|
}
|