Skip to content

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

chore: add functions pages

Jonathan Summers-Muir12437be371e2
diff --git a/studio/pages/project/[ref]/functions/[id]/details.tsx b/studio/pages/project/[ref]/functions/[id]/details.tsx
new file mode 100644
index 00000000000..172498db3af
--- /dev/null
+++ b/studio/pages/project/[ref]/functions/[id]/details.tsx
@@ -0,0 +1,10 @@
+import { observer } from 'mobx-react-lite'
+import { withAuth } from 'hooks'
+
+import FunctionLayout from './../interfaces/FunctionLayout'
+
+const PageLayout = () => {
+ return <FunctionLayout>Details</FunctionLayout>
+}
+
+export default withAuth(observer(PageLayout))
diff --git a/studio/pages/project/[ref]/functions/[id]/index.tsx b/studio/pages/project/[ref]/functions/[id]/index.tsx
new file mode 100644
index 00000000000..7d6566cf847
--- /dev/null
+++ b/studio/pages/project/[ref]/functions/[id]/index.tsx
@@ -0,0 +1,10 @@
+import { observer } from 'mobx-react-lite'
+import { withAuth } from 'hooks'
+
+import FunctionLayout from './../interfaces/FunctionLayout'
+
+const PageLayout = () => {
+ return <FunctionLayout>Metrics</FunctionLayout>
+}
+
+export default withAuth(observer(PageLayout))
diff --git a/studio/pages/project/[ref]/functions/[id]/invocations.tsx b/studio/pages/project/[ref]/functions/[id]/invocations.tsx
new file mode 100644
index 00000000000..2fe31e5a4e7
--- /dev/null
+++ b/studio/pages/project/[ref]/functions/[id]/invocations.tsx
@@ -0,0 +1,23 @@
+import React, { useState } from 'react'
+import { NextPage } from 'next'
+import { withAuth } from 'hooks'
+
+import { observer } from 'mobx-react-lite'
+
+// import LogWrapper from 'components/interfaces/Settings/Logs/LogWrapper'
+
+import { Button, Toggle } from '@supabase/ui'
+import { QueryType, Mode } from 'components/interfaces/Settings/Logs'
+import FunctionLayout from '../interfaces/FunctionLayout'
+
+export const LogPage: NextPage = () => {
+ // ! custom is SQL only logging !
+
+ return (
+ <>
+ <FunctionLayout>{/* <LogWrapper type={'fn_edge'} mode={'simple'} /> */}</FunctionLayout>
+ </>
+ )
+}
+
+export default withAuth(observer(LogPage))
diff --git a/studio/pages/project/[ref]/functions/[id]/logs-old.tsx b/studio/pages/project/[ref]/functions/[id]/logs-old.tsx
new file mode 100644
index 00000000000..652ba2e6145
--- /dev/null
+++ b/studio/pages/project/[ref]/functions/[id]/logs-old.tsx
@@ -0,0 +1,339 @@
+import { observer } from 'mobx-react-lite'
+import { withAuth } from 'hooks'
+
+import FunctionLayout from './../interfaces/FunctionLayout'
+import {
+ Button,
+ Checkbox,
+ Dropdown,
+ IconAlertCircle,
+ IconAlertOctagon,
+ IconCalendar,
+ IconCheck,
+ IconCheckCircle,
+ IconChevronRight,
+ IconExternalLink,
+ IconGlobe,
+ IconSearch,
+ Input,
+ Popover,
+ SidePanel,
+} from '@supabase/ui'
+import { useState } from 'react'
+import Table from 'components/to-be-cleaned/Table'
+import { memoryUsage } from 'process'
+import FunctionsListItem from './../interfaces/FunctionsListItem'
+
+import LogsData from './../data/logs.json'
+import FunctionLogsItem from '../interfaces/FunctionLogsItem'
+import dayjs from 'dayjs'
+import router, { useRouter } from 'next/router'
+
+const EmptyFunctions = () => {
+ return (
+ <>
+ <p className="text-scale-1200 text-base max-w-lg">
+ Scalable pay-as-you-go functions as a service (FaaS) to run your code with zero server
+ management.
+ </p>
+ <p className="text-scale-1100 text-sm max-w-lg">
+ No servers to provision, manage, or upgrade Automatically scale based on the load Integrated
+ monitoring, logging, and debugging capability Built-in security at role and per function
+ level based on the principle of least privilege Key networking capabilities for hybrid and
+ multi-cloud scenarios
+ </p>
+ <div className="flex gap-2">
+ <Button iconRight={<IconChevronRight />}>Get started</Button>
+ <Button type="link" iconRight={<IconExternalLink />}>
+ Documentation
+ </Button>
+ </div>
+ <div className="bg-scale-300 rounded px-10 py-8 flex flex-col gap-8">
+ <h2 className="text-sm text-scale-1100">Function examples</h2>
+ <div className="grid lg:grid-cols-3 gap-8">
+ <div className="flex flex-col gap-3">
+ <div
+ className="
+ h-10 w-10
+ bg-indigo-900
+ bordershadow-indigo-900
+ rounded-md
+ text-scale-fixed-100
+ flex items-center justify-center
+ "
+ >
+ <IconGlobe />
+ </div>
+ <div className="">
+ <h3 className="text-scale-1200">Stripe payments</h3>
+ <p className="text-scale-1100">
+ Charge a payment credit card when a database event occurs
+ </p>
+ </div>
+ </div>
+ <div className="flex flex-col gap-3">
+ <div
+ className="
+ h-10 w-10
+ bg-indigo-900
+ bordershadow-indigo-900
+ rounded-md
+ text-scale-fixed-100
+ flex items-center justify-center
+ "
+ >
+ <IconGlobe />
+ </div>
+ <div className="">
+ <h3 className="text-scale-1200">Stripe payments</h3>
+ <p className="text-scale-1100">
+ Charge a payment credit card when a database event occurs
+ </p>
+ </div>
+ </div>
+ <div className="flex flex-col gap-3">
+ <div
+ className="
+ h-10 w-10
+ bg-indigo-900
+ bordershadow-indigo-900
+ rounded-md
+ text-scale-fixed-100
+ flex items-center justify-center
+ "
+ >
+ <IconGlobe />
+ </div>
+ <div className="">
+ <h3 className="text-scale-1200">Stripe payments</h3>
+ <p className="text-scale-1100">
+ Charge a payment credit card when a database event occurs
+ </p>
+ </div>
+ </div>
+ </div>
+ </div>
+ </>
+ )
+}
+
+const FunctionsList = () => {
+ const [detailVisible, setDetailVisible] = useState(false)
+
+ const router = useRouter()
+ const { ref } = router.query
+
+ const PageState = {
+ functions: [
+ {
+ name: 'hello-world',
+ id: 1,
+ runtime: 'Node14',
+ memory: 256,
+ created_at: 1646524256,
+ },
+ {
+ name: 'charge',
+ id: 2,
+ runtime: 'Node14',
+ memory: 256,
+ created_at: 1646524256,
+ },
+ {
+ name: 'projects',
+ id: 3,
+ runtime: 'Node14',
+ memory: 512,
+ created_at: 1646524256,
+ },
+ ],
+ }
+
+ const logDetails = (
+ <div className="grid grid-cols-12 gap-2">
+ <span className="col-span-3 text-sm text-scale-900 w-32">Status</span>
+ <div className="col-span-7">
+ <div className="flex">
+ <div className="text-sm bg-scale-500 text-scale-1200 rounded px-2">200 OK</div>
+ </div>
+ </div>
+
+ <div className="col-span-3 text-sm text-scale-900 w-32">ID</div>
+ <div className="col-span-7 text-sm text-scale-1200">
+ <span className="">{LogsData[0].id}</span>
+ </div>
+
+ <div className="col-span-3 text-sm text-scale-900 w-32">Time</div>
+ <div className="col-span-7 text-sm text-scale-1200">
+ <span className="">{dayjs(LogsData[0].created_at).format('DD MMM, YYYY HH:mm')}</span>
+ </div>
+
+ <div className="col-span-3 text-sm text-scale-900 w-32">IP Address</div>
+ <div className="col-span-7 text-sm text-scale-1200">
+ <span className="">{LogsData[0].ip_address}</span>
+ </div>
+
+ <div className="col-span-3 text-sm text-scale-900 w-32">API Version</div>
+ <div className="col-span-7 text-sm text-scale-1200">
+ <span className="">v0.1</span>
+ </div>
+
+ <div className="col-span-3 text-sm text-scale-900 w-32">Source</div>
+ <div className="col-span-7 text-sm text-scale-1200">
+ <span className="">Something</span>
+ </div>
+
+ {/* <div className="col-span-3 text-sm text-scale-900 w-32 grow">User agent</div>
+ <div className="col-span-7 flex text-scale-1200">
+ <span className="">{LogsData[0].user_agent}</span>
+ </div> */}
+ </div>
+ )
+
+ return (
+ <div className="flex flex-col gap-3">
+ <div className="flex items-center justify-between gap-3">
+ <div className="flex items-center gap-3">
+ <Input icon={<IconSearch size={14} />} placeholder="Filter by anything.." size="tiny" />
+ <div className="flex -space-x-px">
+ <Button
+ type="secondary"
+ style={{ borderTopRightRadius: 0, borderBottomRightRadius: 0 }}
+ >
+ Last Hour
+ </Button>
+ <Button
+ type="default"
+ icon={<IconCalendar />}
+ style={{ borderTopLeftRadius: 0, borderBottomLeftRadius: 0 }}
+ >
+ Custom
+ </Button>
+ </div>
+ <Popover
+ size="medium"
+ align="end"
+ portalled
+ showClose
+ side="bottom"
+ header={
+ <div className="flex justify-between items-center">
+ <Button size="tiny" type="default">
+ Clear
+ </Button>
+ <h5 className="text-sm text-scale-1200">Status</h5>
+ <Button type="primary">Save</Button>
+ </div>
+ }
+ onOpenChange={function noRefCheck() {}}
+ overlay={[
+ <>
+ <div className="py-6 space-y-4">
+ <Checkbox
+ className="px-3"
+ defaultValue="100%"
+ description="Show all 200 responses"
+ label="Succeeded"
+ size="medium"
+ />
+ <Popover.Seperator />
+ <Checkbox
+ className="px-3"
+ defaultValue="100%"
+ description="Show all 5XX responses"
+ label="Failed"
+ size="medium"
+ />
+ </div>
+ </>,
+ ]}
+ >
+ <Button as="span" type="default">
+ Status
+ </Button>
+ </Popover>
+ </div>
+ <Button
+ type="default"
+ iconRight={<IconExternalLink size={14} />}
+ onClick={() =>
+ router.push(
+ `http://localhost:8082/project/${ref}/logs/database?q=timestamp+%3C+TIMESTAMP_SUB%28CURRENT_TIMESTAMP%28%29%2C+INTERVAL+10+MINUTE%29&s=&te=`
+ )
+ }
+ >
+ Open in logs explorer
+ </Button>
+ </div>
+ <div className="grid grid-cols-2 h-full">
+ <div>
+ <Table
+ head={
+ <>
+ <Table.th className="w-16">Response</Table.th>
+ <Table.th className="w-16">Method</Table.th>
+ <Table.th>URL</Table.th>
+ <Table.th>Timestamp</Table.th>
+ </>
+ }
+ body={
+ <>
+ {LogsData.length > 0 &&
+ LogsData.map((x: any) => (
+ <FunctionLogsItem
+ key={x.id}
+ log={x}
+ onClick={() => {
+ setDetailVisible(true)
+ }}
+ />
+ ))}
+ </>
+ }
+ />
+ </div>
+ <div className="border-t border-l border-r px-6 py-4 space-y-6">
+ <h3 className="text-xl font-medium text-scale-1200 mb-4">
+ POST /readededeaded/functions/hello-world
+ </h3>
+ {logDetails}
+ <SidePanel.Seperator />
+ <h3 className="text-base text-scale-1200">Response body</h3>
+ </div>
+ </div>
+ <SidePanel
+ size="large"
+ header={'POST /readededeaded/functions/hello-world'}
+ visible={detailVisible}
+ onCancel={() => setDetailVisible(false)}
+ >
+ <div className="py-4 flex flex-col space-y-8">
+ <SidePanel.Content>{logDetails}</SidePanel.Content>
+ <SidePanel.Seperator />
+ <SidePanel.Content>
+ <h3 className="text-base text-scale-1200">Response body</h3>
+ </SidePanel.Content>
+ </div>
+ </SidePanel>
+ </div>
+ )
+}
+
+const PageLayout = () => {
+ const [pageState, setPageState] = useState('list')
+
+ const Selection = () => (
+ <div>
+ <Button onClick={() => setPageState('empty')}>empty list</Button>
+ <Button onClick={() => setPageState('list')}>list</Button>
+ </div>
+ )
+
+ return (
+ <FunctionLayout>
+ <FunctionsList />
+ </FunctionLayout>
+ )
+}
+
+export default withAuth(observer(PageLayout))
diff --git a/studio/pages/project/[ref]/functions/[id]/logs.tsx b/studio/pages/project/[ref]/functions/[id]/logs.tsx
new file mode 100644
index 00000000000..6240a437a8e
--- /dev/null
+++ b/studio/pages/project/[ref]/functions/[id]/logs.tsx
@@ -0,0 +1,23 @@
+import React, { useState } from 'react'
+import { NextPage } from 'next'
+import { withAuth } from 'hooks'
+
+import { observer } from 'mobx-react-lite'
+
+// import LogWrapper from 'components/interfaces/Settings/Logs/LogWrapper'
+
+import { Button, Toggle } from '@supabase/ui'
+import { QueryType, Mode } from 'components/interfaces/Settings/Logs'
+import FunctionLayout from '../interfaces/FunctionLayout'
+
+export const LogPage: NextPage = () => {
+ // ! custom is SQL only logging !
+
+ return (
+ <>
+ <FunctionLayout>{/* <LogWrapper type={'functions'} mode={'simple'} /> */}</FunctionLayout>
+ </>
+ )
+}
+
+export default withAuth(observer(LogPage))
diff --git a/studio/pages/project/[ref]/functions/[id]/triggers.tsx b/studio/pages/project/[ref]/functions/[id]/triggers.tsx
new file mode 100644
index 00000000000..94a159273e9
--- /dev/null
+++ b/studio/pages/project/[ref]/functions/[id]/triggers.tsx
@@ -0,0 +1,10 @@
+import { observer } from 'mobx-react-lite'
+import { withAuth } from 'hooks'
+
+import FunctionLayout from './../interfaces/FunctionLayout'
+
+const PageLayout = () => {
+ return <FunctionLayout>Triggers</FunctionLayout>
+}
+
+export default withAuth(observer(PageLayout))
diff --git a/studio/pages/project/[ref]/functions/data/logs.json b/studio/pages/project/[ref]/functions/data/logs.json
new file mode 100644
index 00000000000..a15bc768fa6
--- /dev/null
+++ b/studio/pages/project/[ref]/functions/data/logs.json
@@ -0,0 +1,128 @@
+[
+ {
+ "id": 1,
+ "url": "/readededeaded/functions/hello-world",
+ "method": "POST",
+ "runtime": "Node14",
+ "memory": 256,
+ "created_at": 1646524256,
+ "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36",
+ "memory_used": "113",
+ "init_duration": "431.44",
+ "duration": "1394.57 ms",
+ "edge_status": "200",
+ "function_status": "200"
+ },
+ {
+ "id": 2,
+ "url": "/readededeaded/functions/hello-world",
+ "method": "POST",
+ "runtime": "Node14",
+ "memory": 256,
+ "created_at": 1646524256,
+ "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36",
+ "memory_used": "113",
+ "init_duration": "431.44",
+ "duration": "1394.57 ms",
+ "edge_status": "200",
+ "function_status": "200"
+ },
+ {
+ "id": 3,
+ "url": "/readededeaded/functions/hello-world",
+ "method": "POST",
+ "runtime": "Node14",
+ "memory": 512,
+ "created_at": 1646524256,
+ "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36",
+ "memory_used": "113",
+ "init_duration": "431.44",
+ "duration": "1394.57 ms",
+ "edge_status": "200",
+ "function_status": "200"
+ },
+ {
+ "id": 3,
+ "url": "/readededeaded/functions/hello-world",
+ "method": "POST",
+ "runtime": "Node14",
+ "memory": 512,
+ "created_at": 1646524256,
+ "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36",
+ "memory_used": "113",
+ "init_duration": "431.44",
+ "duration": "1394.57 ms",
+ "edge_status": "200",
+ "function_status": "200"
+ },
+ {
+ "id": 3,
+ "url": "/readededeaded/functions/hello-world",
+ "method": "POST",
+ "runtime": "Node14",
+ "memory": 512,
+ "created_at": 1646524256,
+ "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36",
+ "memory_used": "113",
+ "init_duration": "431.44",
+ "duration": "1394.57 ms",
+ "edge_status": "200",
+ "function_status": "200"
+ },
+ {
+ "id": 3,
+ "url": "/readededeaded/functions/hello-world",
+ "method": "POST",
+ "runtime": "Node14",
+ "memory": 512,
+ "created_at": 1646524256,
+ "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36",
+ "memory_used": "113",
+ "init_duration": "431.44",
+ "duration": "1394.57 ms",
+ "edge_status": "200",
+ "function_status": "200"
+ },
+ {
+ "id": 3,
+ "url": "/readededeaded/functions/hello-world",
+ "method": "POST",
+ "runtime": "Node14",
+ "memory": 512,
+ "created_at": 1646524256,
+ "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36",
+ "memory_used": "113",
+ "init_duration": "431.44",
+ "duration": "1394.57 ms",
+ "edge_status": "200",
+ "function_status": "200"
+ },
+ {
+ "id": 3,
+ "url": "/readededeaded/functions/hello-world",
+ "method": "POST",
+ "runtime": "Node14",
+ "memory": 512,
+ "created_at": 1646524256,
+ "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36",
+ "memory_used": "113",
+ "init_duration": "431.44",
+ "duration": "1394.57 ms",
+ "edge_status": "200",
+ "function_status": "200"
+ },
+ {
+ "id": 3,
+ "url": "/readededeaded/functions/hello-world",
+ "method": "POST",
+ "runtime": "Node14",
+ "memory": 512,
+ "created_at": 1646524256,
+ "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36",
+ "memory_used": "113",
+ "init_duration": "431.44",
+ "duration": "1394.57 ms",
+ "edge_status": "200",
+ "function_status": "200"
+ }
+]
diff --git a/studio/pages/project/[ref]/functions/data/request_sample.json b/studio/pages/project/[ref]/functions/data/request_sample.json
new file mode 100644
index 00000000000..c43f0f33599
--- /dev/null
+++ b/studio/pages/project/[ref]/functions/data/request_sample.json
@@ -0,0 +1,8 @@
+{
+ "custom_fields": {
+ "0": {
+ "name": "Project name",
+ "value": "1a1a1a1a1a1a1a1a1a1a1a"
+ }
+ }
+}
diff --git a/studio/pages/project/[ref]/functions/data/response_sample.json b/studio/pages/project/[ref]/functions/data/response_sample.json
new file mode 100644
index 00000000000..1e64e950ac4
--- /dev/null
+++ b/studio/pages/project/[ref]/functions/data/response_sample.json
@@ -0,0 +1,178 @@
+[
+ {
+ "id": "in_1a1a1a1a1a1a1a1a1a1a1a",
+ "object": "1a1a1a1a1a1a1a1a1a1a1a",
+ "account_country": "US",
+ "account_name": "1a1a1a1a1a1a1a1a1a1a1a",
+ "account_tax_ids": null,
+ "amount_due": 0,
+ "amount_paid": 0,
+ "amount_remaining": 0,
+ "application_fee_amount": null,
+ "attempt_count": 0,
+ "attempted": false,
+ "auto_advance": true,
+ "automatic_tax": {
+ "enabled": false,
+ "status": null
+ },
+ "billing_reason": "1a1a1a1a1a1a1a1a1a1a1a",
+ "charge": null,
+ "collection_method": "charge_automatically",
+ "created": 1646526032,
+ "currency": "usd",
+ "custom_fields": [
+ {
+ "name": "Project name",
+ "value": "1a1a1a1a1a1a1a1a1a1a1a"
+ }
+ ],
+ "customer": "cus_in_1a1a1a1a1a1a1a1a1a1a1a",
+ "customer_address": null,
+ "customer_email": "[email protected]",
+ "customer_name": null,
+ "customer_phone": null,
+ "customer_shipping": null,
+ "customer_tax_exempt": "none",
+ "customer_tax_ids": [],
+ "default_payment_method": null,
+ "default_source": null,
+ "default_tax_rates": [],
+ "description": null,
+ "discount": null,
+ "discounts": [],
+ "due_date": null,
+ "ending_balance": null,
+ "footer": null,
+ "hosted_invoice_url": null,
+ "invoice_pdf": null,
+ "last_finalization_error": null,
+ "lines": {
+ "object": "list",
+ "data": [
+ {
+ "id": "il_in_1a1a1a1a1a1a1a1a1a1a1a",
+ "object": "line_item",
+ "amount": 0,
+ "currency": "usd",
+ "description": "1 × Free tier (at $0.00 / month)",
+ "discount_amounts": [],
+ "discountable": true,
+ "discounts": [],
+ "livemode": true,
+ "metadata": {
+ "project_id": "29167",
+ "project_ref": "1a1a1a1a1a1a1a1a1a1a1a",
+ "project_name": "1a1a1a1a1a1a1a1a1a1a1a",
+ "organization_id": "1a1a1a1a1a1a1a1a1a1a1a",
+ "organization_slug": "1a1a1a1a1a1a1a1a1a1a1a-1a1a1a1a1a1a1a1a1a1a1a-1a1a1a1a1a1a1a1a1a1a1a"
+ },
+ "period": {
+ "end": 1649204401,
+ "start": 1646526001
+ },
+ "plan": {
+ "id": "price_1a1a1a1a1a1a1a1a1a1a1a",
+ "object": "plan",
+ "active": true,
+ "aggregate_usage": null,
+ "amount": 0,
+ "amount_decimal": "0",
+ "billing_scheme": "per_unit",
+ "created": 1615645622,
+ "currency": "usd",
+ "interval": "month",
+ "interval_count": 1,
+ "livemode": true,
+ "metadata": {
+ "price": "0000"
+ },
+ "nickname": null,
+ "product": "prod_1a1a1a1a1a1a1a1a1a1a1a",
+ "tiers_mode": null,
+ "transform_usage": null,
+ "trial_period_days": null,
+ "usage_type": "licensed"
+ },
+ "price": {
+ "id": "price_1a1a1a1a1a1a1a1a1a1a1a",
+ "object": "price",
+ "active": true,
+ "billing_scheme": "per_unit",
+ "created": 1615645622,
+ "currency": "usd",
+ "livemode": true,
+ "lookup_key": null,
+ "metadata": {
+ "price": "0000"
+ },
+ "nickname": null,
+ "product": "prod_1a1a1a1a1a1a1a1a1a1a1a",
+ "recurring": {
+ "aggregate_usage": null,
+ "interval": "month",
+ "interval_count": 1,
+ "trial_period_days": null,
+ "usage_type": "licensed"
+ },
+ "tax_behavior": "unspecified",
+ "tiers_mode": null,
+ "transform_quantity": null,
+ "type": "recurring",
+ "unit_amount": 0,
+ "unit_amount_decimal": "0"
+ },
+ "proration": false,
+ "proration_details": {
+ "credited_items": null
+ },
+ "quantity": 1,
+ "subscription": "sub_1a1a1a1a1a1a1a1a1a1a1a",
+ "subscription_item": "si_1a1a1a1a1a1a1a1a1a1a1a",
+ "tax_amounts": [],
+ "tax_rates": [],
+ "type": "subscription"
+ }
+ ],
+ "has_more": false,
+ "total_count": 1,
+ "url": "/v1/invoices/in_1a1a1a1a1a1a1a1a1a1a1a/lines"
+ },
+ "livemode": true,
+ "metadata": {},
+ "next_payment_attempt": 1646529632,
+ "number": null,
+ "on_behalf_of": null,
+ "paid": false,
+ "paid_out_of_band": false,
+ "payment_intent": null,
+ "payment_settings": {
+ "payment_method_options": null,
+ "payment_method_types": null
+ },
+ "period_end": 1646526001,
+ "period_start": 1644106801,
+ "post_payment_credit_notes_amount": 0,
+ "pre_payment_credit_notes_amount": 0,
+ "quote": null,
+ "receipt_number": null,
+ "starting_balance": 0,
+ "statement_descriptor": null,
+ "status": "draft",
+ "status_transitions": {
+ "finalized_at": null,
+ "marked_uncollectible_at": null,
+ "paid_at": null,
+ "voided_at": null
+ },
+ "subscription": "sub_1a1a1a1a1a1a1a1a1a1a1a",
+ "subtotal": 0,
+ "tax": null,
+ "test_clock": null,
+ "total": 0,
+ "total_discount_amounts": [],
+ "total_tax_amounts": [],
+ "transfer_data": null,
+ "webhooks_delivered_at": null
+ }
+]
diff --git a/studio/pages/project/[ref]/functions/index.tsx b/studio/pages/project/[ref]/functions/index.tsx
new file mode 100644
index 00000000000..394573c3a70
--- /dev/null
+++ b/studio/pages/project/[ref]/functions/index.tsx
@@ -0,0 +1,189 @@
+import { observer } from 'mobx-react-lite'
+import { withAuth } from 'hooks'
+
+import FunctionsLayout from './interfaces/FunctionsLayout'
+import {
+ Button,
+ IconChevronRight,
+ IconExternalLink,
+ IconGlobe,
+ IconSearch,
+ Input,
+} from '@supabase/ui'
+import { useState } from 'react'
+import Table from 'components/to-be-cleaned/Table'
+import { memoryUsage } from 'process'
+import FunctionsListItem from './interfaces/FunctionsListItem'
+
+const EmptyFunctions = () => {
+ return (
+ <>
+ <p className="text-scale-1200 text-base max-w-lg">
+ Scalable pay-as-you-go functions as a service (FaaS) to run your code with zero server
+ management.
+ </p>
+ <p className="text-scale-1100 text-sm max-w-lg">
+ No servers to provision, manage, or upgrade Automatically scale based on the load Integrated
+ monitoring, logging, and debugging capability Built-in security at role and per function
+ level based on the principle of least privilege Key networking capabilities for hybrid and
+ multi-cloud scenarios
+ </p>
+ <div className="flex gap-2">
+ <Button iconRight={<IconChevronRight />}>Get started</Button>
+ <Button type="link" iconRight={<IconExternalLink />}>
+ Documentation
+ </Button>
+ </div>
+ <div className="bg-scale-300 rounded px-10 py-8 flex flex-col gap-8">
+ <h2 className="text-sm text-scale-1100">Function examples</h2>
+ <div className="grid lg:grid-cols-3 gap-8">
+ <div className="flex flex-col gap-3">
+ <div
+ className="
+ h-10 w-10
+ bg-indigo-900
+ bordershadow-indigo-900
+ rounded-md
+ text-scale-fixed-100
+ flex items-center justify-center
+ "
+ >
+ <IconGlobe />
+ </div>
+ <div className="">
+ <h3 className="text-scale-1200">Stripe payments</h3>
+ <p className="text-scale-1100">
+ Charge a payment credit card when a database event occurs
+ </p>
+ </div>
+ </div>
+ <div className="flex flex-col gap-3">
+ <div
+ className="
+ h-10 w-10
+ bg-indigo-900
+ bordershadow-indigo-900
+ rounded-md
+ text-scale-fixed-100
+ flex items-center justify-center
+ "
+ >
+ <IconGlobe />
+ </div>
+ <div className="">
+ <h3 className="text-scale-1200">Stripe payments</h3>
+ <p className="text-scale-1100">
+ Charge a payment credit card when a database event occurs
+ </p>
+ </div>
+ </div>
+ <div className="flex flex-col gap-3">
+ <div
+ className="
+ h-10 w-10
+ bg-indigo-900
+ bordershadow-indigo-900
+ rounded-md
+ text-scale-fixed-100
+ flex items-center justify-center
+ "
+ >
+ <IconGlobe />
+ </div>
+ <div className="">
+ <h3 className="text-scale-1200">Stripe payments</h3>
+ <p className="text-scale-1100">
+ Charge a payment credit card when a database event occurs
+ </p>
+ </div>
+ </div>
+ </div>
+ </div>
+ </>
+ )
+}
+
+const FunctionsList = () => {
+ const PageState = {
+ functions: [
+ {
+ name: 'hello-world',
+ id: 1,
+ runtime: 'Node14',
+ memory: 256,
+ created_at: 1646524256,
+ },
+ {
+ name: 'charge',
+ id: 2,
+ runtime: 'Node14',
+ memory: 256,
+ created_at: 1646524256,
+ },
+ {
+ name: 'projects',
+ id: 3,
+ runtime: 'Node14',
+ memory: 512,
+ created_at: 1646524256,
+ },
+ ],
+ }
+
+ return (
+ <div className="flex flex-col gap-3">
+ <div className="flex justify-between items-center">
+ <span className="text-sm text-scale-900">2 functions deployed</span>
+ <Input icon={<IconSearch size={14} />} size="tiny" />
+ </div>
+ <div>
+ <Table
+ head={
+ <>
+ <Table.th>Email</Table.th>
+ <Table.th>Trigger</Table.th>
+ <Table.th className="hidden 2xl:table-cell">Created</Table.th>
+ <Table.th className="hidden xl:table-cell">Runtime</Table.th>
+ <Table.th className="hidden lg:table-cell">Memory</Table.th>
+ </>
+ }
+ body={
+ <>
+ {PageState.functions.length > 0 &&
+ PageState.functions.map((x: any) => <FunctionsListItem key={x.id} _function={x} />)}
+ </>
+ }
+ />
+ </div>
+ </div>
+ )
+}
+
+const PageLayout = () => {
+ const [pageState, setPageState] = useState('list')
+
+ const Selection = () => (
+ <div>
+ <Button onClick={() => setPageState('empty')}>empty list</Button>
+ <Button onClick={() => setPageState('list')}>list</Button>
+ </div>
+ )
+
+ if (pageState === 'empty') {
+ return (
+ <FunctionsLayout>
+ <EmptyFunctions />
+ <Selection />
+ </FunctionsLayout>
+ )
+ } else {
+ return (
+ <FunctionsLayout>
+ <FunctionsList />
+ <Selection />
+ </FunctionsLayout>
+ )
+ }
+}
+
+export default withAuth(observer(PageLayout))
diff --git a/studio/pages/project/[ref]/functions/interfaces/FunctionLayout.tsx b/studio/pages/project/[ref]/functions/interfaces/FunctionLayout.tsx
new file mode 100644
index 00000000000..fcdd4601f82
--- /dev/null
+++ b/studio/pages/project/[ref]/functions/interfaces/FunctionLayout.tsx
@@ -0,0 +1,82 @@
+import BaseLayout from 'components/layouts'
+import { observer } from 'mobx-react-lite'
+import { useStore, withAuth } from 'hooks'
+import { IconCode, IconSlash, Tabs } from '@supabase/ui'
+import { Tab } from '@headlessui/react'
+import FunctionsNav from './FunctionsNav'
+import React from 'react'
+
+const PageLayout = ({ children }: { children?: React.ReactNode }) => {
+ return (
+ <BaseLayout>
+ <div className="h-full flex flex-col flex-grow">
+ <div
+ className="
+ py-10
+ w-full mx-auto
+
+ transition-all
+
+ px-5
+ lg:px-20
+ xl:px-24
+ 1xl:px-28
+ 2xl:px-32
+
+ flex flex-col
+ gap-8
+ "
+ >
+ <div className="flex items-center gap-3">
+ <div
+ className="w-6 h-6 bg-brand-300 border border-brand-600 rounded text-brand-900
+ flex items-center justify-center
+ "
+ >
+ <IconCode size={14} strokeWidth={3} />
+ </div>
+ <h1 className="text-2xl text-scale-1200">Functions</h1>
+
+ <span className="text-scale-800 dark:text-scale-700">
+ <svg
+ viewBox="0 0 24 24"
+ width="16"
+ height="16"
+ stroke="currentColor"
+ strokeWidth="1"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ fill="none"
+ shapeRendering="geometricPrecision"
+ >
+ <path d="M16 3.549L7.12 20.600"></path>
+ </svg>
+ </span>
+ <h5 className="text-2xl text-scale-1200">hello-world</h5>
+ </div>
+ <FunctionsNav />
+ </div>
+ <div
+ // weird repetative styling
+ className="
+ h-full flex flex-col flex-grow
+
+ w-full mx-auto
+
+ transition-all
+
+ px-5
+ lg:px-20
+ xl:px-24
+ 1xl:px-28
+ 2xl:px-32
+ "
+ >
+ {children}
+ </div>
+ </div>
+ </BaseLayout>
+ )
+}
+
+export default withAuth(observer(PageLayout))
diff --git a/studio/pages/project/[ref]/functions/interfaces/FunctionLogsItem.tsx b/studio/pages/project/[ref]/functions/interfaces/FunctionLogsItem.tsx
new file mode 100644
index 00000000000..f1b6d964b16
--- /dev/null
+++ b/studio/pages/project/[ref]/functions/interfaces/FunctionLogsItem.tsx
@@ -0,0 +1,44 @@
+import dayjs from 'dayjs'
+import { FC } from 'react'
+import { observer } from 'mobx-react-lite'
+import { Badge, IconClipboard, IconExternalLink, IconGlobe, Typography } from '@supabase/ui'
+import Table from 'components/to-be-cleaned/Table'
+
+import SimpleCodeBlock from 'components/to-be-cleaned/SimpleCodeBlock'
+import router, { useRouter } from 'next/router'
+// import logDropdown from './logDropdown'
+
+interface Props {
+ log: any
+ onClick: () => void
+}
+
+const FunctionLogsItem: FC<Props> = ({ log, onClick }) => {
+ const islogConfirmed = log.email_confirmed_at || log.phone_confirmed_at
+
+ const router = useRouter()
+ const { ref } = router.query
+
+ return (
+ <Table.tr key={log.id} onClick={onClick}>
+ <Table.td className="whitespace-nowrap">
+ <div className="flex items-center gap-2">
+ <div className="bg-scale-500 px-2 rounded">{log.function_status}</div>
+ </div>
+ </Table.td>
+ <Table.td className="">
+ <span className="text-xs text-scale-1100">{log.method}</span>
+ </Table.td>
+ <Table.td className="">
+ <span className="text-xs text-scale-1100 font-mono">{log.url}</span>
+ </Table.td>
+ <Table.td className="">
+ <span className="text-scale-1100">
+ {dayjs(log.created_at).format('DD MMM, YYYY HH:mm')}
+ </span>
+ </Table.td>
+ </Table.tr>
+ )
+}
+
+export default observer(FunctionLogsItem)
diff --git a/studio/pages/project/[ref]/functions/interfaces/FunctionsLayout.tsx b/studio/pages/project/[ref]/functions/interfaces/FunctionsLayout.tsx
new file mode 100644
index 00000000000..0b419a890c6
--- /dev/null
+++ b/studio/pages/project/[ref]/functions/interfaces/FunctionsLayout.tsx
@@ -0,0 +1,46 @@
+import BaseLayout from 'components/layouts'
+import { observer } from 'mobx-react-lite'
+import { useStore, withAuth } from 'hooks'
+import { IconCode, IconSlash, Tabs } from '@supabase/ui'
+import { Tab } from '@headlessui/react'
+import FunctionsNav from '../interfaces/FunctionsNav'
+import React from 'react'
+
+const PageLayout = ({ children }: { children?: React.ReactNode }) => {
+ return (
+ <BaseLayout>
+ <div
+ className="
+ py-10
+ w-full mx-auto
+
+ transition-all
+
+ px-5
+ lg:px-20
+ xl:px-24
+ 1xl:px-28
+ 2xl:px-32
+
+ flex flex-col
+ gap-8
+ "
+ >
+ <div className="flex items-center gap-3">
+ <div
+ className="w-6 h-6 bg-brand-300 border border-brand-600 rounded text-brand-900
+ flex items-center justify-center
+ "
+ >
+ <IconCode size={14} strokeWidth={3} />
+ </div>
+ <h1 className="text-2xl text-scale-1200">Functions</h1>
+ </div>
+
+ {children}
+ </div>
+ </BaseLayout>
+ )
+}
+
+export default withAuth(observer(PageLayout))
diff --git a/studio/pages/project/[ref]/functions/interfaces/FunctionsListItem.tsx b/studio/pages/project/[ref]/functions/interfaces/FunctionsListItem.tsx
new file mode 100644
index 00000000000..16ddffe09b6
--- /dev/null
+++ b/studio/pages/project/[ref]/functions/interfaces/FunctionsListItem.tsx
@@ -0,0 +1,68 @@
+import dayjs from 'dayjs'
+import { FC } from 'react'
+import { observer } from 'mobx-react-lite'
+import {
+ Badge,
+ IconClipboard,
+ IconExternalLink,
+ IconGlobe,
+ Icon_function,
+ Typography,
+} from '@supabase/ui'
+import Table from 'components/to-be-cleaned/Table'
+
+import SimpleCodeBlock from 'components/to-be-cleaned/SimpleCodeBlock'
+import router, { useRouter } from 'next/router'
+// import _functionDropdown from './_functionDropdown'
+
+interface Props {
+ _function: any
+}
+
+const FunctionsListItem: FC<Props> = ({ _function }) => {
+ const is_functionConfirmed = _function.email_confirmed_at || _function.phone_confirmed_at
+
+ const router = useRouter()
+ const { ref } = router.query
+
+ return (
+ <Table.tr
+ key={_function.id}
+ onClick={() => {
+ router.push(`/project/${ref}/functions/hello-world`)
+ }}
+ >
+ <Table.td className="whitespace-nowrap">
+ <div className="flex items-center gap-2">
+ <span className="text-base text-scale-1200">{_function.name}</span>
+ </div>
+ </Table.td>
+ <Table.td className="whitespace-nowrap flex flex-col gap-0">
+ <span className="text-sm text-scale-1100 flex items-center gap-1">
+ <IconGlobe size={14} />
+ HTTP Request
+ </span>
+ <span
+ className="text-xs text-scale-900 flex gap-2 items-center
+ font-mono"
+ >
+ https://adlnssnsfsfsfdf.supabase.com/functions/{_function.name}
+ <IconClipboard size={12} />
+ </span>
+ </Table.td>
+ <Table.td className="hidden 2xl:table-cell">
+ <span className="text-scale-1100">
+ {dayjs(_function.created_at).format('DD MMM, YYYY HH:mm')}
+ </span>
+ </Table.td>
+ <Table.td className="hidden 2xl:table-cell">
+ <span className="text-scale-1100">{_function.runtime}</span>
+ </Table.td>
+ <Table.td className="hidden 2xl:table-cell">
+ <span className="text-scale-1100">{_function.memory} MB</span>
+ </Table.td>
+ </Table.tr>
+ )
+}
+
+export default observer(FunctionsListItem)
diff --git a/studio/pages/project/[ref]/functions/interfaces/FunctionsNav.tsx b/studio/pages/project/[ref]/functions/interfaces/FunctionsNav.tsx
new file mode 100644
index 00000000000..bf4142dfa72
--- /dev/null
+++ b/studio/pages/project/[ref]/functions/interfaces/FunctionsNav.tsx
@@ -0,0 +1,29 @@
+import { Tabs } from '@supabase/ui'
+import { useRouter } from 'next/router'
+
+const FunctionsNav = () => {
+ const router = useRouter()
+ const activeRoute = router.pathname.split('/')[5]
+ const { ref } = router.query
+ console.log('activeRoute', activeRoute)
+
+ return (
+ <Tabs
+ defaultActiveId="1"
+ type="underlined"
+ size="medium"
+ activeId={!activeRoute ? 'metrics' : activeRoute}
+ onChange={(e: string) =>
+ router.push(`/project/${ref}/functions/hello-world/${e === 'metrics' ? '' : e}`)
+ }
+ >
+ <Tabs.Panel id="metrics" label="Metrics" />
+ <Tabs.Panel id="details" label="Details" />
+ <Tabs.Panel id="triggers" label="Triggers" />
+ <Tabs.Panel id="invocations" label="Invocations" />
+ <Tabs.Panel id="logs" label="Logs" />
+ </Tabs>
+ )
+}
+
+export default FunctionsNav