mirror of
https://github.com/supabase/supabase.git
synced 2026-10-16 22:59:11 +03:00
## Context This is largely just a mechanical change here: Opting to use lucide icons with the `Icon` suffix across all icon imports within `studio` - so that it’s clearer which components are icons + reduces the possibility of name collision with our own components - e.g <User /> vs <UserIcon /> Also added a eslint rule for this: <img width="1069" height="167" alt="image" src="https://github.com/user-attachments/assets/7f36f443-5ca2-4bf6-8d22-86e774513bfc" /> And updated `AGENTS.md` as such: ``` Icons come from `lucide-react`, always imported with the `Icon` suffix (`import { CheckIcon, Trash2Icon } from 'lucide-react'`) — never the bare names (`Check`) or `Check as CheckIcon` aliases (lint-enforced). ```
62 lines
1.6 KiB
TypeScript
62 lines
1.6 KiB
TypeScript
import { PlayIcon } from 'lucide-react'
|
|
|
|
import { type SqlSnippetSource } from '../../SQLEditor/querySource'
|
|
import { type QueryResult } from '../types'
|
|
import { QueryResultChart } from './QueryResultChart'
|
|
import { QueryResultError } from './QueryResultError'
|
|
import { DataGridResults } from '@/components/ui/DataGridResults'
|
|
import { type ChartConfig } from '@/data/content/notebooks/notebook-schema'
|
|
|
|
interface QueryResultRendererProps {
|
|
result?: QueryResult
|
|
view?: 'table' | 'chart'
|
|
chart?: ChartConfig
|
|
/** The query that produced `result`, used to build the "Debug with Assistant" prompt on error. */
|
|
sql?: string
|
|
source?: SqlSnippetSource
|
|
onDebug?: (prompt: string) => void
|
|
}
|
|
|
|
export const QueryResultRenderer = ({
|
|
result,
|
|
view,
|
|
chart,
|
|
sql,
|
|
source,
|
|
onDebug,
|
|
}: QueryResultRendererProps) => {
|
|
const { rows, error, autoLimit } = result ?? {}
|
|
|
|
if (!result) {
|
|
return (
|
|
<div className="flex items-center gap-x-2 p-3 w-full">
|
|
<PlayIcon size={12} className="text-foreground-lighter" />
|
|
<p className="text-xs text-foreground-lighter">Run the query to see results</p>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
if (error) {
|
|
return (
|
|
<QueryResultError
|
|
error={error}
|
|
autoLimit={autoLimit}
|
|
sql={sql}
|
|
source={source}
|
|
onDebug={onDebug}
|
|
/>
|
|
)
|
|
}
|
|
|
|
if ((rows ?? []).length === 0) {
|
|
return <p className="text-xs text-foreground-lighter p-3">Success. No rows returned</p>
|
|
}
|
|
|
|
if (rows && rows.length > 0) {
|
|
if (view === 'table') return <DataGridResults rows={rows} />
|
|
if (view === 'chart') return <QueryResultChart chart={chart} result={result} />
|
|
}
|
|
|
|
return null
|
|
}
|