Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

added focused log line metadata display

TzeYiing42d5332b89c2
diff --git a/studio/components/to-be-cleaned/Table.tsx b/studio/components/to-be-cleaned/Table.tsx
index 611f54a0d9f..2ff1ad464f7 100644
--- a/studio/components/to-be-cleaned/Table.tsx
+++ b/studio/components/to-be-cleaned/Table.tsx
@@ -68,10 +68,10 @@ type TdProps = {
colSpan?: number
className?: string
style?: React.CSSProperties
-}
-const Td: React.FC<TdProps> = ({ children, colSpan, className, style }) => {
+} & React.HTMLProps<HTMLTableCellElement>
+const Td: React.FC<TdProps> = ({ children, colSpan, className, style , ...rest}) => {
return (
- <td className={className} colSpan={colSpan} style={style}>
+ <td className={className} colSpan={colSpan} style={style} {...rest}>
{children}
</td>
)
diff --git a/studio/components/ui/Logs/LogSelection.tsx b/studio/components/ui/Logs/LogSelection.tsx
new file mode 100644
index 00000000000..4492cbacb1e
--- /dev/null
+++ b/studio/components/ui/Logs/LogSelection.tsx
@@ -0,0 +1,31 @@
+import React from 'react'
+import { Button, Input, Typography } from '@supabase/ui'
+import Panel from 'components/to-be-cleaned/Panel'
+import { LogData } from "./LogTable"
+import dayjs from 'dayjs'
+
+interface Props {
+ log: LogData
+ onClose: () => void
+}
+
+/**
+ * Log selection display
+ */
+const LogSelection = ({ log, onClose }: Props) => (
+ <Panel
+ title={
+ <div className="flex flex-row justify-between items-center w-full">
+ <Typography.Title level={5}>{dayjs(log.timestamp / 1000).toString()}</Typography.Title>
+ <Button size="tiny" type="secondary" onClick={onClose}>Close</Button>
+ </div>
+ }
+ >
+ <div className="p-4 h-full">
+ <Input.TextArea label="Metadata" className="font-mono" rows={25} disabled value={JSON.stringify(log.metadata, null, 2)} />
+ </div>
+
+
+ </Panel>
+)
+export default LogSelection
\ No newline at end of file
diff --git a/studio/components/ui/Logs/LogTable.tsx b/studio/components/ui/Logs/LogTable.tsx
index deb6d6dbad7..c77b30d7c88 100644
--- a/studio/components/ui/Logs/LogTable.tsx
+++ b/studio/components/ui/Logs/LogTable.tsx
@@ -1,7 +1,9 @@
-import React from 'react'
+import React, { useEffect, useState } from 'react'
import Table from 'components/to-be-cleaned/Table'
-import { Typography } from '@supabase/ui'
+import { Typography, SidePanel } from '@supabase/ui'
import dayjs from 'dayjs'
+import { Panel } from '@supabase/ui/dist/cjs/components/Tabs/Tabs'
+import LogSelection from './LogSelection'
interface Props {
data: LogData[] | null | undefined
@@ -17,13 +19,14 @@ export interface LogData {
metadata: Metadata
}
-
/**
- * Logs table view
+ * Logs table view with focus side panel
*/
const LogTable = ({ data }: Props) => {
const columns = ["timestamp", "event_message"]
+ const [focusedLog, setFocusedLog] = useState<LogData | null>(null);
+
if (!data) {
return null
}
@@ -32,18 +35,24 @@ const LogTable = ({ data }: Props) => {
return <Typography.Text className="text-center">No data returned from query</Typography.Text>
}
- return (
- <Table containerClassName="mx-auto container"
+ return (<section className="flex flex-row gap-x-4">
+ <Table containerClassName="mx-auto container overflow-y h-full"
head={columns.map((c) => <Table.th key={c}>{c}</Table.th>)}
body={data.map(d =>
<Table.tr key={d.id}>
- {columns.map(c => <Table.td key={c} >
+ {columns.map(c => <Table.td key={c} className={`${d.id === focusedLog?.id ? "bg-green-800" : ""} `} onClick={() => setFocusedLog(d)}>
{c === "timestamp" &&
- <Typography.Text className="block bg-green-800" code>{dayjs(d[c] / 1000).toString()}</Typography.Text>}
- {c === "event_message" && <Typography.Text className="block" code>{d[c]}</Typography.Text>}
+ <Typography.Text className="block bg-green-800" small code>{dayjs(d[c] / 1000).toString()}</Typography.Text>}
+ {c === "event_message" && <Typography.Text className="block" small code>{d[c]}</Typography.Text>}
</Table.td>)}
</Table.tr>)}
/>
+ {focusedLog && (
+ <div className="sticky top-0">
+ <LogSelection onClose={() => setFocusedLog(null)} log={focusedLog} />
+ </div>
+ )}
+ </section>
)
}
export default LogTable
\ No newline at end of file