fix: logs copy shortcuts (#46183)

## TL;DR 

fixes logs copy shortcuts so selected rows are copied instead of the
full results set
(keeps the existing full results copy when no rows are selected)

## ref:

- closes https://github.com/supabase/supabase/issues/46181

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

## Summary by CodeRabbit

* **New Features**
* Added keyboard shortcuts to quickly copy selected log rows in JSON,
Markdown, and CSV formats. Shortcuts activate only when rows are
selected.

<!-- review_stack_entry_start -->

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/supabase/supabase/pull/46183?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)

<!-- review_stack_entry_end -->

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Vaibhav
2026-05-21 18:41:43 +05:30
committed by GitHub
parent 013c344645
commit 57b7aa2f3d
2 changed files with 24 additions and 3 deletions

View File

@@ -442,6 +442,21 @@ export const LogTable = ({
})
}
useShortcut(SHORTCUT_IDS.RESULTS_COPY_JSON, () => handleCopySelectedRows('json'), {
enabled: selectedRowsData.length > 0,
conflictBehavior: 'allow',
})
useShortcut(SHORTCUT_IDS.RESULTS_COPY_MARKDOWN, () => handleCopySelectedRows('markdown'), {
enabled: selectedRowsData.length > 0,
conflictBehavior: 'allow',
})
useShortcut(SHORTCUT_IDS.RESULTS_COPY_CSV, () => handleCopySelectedRows('csv'), {
enabled: selectedRowsData.length > 0,
conflictBehavior: 'allow',
})
const logsExplorerTableHeader = (
<div
className={cn(
@@ -456,6 +471,7 @@ export const LogTable = ({
text={`Results ${data && data.length ? `(${data.length})` : ''}`}
results={data}
fileName={`supabase-logs-${ref}.csv`}
enableCopyShortcuts={selectedRowsData.length === 0}
/>
</div>

View File

@@ -30,6 +30,7 @@ interface DownloadResultsButtonProps {
align?: 'start' | 'center' | 'end'
results: any[]
fileName: string
enableCopyShortcuts?: boolean
onDownloadAsCSV?: () => void
onCopyAsMarkdown?: () => void
onCopyAsJSON?: () => void
@@ -43,6 +44,7 @@ export const DownloadResultsButton = ({
align = 'start',
results,
fileName,
enableCopyShortcuts = true,
onDownloadAsCSV,
onCopyAsMarkdown,
onCopyAsJSON,
@@ -103,15 +105,18 @@ export const DownloadResultsButton = ({
}
useShortcut(SHORTCUT_IDS.RESULTS_COPY_MARKDOWN, copyAsMarkdown, {
enabled: !isEmpty,
enabled: !isEmpty && enableCopyShortcuts,
conflictBehavior: 'allow',
registerInCommandMenu: true,
})
useShortcut(SHORTCUT_IDS.RESULTS_COPY_JSON, copyAsJSON, {
enabled: !isEmpty,
enabled: !isEmpty && enableCopyShortcuts,
conflictBehavior: 'allow',
registerInCommandMenu: true,
})
useShortcut(SHORTCUT_IDS.RESULTS_COPY_CSV, copyAsCSV, {
enabled: !isEmpty,
enabled: !isEmpty && enableCopyShortcuts,
conflictBehavior: 'allow',
registerInCommandMenu: true,
})
useShortcut(SHORTCUT_IDS.RESULTS_DOWNLOAD_CSV, downloadAsCSV, {