The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Add guard to functiosn list and small refactor
Joshen Lima772a270a251
diff --git a/studio/components/interfaces/Database/Functions/FunctionsList/FunctionsList.tsx b/studio/components/interfaces/Database/Functions/FunctionsList/FunctionsList.tsxindex 66948295c4c..46458d9a75d 100644--- a/studio/components/interfaces/Database/Functions/FunctionsList/FunctionsList.tsx+++ b/studio/components/interfaces/Database/Functions/FunctionsList/FunctionsList.tsx@@ -1,8 +1,9 @@-import { FC } from 'react'+import { FC, useState } from 'react'import { uniqBy, map as lodashMap, includes } from 'lodash'import { Button, IconSearch, IconLoader, Input } from 'ui'import { observer } from 'mobx-react-lite'import * as Tooltip from '@radix-ui/react-tooltip'+import { PostgresFunction } from '@supabase/postgres-meta'import { PermissionAction } from '@supabase/shared-types/out/constants'import { checkPermissions, useStore } from 'hooks'@@ -10,17 +11,25 @@ import AlphaPreview from 'components/to-be-cleaned/AlphaPreview'import ProductEmptyState from 'components/to-be-cleaned/ProductEmptyState'import SchemaTable from './SchemaTable'-const FunctionsList: FC<any> = ({- filterString,- setFilterString = () => {},+interface Props {+ createFunction: () => void+ editFunction: (fn: PostgresFunction) => void+ deleteFunction: (fn: PostgresFunction) => void+}++const FunctionsList: FC<Props> = ({createFunction = () => {},editFunction = () => {},deleteFunction = () => {},}) => {const { meta } = useStore()- const functions = meta.functions.list((fn: any) => !meta.excludedSchemas.includes(fn.schema))- const filteredFunctions = functions.filter((x: any) =>- includes(x.name.toLowerCase(), filterString.toLowerCase())+ const [filterString, setFilterString] = useState<string>('')++ const functions = meta.functions.list(+ (fn: PostgresFunction) => !meta.excludedSchemas.includes(fn.schema)+ )+ const filteredFunctions = functions.filter((x: PostgresFunction) =>+ includes(x.name?.toLowerCase(), filterString.toLowerCase()))const filteredFunctionSchemas = lodashMap(uniqBy(filteredFunctions, 'schema'), 'schema')const canCreateFunctions = checkPermissions(PermissionAction.TENANT_SQL_ADMIN_WRITE, 'functions')diff --git a/studio/pages/project/[ref]/database/functions.tsx b/studio/pages/project/[ref]/database/functions.tsxindex 86e19b62999..5717e14bbcf 100644--- a/studio/pages/project/[ref]/database/functions.tsx+++ b/studio/pages/project/[ref]/database/functions.tsx@@ -11,7 +11,6 @@ import FunctionsList from 'components/interfaces/Database/Functions/FunctionsLisconst FunctionsPage: NextPageWithLayout = () => {const { meta, ui } = useStore()- const [filterString, setFilterString] = useState<string>('')const [selectedFunction, setSelectedFunction] = useState<any>()const [showCreateFunctionForm, setShowCreateFunctionForm] = useState<boolean>(false)const [showDeleteFunctionForm, setShowDeleteFunctionForm] = useState<boolean>(false)@@ -50,8 +49,6 @@ const FunctionsPage: NextPageWithLayout = () => {return (<><FunctionsList- filterString={filterString}- setFilterString={setFilterString}createFunction={createFunction}editFunction={editFunction}deleteFunction={deleteFunction}diff --git a/studio/pages/project/[ref]/functions/index.tsx b/studio/pages/project/[ref]/functions/index.tsxindex f8778eb09f5..0532afd7a8f 100644--- a/studio/pages/project/[ref]/functions/index.tsx+++ b/studio/pages/project/[ref]/functions/index.tsx@@ -12,7 +12,7 @@ import {TerminalInstructions,} from 'components/interfaces/Functions'-const FunctionsList = ({ functions }: { functions: Function[] }) => {+const EdgeFunctionsList = ({ functions }: { functions: Function[] }) => {return (<><div className="flex flex-col gap-3 py-6">@@ -53,7 +53,7 @@ const PageLayout: NextPageWithLayout = () => {return hasFunctions ? (<div className="py-6"><TerminalInstructions closable />- <FunctionsList functions={functions.list()} />+ <EdgeFunctionsList functions={functions.list()} /></div>) : (<FunctionsEmptyState />