The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat: add log selection detailed row value copying
TzeYiinga432267ebab7
diff --git a/studio/components/interfaces/Settings/Logs/LogSelectionRenderers/DatabaseApiSelectionRender.tsx b/studio/components/interfaces/Settings/Logs/LogSelectionRenderers/DatabaseApiSelectionRender.tsxindex 16402c0e2e1..1c786f068ae 100644--- a/studio/components/interfaces/Settings/Logs/LogSelectionRenderers/DatabaseApiSelectionRender.tsx+++ b/studio/components/interfaces/Settings/Logs/LogSelectionRenderers/DatabaseApiSelectionRender.tsx@@ -1,7 +1,7 @@import React from 'react'import { LOGS_TAILWIND_CLASSES } from '../Logs.constants'import LogsDivider from '../Logs.Divider'-import { jsonSyntaxHighlight, ResponseCodeFormatter } from '../LogsFormatters'+import { jsonSyntaxHighlight, ResponseCodeFormatter, SelectionDetailedRow } from '../LogsFormatters'const DatabaseApiSelectionRender = ({ log }: any) => {const request = log?.metadata[0]?.request?.[0]@@ -13,27 +13,16 @@ const DatabaseApiSelectionRender = ({ log }: any) => {const clientInfo = request?.headers?.[0]?.x_client_infoconst referer = request?.headers?.[0]?.referer- const DetailedRow = ({ label, value }: { label: string; value: string | React.ReactNode }) => {- return (- <div className="grid grid-cols-12">- <span className="text-scale-900 text-sm col-span-4 whitespace-pre-wrap">{label}</span>- <span className="text-scale-1200 text-sm col-span-8 whitespace-pre-wrap break-all">- {value}- </span>- </div>- )- }-return (<><div className={`${LOGS_TAILWIND_CLASSES.log_selection_x_padding} space-y-2`}>- <DetailedRow label="Status" value={<ResponseCodeFormatter value={status} />} />- <DetailedRow label="Method" value={method} />- <DetailedRow label="Timestamp" value={log.timestamp} />- <DetailedRow label="IP Address" value={ipAddress} />- <DetailedRow label="Origin Country" value={countryOrigin} />- {clientInfo && <DetailedRow label="Client" value={clientInfo} />}- {referer && <DetailedRow label="Referer" value={referer} />}+ <SelectionDetailedRow label="Status" value={status} valueRender={<ResponseCodeFormatter value={status} />} />+ <SelectionDetailedRow label="Method" value={method} />+ <SelectionDetailedRow label="Timestamp" value={log.timestamp} />+ <SelectionDetailedRow label="IP Address" value={ipAddress} />+ <SelectionDetailedRow label="Origin Country" value={countryOrigin} />+ {clientInfo && <SelectionDetailedRow label="Client" value={clientInfo} />}+ {referer && <SelectionDetailedRow label="Referer" value={referer} />}</div><LogsDivider /><div className={`${LOGS_TAILWIND_CLASSES.log_selection_x_padding}`}>diff --git a/studio/components/interfaces/Settings/Logs/LogSelectionRenderers/DatabasePostgresSelectionRender.tsx b/studio/components/interfaces/Settings/Logs/LogSelectionRenderers/DatabasePostgresSelectionRender.tsxindex 1f341742ccc..c583f131055 100644--- a/studio/components/interfaces/Settings/Logs/LogSelectionRenderers/DatabasePostgresSelectionRender.tsx+++ b/studio/components/interfaces/Settings/Logs/LogSelectionRenderers/DatabasePostgresSelectionRender.tsx@@ -2,21 +2,13 @@ import { Alert } from 'ui'import React from 'react'import { LOGS_TAILWIND_CLASSES } from '../Logs.constants'import LogsDivider from '../Logs.Divider'-import { jsonSyntaxHighlight, SeverityFormatter } from '../LogsFormatters'+import { jsonSyntaxHighlight, SelectionDetailedRow, SeverityFormatter } from '../LogsFormatters'const DatabasePostgresSelectionRender = ({ log }: any) => {const postgresUsername = log?.metadata[0]?.parsed[0]?.user_nameconst sessionId = log?.metadata[0]?.parsed[0]?.session_idconst hint = log?.metadata[0]?.parsed[0]?.hint-- const DetailedRow = ({ label, value }: { label: string; value: string | React.ReactNode }) => {- return (- <div className="grid grid-cols-12">- <p className="col-span-4 whitespace-pre-wrap text-sm text-scale-900">{label}</p>- <p className="col-span-8 whitespace-pre-wrap text-base text-scale-1200">{value}</p>- </div>- )- }+ const errorSeverity = log?.metadata[0]?.parsed[0]?.error_severityreturn (<>@@ -29,13 +21,17 @@ const DatabasePostgresSelectionRender = ({ log }: any) => {</div><LogsDivider /><div className={`${LOGS_TAILWIND_CLASSES.log_selection_x_padding} space-y-2`}>- <DetailedRow label="Severity" value={<SeverityFormatter value={log.error_severity} />} />- <DetailedRow label="Postgres Username" value={postgresUsername} />- <DetailedRow label="Session ID" value={sessionId} />+ <SelectionDetailedRow+ label="Severity"+ value={errorSeverity}+ valueRender={<SeverityFormatter value={errorSeverity} />}+ />+ <SelectionDetailedRow label="Postgres Username" value={postgresUsername} />+ <SelectionDetailedRow label="Session ID" value={sessionId} /></div>{hint && (<div className={`mt-4 ${LOGS_TAILWIND_CLASSES.log_selection_x_padding}`}>- <Alert variant="warning" withIcon title={log?.metadata[0]?.parsed[0]?.hint} />+ <Alert variant="warning" withIcon title={hint} /></div>)}<LogsDivider />diff --git a/studio/components/interfaces/Settings/Logs/LogSelectionRenderers/DefaultExplorerSelectionRenderer.tsx b/studio/components/interfaces/Settings/Logs/LogSelectionRenderers/DefaultExplorerSelectionRenderer.tsxindex 479c27ceed6..a4be3324635 100644--- a/studio/components/interfaces/Settings/Logs/LogSelectionRenderers/DefaultExplorerSelectionRenderer.tsx+++ b/studio/components/interfaces/Settings/Logs/LogSelectionRenderers/DefaultExplorerSelectionRenderer.tsx@@ -1,30 +1,7 @@import { LOGS_TAILWIND_CLASSES } from '../Logs.constants'-import { jsonSyntaxHighlight } from '../LogsFormatters'+import { jsonSyntaxHighlight, SelectionDetailedRow } from '../LogsFormatters'const DefaultExplorerSelectionRenderer = ({ log }: any) => {- const DetailedRow = ({- label,- value,- code,- }: {- label: string- value: string | React.ReactNode- code?: boolean- }) => {- return (- <div className="grid grid-cols-12">- <span className="text-scale-900 text-sm col-span-4 whitespace-prep-wrap">{label}</span>- <span- className={`text-scale-1200 text-sm col-span-8 whitespace-prep-wrap ${- code && 'text-xs font-mono'- }`}- >- {value}- </span>- </div>- )- }-const DetailedJsonRow = ({label,value,@@ -63,7 +40,7 @@ const DefaultExplorerSelectionRenderer = ({ log }: any) => {{value && typeof value === 'object' ? (<DetailedJsonRow label={key} value={value} />) : (- <DetailedRow label={key} value={value === null ? 'NULL ' : String(value)} />+ <SelectionDetailedRow label={key} value={value === null ? 'NULL ' : String(value)} />)}</div>)diff --git a/studio/components/interfaces/Settings/Logs/LogSelectionRenderers/DefaultPreviewSelectionRenderer.tsx b/studio/components/interfaces/Settings/Logs/LogSelectionRenderers/DefaultPreviewSelectionRenderer.tsxindex 35d8510e98e..4f2bfd73b5a 100644--- a/studio/components/interfaces/Settings/Logs/LogSelectionRenderers/DefaultPreviewSelectionRenderer.tsx+++ b/studio/components/interfaces/Settings/Logs/LogSelectionRenderers/DefaultPreviewSelectionRenderer.tsx@@ -1,55 +1,30 @@-import { isUnixMicro, unixMicroToIsoTimestamp } from '..'+import { isUnixMicro, PreviewLogData, unixMicroToIsoTimestamp } from '..'import { LOGS_TAILWIND_CLASSES } from '../Logs.constants'-import { jsonSyntaxHighlight } from '../LogsFormatters'+import { jsonSyntaxHighlight, SelectionDetailedRow } from '../LogsFormatters'-const DefaultPreviewSelectionRenderer = ({ log }: any) => {- const DetailedRow = ({- label,- value,- code,- }: {- label: string- value: string | React.ReactNode- code?: boolean- }) => {- return (- <div className="grid grid-cols-12">- <span className="text-scale-900 text-sm col-span-4 whitespace-prep-wrap">{label}</span>- <span- className={`text-scale-1200 text-sm col-span-8 whitespace-prep-wrap ${- code && 'text-xs font-mono'- }`}- >- {value}- </span>- </div>- )- }-- return (- <div className={`${LOGS_TAILWIND_CLASSES.log_selection_x_padding} space-y-6`}>- <div className="flex flex-col gap-3">- <h3 className="text-scale-900 text-sm">Event Message</h3>- <div className="text-xs text-wrap font-mono text-scale-1200 whitespace-pre-wrap overflow-x-auto">- {log.event_message}- </div>+const DefaultPreviewSelectionRenderer = ({ log }: { log: PreviewLogData }) => (+ <div className={`${LOGS_TAILWIND_CLASSES.log_selection_x_padding} space-y-6`}>+ <div className="flex flex-col gap-3">+ <h3 className="text-scale-900 text-sm">Event Message</h3>+ <div className="text-xs text-wrap font-mono text-scale-1200 whitespace-pre-wrap overflow-x-auto">+ {log.event_message}</div>+ </div>- <DetailedRow- label="ISO Timestamp"- value={isUnixMicro(log.timestamp) ? unixMicroToIsoTimestamp(log.timestamp) : log.timestamp}+ <SelectionDetailedRow+ label="ISO Timestamp"+ value={isUnixMicro(log.timestamp) ? unixMicroToIsoTimestamp(log.timestamp) : String(log.timestamp)}+ />+ <div className="flex flex-col gap-3">+ <h3 className="text-scale-900 text-sm">Metadata</h3>+ <pre+ className=" className={`text-scale-1200 text-sm col-span-8 overflow-x-auto text-xs font-mono`}"+ dangerouslySetInnerHTML={{+ __html: jsonSyntaxHighlight(log.metadata!),+ }}/>- <div className="flex flex-col gap-3">- <h3 className="text-scale-900 text-sm">Metadata</h3>- <pre- className=" className={`text-scale-1200 text-sm col-span-8 overflow-x-auto text-xs font-mono`}"- dangerouslySetInnerHTML={{- __html: jsonSyntaxHighlight(log.metadata),- }}- />- </div></div>- )-}+ </div>+)export default DefaultPreviewSelectionRendererdiff --git a/studio/components/interfaces/Settings/Logs/LogSelectionRenderers/FunctionInvocationSelectionRender.tsx b/studio/components/interfaces/Settings/Logs/LogSelectionRenderers/FunctionInvocationSelectionRender.tsxindex 51cfe6bb247..cb772f6964f 100644--- a/studio/components/interfaces/Settings/Logs/LogSelectionRenderers/FunctionInvocationSelectionRender.tsx+++ b/studio/components/interfaces/Settings/Logs/LogSelectionRenderers/FunctionInvocationSelectionRender.tsx@@ -2,7 +2,7 @@ import dayjs from 'dayjs'import { filterFunctionsRequestResponse } from 'lib/logs'import { PreviewLogData } from '..'import { LOGS_TAILWIND_CLASSES } from '../Logs.constants'-import { jsonSyntaxHighlight, ResponseCodeFormatter } from '../LogsFormatters'+import { jsonSyntaxHighlight, ResponseCodeFormatter, SelectionDetailedRow } from '../LogsFormatters'const FunctionInvocationSelectionRender = ({ log }: { log: PreviewLogData }) => {const metadata = log.metadata?.[0]@@ -15,39 +15,22 @@ const FunctionInvocationSelectionRender = ({ log }: { log: PreviewLogData }) =>const deploymentId = metadata.deployment_idconst timestamp = dayjs(log.timestamp / 1000)- const DetailedRow = ({- label,- value,- code,- }: {- label: string- value: string | React.ReactNode- code?: boolean- }) => {- return (- <div className="grid grid-cols-12">- <span className="text-scale-900 text-sm col-span-4 whitespace-pre-wrap">{label}</span>- <span- className={`text-scale-1200 text-sm col-span-8 whitespace-pre-wrap ${- code && 'text-xs font-mono'- }`}- >- {value}- </span>- </div>- )- }-return (<><div className={`${LOGS_TAILWIND_CLASSES.log_selection_x_padding} space-y-2`}>- <DetailedRow label="Status" value={<ResponseCodeFormatter value={status} />} />- <DetailedRow label="Method" value={method} />- <DetailedRow label="Timestamp" value={dayjs(timestamp).format('DD MMM, YYYY HH:mm')} />- <DetailedRow label="Execution Time" value={`${executionTimeMs}ms`} />- <DetailedRow label="Deployment ID" value={deploymentId} />- <DetailedRow label="Log ID" value={log.id} />- <DetailedRow label="Request Path" value={requestUrl.pathname + requestUrl.search} />+ <SelectionDetailedRow label="Status" value={status} valueRender={<ResponseCodeFormatter value={status} />} />+ <SelectionDetailedRow label="Method" value={method} />+ <SelectionDetailedRow+ label="Timestamp"+ value={dayjs(timestamp).format('DD MMM, YYYY HH:mm')}+ />+ <SelectionDetailedRow label="Execution Time" value={`${executionTimeMs}ms`} />+ <SelectionDetailedRow label="Deployment ID" value={deploymentId} />+ <SelectionDetailedRow label="Log ID" value={log.id} />+ <SelectionDetailedRow+ label="Request Path"+ value={requestUrl.pathname + requestUrl.search}+ /></div><div className={`${LOGS_TAILWIND_CLASSES.log_selection_x_padding}`}><h3 className="text-lg text-scale-1200 mb-4">Request body</h3>diff --git a/studio/components/interfaces/Settings/Logs/LogSelectionRenderers/FunctionLogsSelectionRender.tsx b/studio/components/interfaces/Settings/Logs/LogSelectionRenderers/FunctionLogsSelectionRender.tsxindex 9d371f162d7..fb5a925767b 100644--- a/studio/components/interfaces/Settings/Logs/LogSelectionRenderers/FunctionLogsSelectionRender.tsx+++ b/studio/components/interfaces/Settings/Logs/LogSelectionRenderers/FunctionLogsSelectionRender.tsx@@ -1,34 +1,11 @@import dayjs from 'dayjs'import { LOGS_TAILWIND_CLASSES } from '../Logs.constants'-import { jsonSyntaxHighlight, SeverityFormatter } from '../LogsFormatters'+import { jsonSyntaxHighlight, SelectionDetailedRow, SeverityFormatter } from '../LogsFormatters'const FunctionLogsSelectionRender = ({ log }: any) => {const timestamp = dayjs(log.timestamp / 1000)const metadata = log.metadata[0]- const DetailedRow = ({- label,- value,- code,- }: {- label: string- value: string | React.ReactNode- code?: boolean- }) => {- return (- <div className="grid grid-cols-12">- <span className="text-scale-900 text-sm col-span-4 whitespace-pre-wrap">{label}</span>- <span- className={`text-scale-1200 text-sm col-span-8 whitespace-pre-wrap ${- code && 'text-xs font-mono'- }`}- >- {value}- </span>- </div>- )- }-return (<><div className={`${LOGS_TAILWIND_CLASSES.log_selection_x_padding}`}>@@ -39,11 +16,15 @@ const FunctionLogsSelectionRender = ({ log }: any) => {</div><div className="h-px w-full bg-panel-border-interior-light dark:bg-panel-border-interior-dark"></div><div className={`${LOGS_TAILWIND_CLASSES.log_selection_x_padding} space-y-2`}>- <DetailedRow label="Severity" value={<SeverityFormatter value={metadata.level} />} />- <DetailedRow label="Deployment version" value={metadata.version} />- <DetailedRow label="Timestamp" value={timestamp.format('DD MMM, YYYY HH:mm')} />- <DetailedRow label="Execution ID" value={metadata.execution_id} />- <DetailedRow label="Deployment ID" value={metadata.deployment_id} />+ <SelectionDetailedRow+ label="Severity"+ value={metadata.level}+ valueRender={<SeverityFormatter value={metadata.level} />}+ />+ <SelectionDetailedRow label="Deployment version" value={metadata.version} />+ <SelectionDetailedRow label="Timestamp" value={timestamp.format('DD MMM, YYYY HH:mm')} />+ <SelectionDetailedRow label="Execution ID" value={metadata.execution_id} />+ <SelectionDetailedRow label="Deployment ID" value={metadata.deployment_id} /></div><div className={`${LOGS_TAILWIND_CLASSES.log_selection_x_padding}`}><h3 className="text-lg text-scale-1200 mb-4">Metadata</h3>diff --git a/studio/components/interfaces/Settings/Logs/LogsFormatters.tsx b/studio/components/interfaces/Settings/Logs/LogsFormatters.tsxindex 82156ba5284..87ed2f6f855 100644--- a/studio/components/interfaces/Settings/Logs/LogsFormatters.tsx+++ b/studio/components/interfaces/Settings/Logs/LogsFormatters.tsx@@ -8,11 +8,41 @@ import { IconAlertCircle, IconInfo } from 'ui'import dayjs from 'dayjs'import React from 'react'import { isUnixMicro, unixMicroToIsoTimestamp } from '.'+import CopyButton from 'components/ui/CopyButton'export const RowLayout: React.FC = ({ children }) => (<div className="flex h-full w-full items-center gap-4">{children}</div>)+export const SelectionDetailedRow = ({+ label,+ value,+ valueRender,+}: {+ label: string+ value: string+ valueRender?: React.ReactNode+}) => {+ return (+ <div className="grid grid-cols-12 group">+ <span className="text-scale-900 text-sm col-span-4 whitespace-pre-wrap">{label}</span>+ <span className="text-scale-1200 text-sm col-span-6 whitespace-pre-wrap break-all">+ {valueRender ?? value}+ </span>+ <CopyButton+ bounceIconOnCopy+ text={value}+ className="group-hover:opacity-100 opacity-0 my-auto transition col-span-2 h-4 w-4 px-0 py-0"+ type="text"+ title="Copy to clipboard"+ >+ {''}+ </CopyButton>+ </div>+ )+}++// used for column renderersexport const TextFormatter: React.FC<{ className?: string; value: string }> = ({value,className,diff --git a/studio/components/ui/CopyButton.tsx b/studio/components/ui/CopyButton.tsxindex 294a0cdb179..690f3399d7e 100644--- a/studio/components/ui/CopyButton.tsx+++ b/studio/components/ui/CopyButton.tsx@@ -5,8 +5,16 @@ import { useEffect, useState } from 'react'export interface CopyButtonProps extends ButtonProps {text: string+ // used for text-less feedback+ bounceIconOnCopy?: boolean}-const CopyButton: React.FC<CopyButtonProps> = ({ text, children, onClick, ...props }) => {+const CopyButton: React.FC<CopyButtonProps> = ({+ text,+ children,+ onClick,+ bounceIconOnCopy,+ ...props+}) => {const [showCopied, setShowCopied] = useState(false)useEffect(() => {@@ -22,7 +30,14 @@ const CopyButton: React.FC<CopyButtonProps> = ({ text, children, onClick, ...procopyToClipboard(text)onClick?.(e)}}- icon={<IconClipboard size="tiny" />}+ icon={+ <IconClipboard+ size="tiny"+ className={[showCopied && bounceIconOnCopy ? 'animate-bounce' : '', 'transition'].join(+ ' '+ )}+ />+ }{...props}>{children ?? (showCopied ? 'Copied' : 'Copy')}