mirror of
https://github.com/supabase/supabase.git
synced 2026-10-09 03:15:06 +03:00
## Context Just reorganizing the files under the Explorer folder as details are a bit more clearer Mainly shifting related and exclusive files into their own folder and tests into `__tests__` folder + renaming some files <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added query result display settings for switching between table and chart views. - Added chart configuration options for chart type, axes, scaling, cumulative mode, and labels. - Automatically prevents invalid logarithmic scaling when chart data is incompatible. - **Refactor** - Standardized Explorer tab and query source naming across the interface without changing existing behavior. - Updated Explorer navigation, routing, and page wiring to use the standardized components. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
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
|
|
}
|
|
|
|
export const QueryResultRenderer = ({ result, view, chart }: QueryResultRendererProps) => {
|
|
const { rows, error, autoLimit } = result ?? {}
|
|
|
|
if (!result) {
|
|
return <p className="text-xs text-foreground-lighter">Run the query to see results</p>
|
|
}
|
|
|
|
if (error) {
|
|
return <QueryResultError error={error} autoLimit={autoLimit} />
|
|
}
|
|
|
|
if ((rows ?? []).length === 0) {
|
|
return <p className="text-xs text-foreground-lighter">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
|
|
}
|