Skip to content

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

Add empty state for when no edge functions available in project

Joshen Lim745cee1eb3c9
diff --git a/studio/components/interfaces/Database/Hooks/EditHookPanel.tsx b/studio/components/interfaces/Database/Hooks/EditHookPanel.tsx
index 0f01072083c..245f31d1533 100644
--- a/studio/components/interfaces/Database/Hooks/EditHookPanel.tsx
+++ b/studio/components/interfaces/Database/Hooks/EditHookPanel.tsx
@@ -391,7 +391,6 @@ const EditHookPanel = ({ visible, selectedHook, onClose }: EditHookPanelProps) =
>
{AVAILABLE_WEBHOOK_TYPES.map((webhook) => (
<Radio
- disabled={webhook.disabled}
key={webhook.value}
id={webhook.value}
value={webhook.value}
@@ -402,11 +401,6 @@ const EditHookPanel = ({ visible, selectedHook, onClose }: EditHookPanelProps) =
<div className="flex-col space-y-0">
<div className="flex space-x-2">
<p className="text-scale-1200">{webhook.label}</p>
- {webhook.disabled ? (
- <Badge color="amber">Coming soon</Badge>
- ) : (
- <Badge color="green">Alpha</Badge>
- )}
</div>
<p className="text-scale-1000">{webhook.description}</p>
</div>
diff --git a/studio/components/interfaces/Database/Hooks/HTTPRequestFields.tsx b/studio/components/interfaces/Database/Hooks/HTTPRequestFields.tsx
index 796c3d66aad..072fbb08ea0 100644
--- a/studio/components/interfaces/Database/Hooks/HTTPRequestFields.tsx
+++ b/studio/components/interfaces/Database/Hooks/HTTPRequestFields.tsx
@@ -1,3 +1,4 @@
+import Link from 'next/link'
import {
Button,
Listbox,
@@ -44,6 +45,7 @@ const HTTPRequestFields = ({
const { data: settings } = useProjectApiQuery({ projectRef: ref })
const { data: functions } = useEdgeFunctionsQuery({ projectRef: ref })
+ const edgeFunctions = functions ?? []
const apiService = settings?.autoApiService
const anonKey = apiService?.service_api_keys.find((x) => x.name === 'anon key')
? apiService.defaultApiKey
@@ -79,9 +81,21 @@ const HTTPRequestFields = ({
placeholder="http://api.com/path/resource"
descriptionText="URL of the HTTP request. Must include HTTP/HTTPS"
/>
- ) : type === 'supabase_function' ? (
+ ) : type === 'supabase_function' && edgeFunctions.length === 0 ? (
+ <div className="space-y-1">
+ <p className="text-sm text-scale-1100">Select which edge function to trigger</p>
+ <div className="px-4 py-4 border rounded bg-scale-500 border-scale-700 flex items-center justify-between space-x-4">
+ <p className="text-sm">No edge functions created yet</p>
+ <Link href={`/project/${ref}/functions`}>
+ <a>
+ <Button>Create an edge function</Button>
+ </a>
+ </Link>
+ </div>
+ </div>
+ ) : type === 'supabase_function' && edgeFunctions.length > 0 ? (
<Listbox id="http_url" name="http_url" label="Select which edge function to trigger">
- {(functions ?? []).map((fn) => {
+ {edgeFunctions.map((fn) => {
const restUrl = ui.selectedProject?.restUrl
const restUrlTld = new URL(restUrl as string).hostname.split('.').pop()
const functionUrl = `https://${ref}.functions.supabase.${restUrlTld}/${fn.slug}`
diff --git a/studio/components/interfaces/Database/Hooks/Hooks.constants.ts b/studio/components/interfaces/Database/Hooks/Hooks.constants.ts
index 2f6a22986be..1fe98a85928 100644
--- a/studio/components/interfaces/Database/Hooks/Hooks.constants.ts
+++ b/studio/components/interfaces/Database/Hooks/Hooks.constants.ts
@@ -35,14 +35,12 @@ export const HOOK_EVENTS = [
export const AVAILABLE_WEBHOOK_TYPES = [
{
- disabled: false,
value: 'http_request',
icon: `${BASE_PATH}/img/function-providers/http-request.png`,
label: 'HTTP Request',
description: 'Send an HTTP request to any URL.',
},
{
- disabled: false,
value: 'supabase_function',
icon: `${BASE_PATH}/img/function-providers/supabase-severless-function.png`,
label: 'Supabase Edge Functions',