Files
supabase/apps/studio/components/ui/DataTable/RefreshButton.tsx
Ali Waseem 2cb7f0c078 feat(studio): add keyboard shortcuts for unified logs (#46680)
Adds the final set of keyboard shortcuts to the Unified Logs page and
converts the last hardcoded `keydown` listener (detail-panel prev/next)
to the shared shortcut registry. Each action also surfaces its keybind
in a registry-driven tooltip.

Closes FE-3415.

## Shortcuts

| Action | Shortcut | Notes |
| --- | --- | --- |
| Refresh logs | `Shift+R` | new |
| Download logs | `Shift+E` | new — opens export dropdown |
| Focus filter bar | `Shift+F` | new |
| Clear filters | `F` then `C` | new |
| Copy selected as JSON | `Mod+Shift+J` | new — reuses
`results.copy-json` |
| Copy selected as Markdown | `Mod+Shift+M` | new — reuses
`results.copy-markdown` |
| Previous / next log (detail panel) | `↑` / `↓` | converted from
hardcoded listener |
| Close details panel | `Escape` | new |

Existing shared `data-table.*` shortcuts kept as-is: toggle sidebar
(`Mod+B`), live mode (`Mod+J`), reset filters (`Mod+Esc`), reset columns
(`Mod+U`), reset focus (`Mod+.`).

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

* **New Features**
* Added keyboard shortcuts for Unified Logs: copy selected rows as
JSON/Markdown, navigate rows, refresh, clear/reset filters, download,
and focus filter — shortcuts show in the command menu and display
badges/hints in menus and buttons.
* **Refactor**
* Shortcut handling unified across log controls; shortcuts
enable/disable based on context and a new "Logs" group appears in the
shortcut reference.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-06-05 09:21:20 -06:00

59 lines
1.5 KiB
TypeScript

import { LoaderCircle, RefreshCcw } from 'lucide-react'
import { Button } from 'ui'
import { ButtonTooltip } from '../ButtonTooltip'
import { Shortcut } from '@/components/ui/Shortcut'
import type { ShortcutId } from '@/state/shortcuts/registry'
interface RefreshButtonProps {
isLoading: boolean
onRefresh: () => void
/**
* When provided, the button binds this registered shortcut (hotkey + a
* tooltip that surfaces the keybind). Otherwise it falls back to a plain
* "Refresh logs" tooltip with no keybind.
*/
shortcutId?: ShortcutId
}
export const RefreshButton = ({ isLoading, onRefresh, shortcutId }: RefreshButtonProps) => {
const icon = isLoading ? (
<LoaderCircle className="text-foreground animate-spin" />
) : (
<RefreshCcw className="text-foreground" />
)
if (shortcutId) {
return (
<Shortcut
id={shortcutId}
onTrigger={onRefresh}
options={{ enabled: !isLoading, registerInCommandMenu: true }}
side="bottom"
>
<Button
size="tiny"
type="default"
disabled={isLoading}
onClick={onRefresh}
className="w-[26px]"
icon={icon}
aria-label="Refresh logs"
/>
</Shortcut>
)
}
return (
<ButtonTooltip
size="tiny"
type="default"
disabled={isLoading}
onClick={onRefresh}
className="w-[26px]"
icon={icon}
tooltip={{ content: { side: 'bottom', text: 'Refresh logs' } }}
/>
)
}