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" />
115 lines
3.9 KiB
TypeScript
115 lines
3.9 KiB
TypeScript
import { CheckIcon, ChevronDownIcon, CopyIcon, XIcon } from 'lucide-react'
|
|
import {
|
|
Button,
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuTrigger,
|
|
} from 'ui'
|
|
|
|
import type { LogData, QueryType } from './Logs.types'
|
|
import { buildLogsPrompt } from './Logs.utils'
|
|
import { SIDEBAR_KEYS } from '@/components/layouts/ProjectLayout/LayoutSidebar/LayoutSidebarProvider'
|
|
import { AiAssistantDropdown } from '@/components/ui/AiAssistantDropdown'
|
|
import { ShortcutBadge } from '@/components/ui/ShortcutBadge'
|
|
import { useAiAssistantStateSnapshot } from '@/state/ai-assistant-state'
|
|
import { SHORTCUT_IDS } from '@/state/shortcuts/registry'
|
|
import { useSidebarManagerSnapshot } from '@/state/sidebar-manager-state'
|
|
|
|
export type LogCopyFormat = 'json' | 'markdown' | 'csv'
|
|
|
|
interface MultiSelectActionBarProps {
|
|
selectedRows: Set<string>
|
|
selectedRowsData: LogData[]
|
|
copiedFormat: LogCopyFormat | null
|
|
onCopy: (format: LogCopyFormat) => void
|
|
onClear: () => void
|
|
queryType?: QueryType
|
|
sqlQuery?: string
|
|
}
|
|
|
|
export function MultiSelectActionBar({
|
|
selectedRows,
|
|
selectedRowsData,
|
|
copiedFormat,
|
|
onCopy,
|
|
onClear,
|
|
queryType,
|
|
sqlQuery,
|
|
}: MultiSelectActionBarProps) {
|
|
const { openSidebar } = useSidebarManagerSnapshot()
|
|
const aiSnap = useAiAssistantStateSnapshot()
|
|
|
|
function handleOpenAiAssistant() {
|
|
const prompt = buildLogsPrompt(selectedRowsData, { queryType, sqlQuery })
|
|
openSidebar(SIDEBAR_KEYS.AI_ASSISTANT)
|
|
aiSnap.newChat({ initialMessage: prompt })
|
|
}
|
|
const count = selectedRows.size
|
|
if (count === 0) return null
|
|
|
|
return (
|
|
<div
|
|
className="flex items-center gap-2 px-3 py-1.5 border-b bg-surface-200 text-sm sticky top-0 z-10"
|
|
style={{ height: 40 }}
|
|
>
|
|
<span className="text-foreground-light font-mono text-xs">
|
|
{`${count} ${count === 1 ? 'row' : 'rows'} selected`}
|
|
</span>
|
|
|
|
<div className="flex items-center gap-1 ml-auto">
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger asChild>
|
|
<Button
|
|
size="tiny"
|
|
icon={
|
|
copiedFormat ? (
|
|
<CheckIcon size={12} className="text-primary" />
|
|
) : (
|
|
<CopyIcon size={12} />
|
|
)
|
|
}
|
|
iconRight={<ChevronDownIcon size={11} />}
|
|
>
|
|
{copiedFormat ? 'Copied!' : 'Copy'}
|
|
</Button>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent align="end" className="w-60">
|
|
<DropdownMenuItem onClick={() => onCopy('json')} className="gap-x-2">
|
|
<CopyIcon size={13} />
|
|
<p>Copy as JSON</p>
|
|
<ShortcutBadge shortcutId={SHORTCUT_IDS.RESULTS_COPY_JSON} className="ml-auto" />
|
|
</DropdownMenuItem>
|
|
<DropdownMenuItem onClick={() => onCopy('markdown')} className="gap-x-2">
|
|
<CopyIcon size={13} />
|
|
<p>Copy as Markdown</p>
|
|
<ShortcutBadge shortcutId={SHORTCUT_IDS.RESULTS_COPY_MARKDOWN} className="ml-auto" />
|
|
</DropdownMenuItem>
|
|
<DropdownMenuItem onClick={() => onCopy('csv')} className="gap-x-2">
|
|
<CopyIcon size={13} />
|
|
<p>Copy as CSV</p>
|
|
<ShortcutBadge shortcutId={SHORTCUT_IDS.RESULTS_COPY_CSV} className="ml-auto" />
|
|
</DropdownMenuItem>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
|
|
<AiAssistantDropdown
|
|
label="Explain with AI"
|
|
buildPrompt={() => buildLogsPrompt(selectedRowsData, { queryType, sqlQuery })}
|
|
onOpenAssistant={handleOpenAiAssistant}
|
|
telemetrySource="log_explorer"
|
|
/>
|
|
|
|
<Button
|
|
variant="text"
|
|
size="tiny"
|
|
icon={<XIcon size={12} />}
|
|
onClick={onClear}
|
|
title="Clear selection"
|
|
className="text-foreground-lighter px-1.5 hover:text-foreground"
|
|
/>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|