Skip to content

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

dynamically gets all selected languages

FatumaA0b37dbc51168
diff --git a/studio/components/interfaces/Database/Functions/CreateFunction.tsx b/studio/components/interfaces/Database/Functions/CreateFunction.tsx
index 13758a32b06..c53e766236a 100644
--- a/studio/components/interfaces/Database/Functions/CreateFunction.tsx
+++ b/studio/components/interfaces/Database/Functions/CreateFunction.tsx
@@ -1,5 +1,5 @@
import { FC, useEffect, useContext, createContext, FormEvent } from 'react'
-import { isEmpty, mapValues, has, filter, keyBy, isUndefined } from 'lodash'
+import { isEmpty, mapValues, has, filter, keyBy, isUndefined, partition, isNull } from 'lodash'
import { observer, useLocalObservable } from 'mobx-react-lite'
import {
Button,
@@ -21,6 +21,7 @@ import { useStore } from 'hooks'
import Panel from 'components/to-be-cleaned/Panel'
import SqlEditor from 'components/to-be-cleaned/SqlEditor'
+
class CreateFunctionFormState {
id: number | undefined
originalName: string | undefined
@@ -752,8 +753,14 @@ const SelectSchema: FC = observer(({}) => {
})
const SelectLanguage: FC = observer(({}) => {
+ const { meta } = useStore()
const _localState = useContext(CreateFunctionContext)
+ const [enabledExtensions] = partition(
+ meta.extensions.list(),
+ (ext: any) => !isNull(ext.installed_version)
+ )
+
return (
<div className={`space-y-4 px-6`}>
<Select
@@ -771,7 +778,14 @@ const SelectLanguage: FC = observer(({}) => {
size="small"
>
<Select.Option value="sql">sql</Select.Option>
- <Select.Option value="plpgsql">plpgsql</Select.Option>
+ {
+ //map through all selected extensions that start with pl
+ enabledExtensions.filter((ex:any) => {
+ return ex.name.startsWith('pl')
+ }).map(ex => (<Select.Option key={ex.name} value={ex.name}>{ex.name}</Select.Option>))
+
+ }
+
</Select>
</div>
)