The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Chore/edge functions fixes (#31317)
Joshen Lim6f1ccc5d2145
diff --git a/apps/studio/components/interfaces/Functions/EdgeFunctionDetails/EdgeFunctionDetails.tsx b/apps/studio/components/interfaces/Functions/EdgeFunctionDetails/EdgeFunctionDetails.tsxindex 483a1fa9a84..aa42058a0a5 100644--- a/apps/studio/components/interfaces/Functions/EdgeFunctionDetails/EdgeFunctionDetails.tsx+++ b/apps/studio/components/interfaces/Functions/EdgeFunctionDetails/EdgeFunctionDetails.tsx@@ -101,7 +101,7 @@ const EdgeFunctionDetails = () => {return (<>- <div className="space-y-4 pb-16">+ <div className="space-y-4 pb-16 pt-3"><Form id={formId} initialValues={{}} onSubmit={onUpdateFunction}>{({ handleReset, values, initialValues, resetForm }: any) => {const hasChanges = JSON.stringify(values) !== JSON.stringify(initialValues)diff --git a/apps/studio/components/interfaces/Functions/EdgeFunctionsListItem.tsx b/apps/studio/components/interfaces/Functions/EdgeFunctionsListItem.tsxindex 428d29b3372..269f0183ea0 100644--- a/apps/studio/components/interfaces/Functions/EdgeFunctionsListItem.tsx+++ b/apps/studio/components/interfaces/Functions/EdgeFunctionsListItem.tsx@@ -36,7 +36,7 @@ const EdgeFunctionsListItem = ({ function: item }: EdgeFunctionsListItemProps) =<Table.trkey={item.id}onClick={() => {- router.push(`/project/${ref}/functions/${item.slug}/details`)+ router.push(`/project/${ref}/functions/${item.slug}`)}}><Table.td>diff --git a/apps/studio/components/interfaces/Functions/FunctionsNav.tsx b/apps/studio/components/interfaces/Functions/FunctionsNav.tsxindex 47b6d4f734d..fe37ab1afca 100644--- a/apps/studio/components/interfaces/Functions/FunctionsNav.tsx+++ b/apps/studio/components/interfaces/Functions/FunctionsNav.tsx@@ -11,17 +11,18 @@ const FunctionsNav = ({ item }: any) => {defaultActiveId="1"type="underlined"size="medium"- activeId={!activeRoute ? 'metrics' : activeRoute}+ baseClassNames="!space-y-0"+ activeId={!activeRoute ? 'overview' : activeRoute}onChange={(e: string) => {if (item?.slug) {- router.push(`/project/${ref}/functions/${item.slug}/${e === 'metrics' ? '' : e}`)+ router.push(`/project/${ref}/functions/${item.slug}/${e === 'overview' ? '' : e}`)}}}>- <Tabs.Panel id="details" label="Details" />- <Tabs.Panel id="metrics" label="Metrics" />+ <Tabs.Panel id="overview" label="Overview" /><Tabs.Panel id="invocations" label="Invocations" /><Tabs.Panel id="logs" label="Logs" />+ <Tabs.Panel id="details" label="Details" /></Tabs>)}diff --git a/apps/studio/components/interfaces/Settings/Logs/LogTable.tsx b/apps/studio/components/interfaces/Settings/Logs/LogTable.tsxindex f83f79c0f8d..91cc4ff5233 100644--- a/apps/studio/components/interfaces/Settings/Logs/LogTable.tsx+++ b/apps/studio/components/interfaces/Settings/Logs/LogTable.tsx@@ -92,15 +92,10 @@ const LogTable = ({const { profile } = useProfile()const { show: showContextMenu } = useContextMenu()+ const downloadCsvRef = useRef<HTMLDivElement>(null)const [cellPosition, setCellPosition] = useState<any>()-const [selectionOpen, setSelectionOpen] = useState(false)-- useEffect(() => {- if (selectedLog || isSelectedLogLoading) {- setSelectionOpen(true)- }- }, [selectedLog, isSelectedLogLoading])+ const [selectedRow, setSelectedRow] = useState<LogData | null>(null)const canCreateLogQuery = useCheckPermissions(PermissionAction.CREATE, 'user_content', {resource: { type: 'log_sql', owner_id: profile?.id },@@ -148,6 +143,7 @@ const LogTable = ({})let columns = DEFAULT_COLUMNS+if (!queryType) {columns} else {@@ -235,21 +231,10 @@ const LogTable = ({}}- const copyResultsToClipboard = () => {- copyToClipboard(stringData, () => {- toast.success('Results copied to clipboard')- })- }-- const downloadCsvRef = useRef<HTMLDivElement>(null)- function downloadCSV() {- downloadCsvRef.current?.click()- }-const LogsExplorerTableHeader = () => (<divclassName={cn(- 'flex w-full items-center justify-between border-t bg-surface-100 px-5 py-2',+ 'flex w-full items-center justify-between border-t bg-surface-100 px-5 py-2',className,{ hidden: !showHeader })}@@ -262,11 +247,23 @@ const LogTable = ({</Button></DropdownMenuTrigger><DropdownMenuContent align="start">- <DropdownMenuItem onClick={downloadCSV} className="space-x-2">+ <DropdownMenuItem+ onClick={() => {+ downloadCsvRef.current?.click()+ }}+ className="space-x-2"+ ><Download size={14} /><div>Download CSV</div></DropdownMenuItem>- <DropdownMenuItem onClick={copyResultsToClipboard} className="space-x-2">+ <DropdownMenuItem+ onClick={() => {+ copyToClipboard(stringData, () => {+ toast.success('Results copied to clipboard')+ })+ }}+ className="space-x-2"+ ><Clipboard size={14} /><div>Copy to clipboard</div></DropdownMenuItem>@@ -352,14 +349,22 @@ const LogTable = ({else return <LogsTableEmptyState />}- const [selectedRow, setSelectedRow] = useState<LogData | null>(null)-function onRowClick(row: LogData) {setSelectedRow(row)onSelectedLogChange?.(row)}+ useEffect(() => {+ if (selectedLog || isSelectedLogLoading) {+ setSelectionOpen(true)+ }+ if (!isSelectedLogLoading && !selectedLog) {+ setSelectedRow(null)+ }+ }, [selectedLog, isSelectedLogLoading])+if (!data) return null+return (<section className={'h-full flex w-full flex-col flex-1'}>{!queryType && <LogsExplorerTableHeader />}@@ -369,7 +374,7 @@ const LogTable = ({<DataGridrole="table"style={{ height: '100%' }}- className={cn('flex-1 flex-grow h-full border-none', {+ className={cn('flex-1 flex-grow h-full border-0', {'data-grid--simple-logs': queryType,'data-grid--logs-explorer': !queryType,})}diff --git a/apps/studio/components/interfaces/Settings/Logs/Logs.constants.ts b/apps/studio/components/interfaces/Settings/Logs/Logs.constants.tsindex 4af99e34e51..ee10cbcf03a 100644--- a/apps/studio/components/interfaces/Settings/Logs/Logs.constants.ts+++ b/apps/studio/components/interfaces/Settings/Logs/Logs.constants.ts@@ -350,6 +350,9 @@ export const SQL_FILTER_TEMPLATES: any = {..._SQL_FILTER_COMMON,database: (value: string) => `m.project like '${value}%'`,},+ pg_cron_logs: {+ ..._SQL_FILTER_COMMON,+ },}export enum LogsTableName {diff --git a/apps/studio/components/interfaces/Settings/Logs/LogsPreviewer.tsx b/apps/studio/components/interfaces/Settings/Logs/LogsPreviewer.tsxindex ee03bbd0c93..8af8a9c74c3 100644--- a/apps/studio/components/interfaces/Settings/Logs/LogsPreviewer.tsx+++ b/apps/studio/components/interfaces/Settings/Logs/LogsPreviewer.tsx@@ -39,6 +39,7 @@ interface LogsPreviewerProps {condensedLayout?: booleantableName?: LogsTableNameEmptyState?: React.ReactNode+ filterPanelClassName?: string}export const LogsPreviewer = ({projectRef,@@ -48,6 +49,7 @@ export const LogsPreviewer = ({tableName,children,EmptyState,+ filterPanelClassName,}: PropsWithChildren<LogsPreviewerProps>) => {const router = useRouter()const { s, ite, its, db } = useParams()@@ -150,6 +152,7 @@ export const LogsPreviewer = ({}const handleSearch: LogSearchCallback = async (event, { query, to, from }) => {if (event === 'search-input-change') {+ setSelectedLogId(null)setFilters((prev) => ({ ...prev, search_query: query }))router.push({pathname: router.pathname,@@ -199,6 +202,7 @@ export const LogsPreviewer = ({return (<div className="flex-1 flex flex-col h-full"><PreviewFilterPanel+ className={filterPanelClassName}csvData={logData}isLoading={isLoading}newCount={newCount}diff --git a/apps/studio/components/interfaces/Settings/Logs/PreviewFilterPanel.tsx b/apps/studio/components/interfaces/Settings/Logs/PreviewFilterPanel.tsxindex ffe90c561d0..3393bc746d1 100644--- a/apps/studio/components/interfaces/Settings/Logs/PreviewFilterPanel.tsx+++ b/apps/studio/components/interfaces/Settings/Logs/PreviewFilterPanel.tsx@@ -1,13 +1,21 @@-import { Eye, EyeOff, RefreshCw, Search, Terminal } from 'lucide-react'+import { Eye, EyeOff, RefreshCw, Search, Terminal, X } from 'lucide-react'import Link from 'next/link'import { useRouter } from 'next/router'import { useEffect, useState } from 'react'-import { Button, Input, TooltipContent_Shadcn_, TooltipTrigger_Shadcn_, Tooltip_Shadcn_ } from 'ui'import { useParams } from 'common'+import { ButtonTooltip } from 'components/ui/ButtonTooltip'import CSVButton from 'components/ui/CSVButton'import DatabaseSelector from 'components/ui/DatabaseSelector'import { useLoadBalancersQuery } from 'data/read-replicas/load-balancers-query'+import {+ Button,+ Input,+ TooltipContent_Shadcn_,+ TooltipTrigger_Shadcn_,+ Tooltip_Shadcn_,+ cn,+} from 'ui'import DatePickers from './Logs.DatePickers'import {FILTER_OPTIONS,@@ -38,6 +46,7 @@ interface PreviewFilterPanelProps {onFiltersChange: (filters: Filters) => voidfilters: FiltersonSelectedDatabaseChange: (id: string) => void+ className?: string}/**@@ -61,6 +70,7 @@ const PreviewFilterPanel = ({filters,table,onSelectedDatabaseChange,+ className,}: PreviewFilterPanelProps) => {const router = useRouter()const { ref } = useParams()@@ -121,7 +131,13 @@ const PreviewFilterPanel = ({const handleInputSearch = (query: string) => onSearch('search-input-change', { query })return (- <div className={'flex w-full items-center justify-between' + (condensedLayout ? ' p-3' : '')}>+ <div+ className={cn(+ 'flex w-full items-center justify-between',+ condensedLayout ? ' p-3' : '',+ className+ )}+ ><div className="flex flex-row items-center gap-x-2"><formid="log-panel-search"@@ -147,14 +163,27 @@ const PreviewFilterPanel = ({}value={search}actions={- hasEdits && (- <button- onClick={() => handleInputSearch(search)}- className="mx-2 text-foreground-light hover:text-foreground"- >- {'↲'}- </button>- )+ <div className="flex items-center gap-x-1 mr-0.5">+ {hasEdits && (+ <ButtonTooltip+ icon={<span>↲</span>}+ type="text"+ className="px-1 h-[20px]"+ onClick={() => handleInputSearch(search)}+ tooltip={{ content: { side: 'bottom', text: 'Search for events' } }}+ />+ )}++ {search.length > 0 && (+ <ButtonTooltip+ icon={<X />}+ type="text"+ className="p-[1px] h-[20px]"+ onClick={() => handleInputSearch('')}+ tooltip={{ content: { side: 'bottom', text: 'Clear search' } }}+ />+ )}+ </div>}/></form>diff --git a/apps/studio/components/layouts/FunctionsLayout/FunctionsLayout.tsx b/apps/studio/components/layouts/FunctionsLayout/FunctionsLayout.tsxindex 1b3a03d852d..bf5b9d1dc36 100644--- a/apps/studio/components/layouts/FunctionsLayout/FunctionsLayout.tsx+++ b/apps/studio/components/layouts/FunctionsLayout/FunctionsLayout.tsx@@ -89,12 +89,12 @@ const FunctionsLayout = ({ title, children }: PropsWithChildren<FunctionsLayoutP</h1></Link>{name && (- <div className="mt-1.5 flex items-center space-x-4">+ <div className="flex items-center space-x-4"><span className="text-foreground-light"><svgviewBox="0 0 24 24"- width="16"- height="16"+ width="24"+ height="24"stroke="currentColor"strokeWidth="1"strokeLinecap="round"@@ -105,7 +105,7 @@ const FunctionsLayout = ({ title, children }: PropsWithChildren<FunctionsLayoutP<path d="M16 3.549L7.12 20.600"></path></svg></span>- <h5 className="text-lg text-foreground">{name}</h5>+ <h1 className="text-2xl text-foreground">{name}</h1></div>)}</div>diff --git a/apps/studio/pages/project/[ref]/functions/[functionSlug]/index.tsx b/apps/studio/pages/project/[ref]/functions/[functionSlug]/index.tsxindex 053397213a9..7362374780a 100644--- a/apps/studio/pages/project/[ref]/functions/[functionSlug]/index.tsx+++ b/apps/studio/pages/project/[ref]/functions/[functionSlug]/index.tsx@@ -151,7 +151,7 @@ const PageLayout: NextPageWithLayout = () => {return <NoPermission isFullPage resourceText="access this edge function" />}return (- <div className="space-y-6 py-2">+ <div className="space-y-6 py-3"><div className="flex flex-row items-center gap-2"><div className="flex items-center">{CHART_INTERVALS.map((item, i) => {diff --git a/apps/studio/pages/project/[ref]/functions/[functionSlug]/invocations.tsx b/apps/studio/pages/project/[ref]/functions/[functionSlug]/invocations.tsxindex 29c2e48d83b..5ecb05564fd 100644--- a/apps/studio/pages/project/[ref]/functions/[functionSlug]/invocations.tsx+++ b/apps/studio/pages/project/[ref]/functions/[functionSlug]/invocations.tsx@@ -19,9 +19,11 @@ export const LogPage: NextPageWithLayout = () => {return (<LogsPreviewer+ condensedLayoutprojectRef={ref as string}queryType={'fn_edge'}filterOverride={{ function_id: selectedFunction.id }}+ filterPanelClassName="px-0"/>)}diff --git a/apps/studio/pages/project/[ref]/functions/[functionSlug]/logs.tsx b/apps/studio/pages/project/[ref]/functions/[functionSlug]/logs.tsxindex c3d5282e6d9..e82144574d1 100644--- a/apps/studio/pages/project/[ref]/functions/[functionSlug]/logs.tsx+++ b/apps/studio/pages/project/[ref]/functions/[functionSlug]/logs.tsx@@ -16,9 +16,11 @@ export const LogPage: NextPageWithLayout = () => {return (<LogsPreviewer+ condensedLayoutprojectRef={ref as string}queryType={'functions'}filterOverride={{ 'metadata.function_id': selectedFunction.id }}+ filterPanelClassName="px-0"/>)}diff --git a/apps/studio/pages/project/[ref]/functions/index.tsx b/apps/studio/pages/project/[ref]/functions/index.tsxindex 9a819b83a6f..684fa07eda2 100644--- a/apps/studio/pages/project/[ref]/functions/index.tsx+++ b/apps/studio/pages/project/[ref]/functions/index.tsx@@ -1,16 +1,5 @@import { useParams } from 'common'-import { useState } from 'react'-import {- Button,- Dialog,- DialogContent,- DialogFooter,- DialogHeader,- DialogSection,- DialogSectionSeparator,- DialogTrigger,- Modal,-} from 'ui'+import { Button, Dialog, DialogContent, DialogSection, DialogTrigger } from 'ui'import {EdgeFunctionsListItem,@@ -26,7 +15,6 @@ import type { NextPageWithLayout } from 'types'const PageLayout: NextPageWithLayout = () => {const { ref } = useParams()- const [showTerminalInstructions, setShowTerminalInstructions] = useState(false)const {data: functions,@@ -55,9 +43,7 @@ const PageLayout: NextPageWithLayout = () => {} deployed`}</span><Dialog><DialogTrigger asChild>- <Button type="primary" onClick={() => setShowTerminalInstructions(true)}>- Deploy a new function- </Button>+ <Button type="primary">Deploy a new function</Button></DialogTrigger><DialogContent size={'large'}><DialogSection padding="small">