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" />
90 lines
2.6 KiB
TypeScript
90 lines
2.6 KiB
TypeScript
import dayjs from 'dayjs'
|
|
import { CheckIcon, Loader2Icon, XIcon } from 'lucide-react'
|
|
|
|
import { pgmqQueueTable } from './Queues.utils'
|
|
import { useQueuesMetricsQuery } from '@/data/database-queues/database-queues-metrics-query'
|
|
import { PostgresQueue } from '@/data/database-queues/database-queues-query'
|
|
import { useTablesQuery } from '@/data/tables/tables-query'
|
|
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
|
|
import { DATETIME_FORMAT } from '@/lib/constants'
|
|
|
|
export interface QueueWithMetrics extends PostgresQueue {
|
|
id: string // Add unique id for DataGrid
|
|
}
|
|
|
|
interface QueueCellProps {
|
|
queue: QueueWithMetrics
|
|
}
|
|
|
|
export const QueueNameCell = ({ queue }: QueueCellProps) => (
|
|
<div className="flex items-center">
|
|
<span className="truncate" title={queue.queue_name}>
|
|
{queue.queue_name}
|
|
</span>
|
|
</div>
|
|
)
|
|
|
|
export const QueueTypeCell = ({ queue }: QueueCellProps) => {
|
|
const type = queue.is_partitioned ? 'Partitioned' : queue.is_unlogged ? 'Unlogged' : 'Basic'
|
|
return (
|
|
<div className="flex items-center">
|
|
<span className="truncate" title={type.toLowerCase()}>
|
|
{type}
|
|
</span>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export const QueueRLSCell = ({ queue }: QueueCellProps) => {
|
|
const { data: selectedProject } = useSelectedProjectQuery()
|
|
|
|
const { data: queueTables } = useTablesQuery({
|
|
projectRef: selectedProject?.ref,
|
|
connectionString: selectedProject?.connectionString,
|
|
schema: 'pgmq',
|
|
})
|
|
|
|
const queueTable = queueTables?.find((x) => x.name === pgmqQueueTable(queue.queue_name))
|
|
const isRlsEnabled = !!queueTable?.rls_enabled
|
|
|
|
return (
|
|
<div className="flex items-center">
|
|
{isRlsEnabled ? <CheckIcon size={14} className="text-primary" /> : <XIcon size={14} />}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export const QueueCreatedAtCell = ({ queue }: QueueCellProps) => (
|
|
<div className="flex items-center">
|
|
<span title={queue.created_at}>{dayjs(queue.created_at).format(DATETIME_FORMAT)}</span>
|
|
</div>
|
|
)
|
|
|
|
export const QueueSizeCell = ({ queue }: QueueCellProps) => {
|
|
const { data: selectedProject } = useSelectedProjectQuery()
|
|
|
|
const { data: metrics, isPending: isLoading } = useQueuesMetricsQuery(
|
|
{
|
|
queueName: queue.queue_name,
|
|
projectRef: selectedProject?.ref,
|
|
connectionString: selectedProject?.connectionString,
|
|
},
|
|
{
|
|
staleTime: 30 * 1000, // 30 seconds
|
|
}
|
|
)
|
|
|
|
return (
|
|
<div className="flex items-center">
|
|
{isLoading ? (
|
|
<Loader2Icon className="animate-spin" size={16} />
|
|
) : (
|
|
<span>
|
|
{metrics?.queue_length}{' '}
|
|
{metrics?.method === 'estimated' ? <span>(Approximate)</span> : null}
|
|
</span>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|