The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat: add query previews for log templates, added more descriptions
TzeYiingdb71b9971bce
diff --git a/studio/components/interfaces/Settings/Logs/Logs.constants.ts b/studio/components/interfaces/Settings/Logs/Logs.constants.tsindex 2bad6329f66..323187582f7 100644--- a/studio/components/interfaces/Settings/Logs/Logs.constants.ts+++ b/studio/components/interfaces/Settings/Logs/Logs.constants.ts@@ -15,7 +15,7 @@ export const TEMPLATES: LogTemplate[] = [},{label: 'Commits By User',- description: 'Print which users made what commits on the database',+ description: 'Count of commits made by users on the database',mode: 'custom',searchString: `SELECTp.user_name, count(*) as count@@ -31,7 +31,7 @@ group by},{label: 'Metadata IP',- description: 'Print all the IP addresses that used Supabase api',+ description: 'List all IP addresses that used the Supabase API',mode: 'custom',searchString: `SELECT timestamp, h.x_real_ipfrom edge_logs@@ -44,6 +44,7 @@ where h.x_real_ip is not null},{label: 'Requests by Country',+ description: 'List all ISO 3166-1 alpha-2 country codes that used the Supabase API',mode: 'custom',searchString: `SELECTcf.country, count(*) as count@@ -61,6 +62,7 @@ order by{label: 'Slow Response Time',mode: 'custom',+ description: 'List all Supabase API requests that are slow',searchString: `selecttimestamp,event_message,@@ -78,6 +80,7 @@ limit 100},{label: '500 Request Codes',+ description: 'List all Supabase API requests that responded witha 5XX status code',mode: 'custom',searchString: `SELECTtimestamp,@@ -96,6 +99,7 @@ limit 100},{label: 'Top Paths',+ description: 'List the most requested Supabase API paths',mode: 'custom',searchString: `SELECTr.path as path,@@ -115,6 +119,7 @@ limit 100},{label: 'REST Requests',+ description: 'List all PostgREST requests',mode: 'custom',searchString: `SELECTtimestamp,@@ -132,6 +137,7 @@ limit 100},{label: 'Errors',+ description: 'List all Postgres error messages with ERROR, FATAL, or PANIC severity',mode: 'custom',searchString: `SELECTt.timestamp,diff --git a/studio/components/ui/CardButton.tsx b/studio/components/ui/CardButton.tsxindex 5b33bfeb093..11d7c480f13 100644--- a/studio/components/ui/CardButton.tsx+++ b/studio/components/ui/CardButton.tsx@@ -13,6 +13,7 @@ interface Props {imgAlt?: stringonClick?: () => voidicon?: React.ReactNode+ containerHeightClassName?: string}const CardButton: FC<Props> = ({@@ -26,6 +27,7 @@ const CardButton: FC<Props> = ({imgAlt,onClick,icon,+ containerHeightClassName="h-32"}) => {const LinkContainer = ({ children }: { children: React.ReactNode }) => (<Link href={linkHref}>{children}</Link>@@ -42,8 +44,9 @@ const CardButton: FC<Props> = ({'group relative text-left','bg-panel-header-light dark:bg-panel-header-dark','border border-panel-border-light dark:border-panel-border-dark',- 'rounded-md py-4 px-6 flex flex-row h-32',+ 'rounded-md py-4 px-6 flex flex-row','transition ease-in-out duration-150',+ containerHeightClassName]if (isLink) {diff --git a/studio/pages/project/[ref]/logs-explorer/templates.tsx b/studio/pages/project/[ref]/logs-explorer/templates.tsxindex 8ec25b1a48d..2801b2e38d3 100644--- a/studio/pages/project/[ref]/logs-explorer/templates.tsx+++ b/studio/pages/project/[ref]/logs-explorer/templates.tsx@@ -1,8 +1,8 @@-import React from 'react'+import React, { useState } from 'react'import { NextPage } from 'next'import { useRouter } from 'next/router'-import { observer } from 'mobx-react-lite'-import { IconCode, Badge } from '@supabase/ui'+import { observer, useStaticRendering } from 'mobx-react-lite'+import { IconCode, Badge, Collapsible, Button, Popover } from '@supabase/ui'import { withAuth } from 'hooks'import { TEMPLATES } from 'components/interfaces/Settings/Logs'import LogsExplorerLayout from 'components/layouts/LogsExplorerLayout/LogsExplorerLayout'@@ -17,6 +17,7 @@ export const LogsExplorerPage: NextPage = () => {<div><div className="grid grid-cols-3 gap-6">{TEMPLATES.filter((template) => template.mode === 'custom').map((template) => {+ const [showPreview, setShowPreview] = useState(false)return (<CardButtontitle={template.label}@@ -35,8 +36,35 @@ export const LogsExplorerPage: NextPage = () => {</div></div>}+ containerHeightClassName="h-40"linkHref={`/project/${ref}/logs-explorer?q=${encodeURI(template.searchString)}`}description={template.description}+ footer={+ <div className="flex flex-row justify-end">+ <Popover+ onOpenChange={setShowPreview}+ open={showPreview}+ className="rounded-lg bg-scale-100"+ size="content"+ overlay={+ <pre className="rounded-lg whitespace-pre-line bg-scale-100 p-4 text-sm break-words">+ {template.searchString}+ </pre>+ }+ >+ <Button+ type="default"+ as="span"+ onClick={(e) => {+ e.preventDefault()+ setShowPreview(!showPreview)+ }}+ >+ Preview+ </Button>+ </Popover>+ </div>+ }/>)})}