Files
supabase/apps/studio/components/interfaces/Explorer/QueryEditor/QueryResultFooter.tsx
T
Joshen Lim cdbe2963fa Add DownloadResultsButton to explorer query editor (#50563)
## Context

Adds the `DownloadResultsButton` component to the footer of the
explorer's query editor - will show up in notebook + query tab

<img width="1147" height="907" alt="image"
src="https://github.com/user-attachments/assets/141278a8-1e00-424e-84ec-8ddb7cf0a96b"
/>
<img width="1152" height="913" alt="image"
src="https://github.com/user-attachments/assets/0e4a48b0-ebc3-473e-8bc0-19ab633e1904"
/>


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Added a results footer displaying row counts and optional row limits.
  - Added download and export actions when query results are available.
  - Standardized the results footer across query and notebook previews.
- Added keyboard shortcut hints to export options when shortcuts are
enabled.

- **Improvements**
- Export actions now support read-only result sets without changing
displayed output.
- Export menu sizing and shortcut labels adapt to the enabled shortcut
configuration.
  - Improved accessibility with a label for refreshing logs.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-09-18 17:13:44 +08:00

43 lines
1.1 KiB
TypeScript

import { ExplorerQueryFooter } from '../ExplorerQuery'
import { DownloadResultsButton } from '@/components/ui/DownloadResultsButton'
import { pluralize } from '@/lib/helpers'
interface QueryResultFooterProps {
count: number
rowLimit?: number
results?: readonly Record<string, unknown>[]
fileName?: string
}
export const QueryResultFooter = ({
count,
rowLimit,
results,
fileName,
}: QueryResultFooterProps) => {
return (
<ExplorerQueryFooter className="flex items-center justify-between gap-x-2">
<div className="flex items-center gap-x-2">
<p>
{count.toLocaleString()} {pluralize(count, 'row')}
</p>
{rowLimit && (
<>
<p>·</p>
<p>{rowLimit < 0 ? 'No row limit' : `Limit ${rowLimit} rows`}</p>
</>
)}
</div>
{results && results.length > 0 && (
<DownloadResultsButton
enableCopyShortcuts={false}
align="end"
variant="text"
results={results}
fileName={fileName ?? 'Results'}
/>
)}
</ExplorerQueryFooter>
)
}