- {topDivider && (
-
- )}
{Icon ? (
) : (
)}
-
- {title}
-
+ {title}
{summary !== undefined && summary !== null && summary !== '' ? (
{summary}
diff --git a/apps/studio/components/interfaces/UnifiedLogs/components/LogFieldRow.tsx b/apps/studio/components/interfaces/UnifiedLogs/components/LogFieldRow.tsx
new file mode 100644
index 00000000000..79284e02377
--- /dev/null
+++ b/apps/studio/components/interfaces/UnifiedLogs/components/LogFieldRow.tsx
@@ -0,0 +1,72 @@
+import type { Table } from '@tanstack/react-table'
+import type { ReactNode } from 'react'
+import { cn } from 'ui'
+
+import type { DataTableFilterField } from '@/components/ui/DataTable/DataTable.types'
+import { DataTableSheetRowAction } from '@/components/ui/DataTable/DataTableSheetRowAction'
+
+interface LogFieldRowProps
{
+ label: string
+ /** Value to copy, and to filter by when `fieldValue` is set. */
+ value: string | number
+ /** Rendered value; defaults to `value`. */
+ children?: ReactNode
+ /** Filter field id; omit for copy-only rows. */
+ fieldValue?: DataTableFilterField['value']
+ filterFields: DataTableFilterField[]
+ table?: Table
+ disabled?: boolean
+ /** Truncate the label to one line instead of wrapping it. */
+ truncateLabel?: boolean
+ alignOffset?: number
+ className?: string
+}
+
+/** Key/value row for a log field, opening copy and filter actions on click. */
+export function LogFieldRow({
+ label,
+ value,
+ children,
+ fieldValue,
+ filterFields,
+ table,
+ disabled,
+ truncateLabel = false,
+ alignOffset = 16,
+ className,
+}: LogFieldRowProps) {
+ return (
+
+
+
+ {label}
+ {' '}
+
+ {children ?? value}
+
+
+
+ )
+}
diff --git a/apps/studio/components/ui/DataTable/DataTableSheetRowAction.tsx b/apps/studio/components/ui/DataTable/DataTableSheetRowAction.tsx
index 207f4dc9687..f5f71dbdf94 100644
--- a/apps/studio/components/ui/DataTable/DataTableSheetRowAction.tsx
+++ b/apps/studio/components/ui/DataTable/DataTableSheetRowAction.tsx
@@ -13,6 +13,7 @@ import {
import { ComponentPropsWithRef, useEffect, useState } from 'react'
import {
cn,
+ copyToClipboard,
DropdownMenu,
DropdownMenuContent,
DropdownMenuGroup,
@@ -25,9 +26,7 @@ import {
isLogsFilterColumnValue,
type LogsColumnFilterValue,
} from '@/components/interfaces/UnifiedLogs/UnifiedLogs.filters'
-import CopyButton from '@/components/ui/CopyButton'
import { DataTableFilterField } from '@/components/ui/DataTable/DataTable.types'
-import { useCopyToClipboard } from '@/hooks/ui/useCopyToClipboard'
interface DataTableSheetRowActionProps<
TData,
@@ -36,8 +35,9 @@ interface DataTableSheetRowActionProps<
fieldValue?: TFields['value']
filterFields: TFields[]
value: string | number
- table: Table
+ table?: Table
label?: string
+ alignOffset?: number
}
export function DataTableSheetRowAction>({
@@ -48,10 +48,10 @@ export function DataTableSheetRowAction) {
- const { copy } = useCopyToClipboard()
const [open, setOpen] = useState(false)
/**
@@ -72,7 +72,7 @@ export function DataTableSheetRowAction f.value === fieldValue) : undefined
const column =
!!fieldValue && !!field
- ? table.getAllColumns().find((c) => c.id === fieldValue.toString())
+ ? table?.getAllColumns().find((c) => c.id === fieldValue.toString())
: undefined
function renderOptions() {
@@ -96,7 +96,7 @@ export function DataTableSheetRowAction
- Add as filter for {column?.id}
+ Add filter
)
case 'input':
@@ -111,7 +111,7 @@ export function DataTableSheetRowAction
- Add as filter for {column?.id}
+ Add filter
)
case 'slider':
@@ -182,42 +182,41 @@ export function DataTableSheetRowAction
- {
- if (e.key === 'ArrowDown') {
- // REMINDER: default behavior is to open the dropdown menu
- // But because we use it to navigate between rows, we need to prevent it
- // and only use "Enter" to select the option
- e.preventDefault()
- }
- onKeyDown?.(e)
- }}
- {...props}
+ return (
+
+ {
+ if (e.key === 'ArrowDown') {
+ // REMINDER: default behavior is to open the dropdown menu
+ // But because we use it to navigate between rows, we need to prevent it
+ // and only use "Enter" to select the option
+ e.preventDefault()
+ }
+ onKeyDown?.(e)
+ }}
+ {...props}
+ >
+ {children}
+
+
+
+ {!!field && !!column && (
+ <>
+ {renderOptions()}
+
+ >
+ )}
+
+ copyToClipboard(String(value))}
+ className="flex items-center gap-2"
>
- {children}
-
-
-
- {renderOptions()}
-
-
-
- copy(String(value), { timeout: 1000 })}
- className="flex items-center gap-2"
- >
-
- Copy {label}
-
-
-
- )
- }
-
- return
+
+ Copy {label}
+
+
+
+ )
}