Skip to content

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

Clean up functions and logs explorer pages

Joshen Lim18886f11f5e2
diff --git a/studio/components/interfaces/functions/Functions.data.ts b/studio/components/interfaces/functions/Functions.data.ts
new file mode 100644
index 00000000000..88d1b1e44fb
--- /dev/null
+++ b/studio/components/interfaces/functions/Functions.data.ts
@@ -0,0 +1,326 @@
+export const LOGS_DATA = [
+ {
+ 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',
+ },
+]
+
+export const REQUEST_SAMPLE = {
+ custom_fields: {
+ '0': {
+ name: 'Project name',
+ value: '1a1a1a1a1a1a1a1a1a1a1a',
+ },
+ },
+}
+
+export const RESPONSE_SAMPLE = [
+ {
+ 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/[id]/details.tsx b/studio/pages/project/[ref]/functions/[id]/details.tsx
index 81544ceda9d..9b5c7ee31b4 100644
--- a/studio/pages/project/[ref]/functions/[id]/details.tsx
+++ b/studio/pages/project/[ref]/functions/[id]/details.tsx
@@ -1,8 +1,8 @@
import { observer } from 'mobx-react-lite'
import { useStore, withAuth } from 'hooks'
-import FunctionLayout from '../../../../../components/interfaces/functions/FunctionLayout'
-import CommandRender from '../../../../../components/interfaces/functions/CommandRender'
+import FunctionLayout from 'components/interfaces/functions/FunctionLayout'
+import CommandRender from 'components/interfaces/functions/CommandRender'
import { useRouter } from 'next/router'
import { useEffect, useState } from 'react'
import { toJS } from 'mobx'
diff --git a/studio/pages/project/[ref]/functions/[id]/index.tsx b/studio/pages/project/[ref]/functions/[id]/index.tsx
index 1ad2353474e..aa234eeeb69 100644
--- a/studio/pages/project/[ref]/functions/[id]/index.tsx
+++ b/studio/pages/project/[ref]/functions/[id]/index.tsx
@@ -14,7 +14,7 @@ import ChartHandler from 'components/to-be-cleaned/Charts/ChartHandler'
import { get } from 'lib/common/fetch'
import { API_URL, DATE_FORMAT } from 'lib/constants'
-import FunctionLayout from '../../../../../components/interfaces/functions/FunctionLayout'
+import FunctionLayout from 'components/interfaces/functions/FunctionLayout'
const CHART_INTERVALS = [
{
diff --git a/studio/pages/project/[ref]/functions/[id]/invocations.tsx b/studio/pages/project/[ref]/functions/[id]/invocations.tsx
index b3603421de8..de138ab142b 100644
--- a/studio/pages/project/[ref]/functions/[id]/invocations.tsx
+++ b/studio/pages/project/[ref]/functions/[id]/invocations.tsx
@@ -5,7 +5,7 @@ import { observer } from 'mobx-react-lite'
import { withAuth } from 'hooks'
import { LOG_TYPE_LABEL_MAPPING } from 'components/interfaces/Settings/Logs'
import LogsPreviewer from 'components/interfaces/Settings/Logs/LogsPreviewer'
-import FunctionLayout from '../../../../../components/interfaces/functions/FunctionLayout'
+import FunctionLayout from 'components/interfaces/functions/FunctionLayout'
/**
* Placeholder page for logs previewers until we figure out where to slot them
diff --git a/studio/pages/project/[ref]/functions/[id]/logs-old.tsx b/studio/pages/project/[ref]/functions/[id]/logs-old.tsx
index 2ea9a01b332..c6e448c7108 100644
--- a/studio/pages/project/[ref]/functions/[id]/logs-old.tsx
+++ b/studio/pages/project/[ref]/functions/[id]/logs-old.tsx
@@ -1,16 +1,12 @@
+import dayjs from 'dayjs'
+import { useRouter } from 'next/router'
+import { useState } from 'react'
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,
@@ -19,15 +15,12 @@ import {
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'
+import { withAuth } from 'hooks'
+import Table from 'components/to-be-cleaned/Table'
+import FunctionLayout from 'components/interfaces/functions/FunctionLayout'
+import FunctionLogsItem from 'components/interfaces/functions/FunctionLogsItem'
+import { LOGS_DATA } from 'components/interfaces/functions/Functions.data'
const EmptyFunctions = () => {
return (
@@ -160,19 +153,19 @@ const FunctionsList = () => {
<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>
+ <span className="">{LOGS_DATA[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>
+ <span className="">{dayjs(LOGS_DATA[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">
{/*
// @ts-ignore */}
- <span className="">{LogsData[0].ip_address}</span>
+ <span className="">{LOGS_DATA[0].ip_address}</span>
</div>
<div className="col-span-3 text-sm text-scale-900 w-32">API Version</div>
@@ -187,7 +180,7 @@ const FunctionsList = () => {
{/* <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>
+ <span className="">{LOGS_DATA[0].user_agent}</span>
</div> */}
</div>
)
@@ -280,8 +273,8 @@ const FunctionsList = () => {
}
body={
<>
- {LogsData.length > 0 &&
- LogsData.map((x: any) => (
+ {LOGS_DATA.length > 0 &&
+ LOGS_DATA.map((x: any) => (
<FunctionLogsItem
key={x.id}
log={x}
diff --git a/studio/pages/project/[ref]/functions/[id]/logs.tsx b/studio/pages/project/[ref]/functions/[id]/logs.tsx
index b553e520703..31096934378 100644
--- a/studio/pages/project/[ref]/functions/[id]/logs.tsx
+++ b/studio/pages/project/[ref]/functions/[id]/logs.tsx
@@ -5,7 +5,7 @@ import { observer } from 'mobx-react-lite'
import { withAuth } from 'hooks'
import { LOG_TYPE_LABEL_MAPPING } from 'components/interfaces/Settings/Logs'
import LogsPreviewer from 'components/interfaces/Settings/Logs/LogsPreviewer'
-import FunctionLayout from '../../../../../components/interfaces/functions/FunctionLayout'
+import FunctionLayout from 'components/interfaces/functions/FunctionLayout'
/**
* Placeholder page for logs previewers until we figure out where to slot them
diff --git a/studio/pages/project/[ref]/functions/[id]/triggers.tsx b/studio/pages/project/[ref]/functions/[id]/triggers.tsx
index feb8d9299c8..266c6006540 100644
--- a/studio/pages/project/[ref]/functions/[id]/triggers.tsx
+++ b/studio/pages/project/[ref]/functions/[id]/triggers.tsx
@@ -1,7 +1,7 @@
import { observer } from 'mobx-react-lite'
import { withAuth } from 'hooks'
-import FunctionLayout from '../../../../../components/interfaces/functions/FunctionLayout'
+import FunctionLayout from 'components/interfaces/functions/FunctionLayout'
const PageLayout = () => {
return <FunctionLayout>Triggers</FunctionLayout>
diff --git a/studio/pages/project/[ref]/functions/data/logs.json b/studio/pages/project/[ref]/functions/data/logs.json
deleted file mode 100644
index a15bc768fa6..00000000000
--- a/studio/pages/project/[ref]/functions/data/logs.json
+++ /dev/null
@@ -1,128 +0,0 @@
-[
- {
- "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
deleted file mode 100644
index c43f0f33599..00000000000
--- a/studio/pages/project/[ref]/functions/data/request_sample.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "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
deleted file mode 100644
index 1e64e950ac4..00000000000
--- a/studio/pages/project/[ref]/functions/data/response_sample.json
+++ /dev/null
@@ -1,178 +0,0 @@
-[
- {
- "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
index 6312801a979..6d2197e2966 100644
--- a/studio/pages/project/[ref]/functions/index.tsx
+++ b/studio/pages/project/[ref]/functions/index.tsx
@@ -1,21 +1,17 @@
-import { observer } from 'mobx-react-lite'
-import { useStore, withAuth } from 'hooks'
-
-import FunctionsLayout from '../../../../components/interfaces/functions/FunctionsLayout'
-import { Button, IconBookOpen, IconSearch, IconTerminal, Input, Loading } from '@supabase/ui'
+import Link from 'next/link'
import { useEffect } from 'react'
-import Table from 'components/to-be-cleaned/Table'
-
-import FunctionsListItem from '../../../../components/interfaces/functions/FunctionsListItem'
import { useRouter } from 'next/router'
+import { observer } from 'mobx-react-lite'
+import { Button, IconBookOpen, IconSearch, IconTerminal, Input, Loading } from '@supabase/ui'
+import { useStore, withAuth } from 'hooks'
import { post } from 'lib/common/fetch'
import { API_URL, PROJECT_STATUS } from 'lib/constants'
-
-import CommandRender from '../../../../components/interfaces/functions/CommandRender'
-import Link from 'next/link'
-
-import { Function } from '../../../../components/interfaces/functions/Functions.types'
+import Table from 'components/to-be-cleaned/Table'
+import FunctionsLayout from 'components/interfaces/functions/FunctionsLayout'
+import FunctionsListItem from 'components/interfaces/functions/FunctionsListItem'
+import CommandRender from 'components/interfaces/functions/CommandRender'
+import { Function } from 'components/interfaces/functions/Functions.types'
const EmptyFunctions = () => {
const router = useRouter()
diff --git a/studio/pages/project/[ref]/functions/interfaces/CommandRender.tsx b/studio/pages/project/[ref]/functions/interfaces/CommandRender.tsx
deleted file mode 100644
index 18af5eb91ee..00000000000
--- a/studio/pages/project/[ref]/functions/interfaces/CommandRender.tsx
+++ /dev/null
@@ -1,55 +0,0 @@
-import { IconCheck, IconClipboard } from '@supabase/ui'
-import { useState } from 'react'
-
-const CommandRender = ({ commands }: any) => {
- console.log('commands', commands)
- return (
- <div className="space-y-4">
- {commands.map((item: any) => {
- const [isCopied, setIsCopied] = useState(false)
- return (
- <div>
- <span className="font-mono text-xs text-scale-900">{`> ${item.comment}`}</span>
- <div className="flex items-center gap-2">
- <div className="flex gap-2 text-scale-1200 font-mono text-sm font-normal">
- <span className="text-scale-900">$</span>
- <span>
- <span className="">{item.jsx ? item.jsx() : null} </span>
- <button
- type="button"
- className="text-scale-900 hover:text-scale-1200"
- onClick={() => {
- function onCopy(value: any) {
- setIsCopied(true)
- navigator.clipboard.writeText(value).then()
- setTimeout(function () {
- setIsCopied(false)
- }, 3000)
- }
- onCopy(item.command)
- }}
- >
- {isCopied ? (
- <div className="text-brand-900">
- <IconCheck size={14} strokeWidth={3} />
- </div>
- ) : (
- <div className="relative">
- <div className="block">
- <IconClipboard size={14} />
- </div>
- </div>
- )}
- </button>
- </span>
- </div>
- </div>
- <span className="text-xs text-scale-900">{item.description}</span>
- </div>
- )
- })}
- </div>
- )
-}
-
-export default CommandRender
diff --git a/studio/pages/project/[ref]/functions/interfaces/FunctionLayout.tsx b/studio/pages/project/[ref]/functions/interfaces/FunctionLayout.tsx
deleted file mode 100644
index f176767046a..00000000000
--- a/studio/pages/project/[ref]/functions/interfaces/FunctionLayout.tsx
+++ /dev/null
@@ -1,118 +0,0 @@
-import BaseLayout from 'components/layouts'
-import { observer } from 'mobx-react-lite'
-import { useStore, withAuth } from 'hooks'
-import { IconAlertCircle, IconCode, IconSlash, Loading, Tabs } from '@supabase/ui'
-import { Tab } from '@headlessui/react'
-import FunctionsNav from './FunctionsNav'
-import React, { useEffect } from 'react'
-import { useRouter } from 'next/router'
-import Link from 'next/link'
-import WarningBanner from 'components/ui/WarningBanner'
-import { WARNING_MESSAGE } from './Functions.Constants'
-
-const PageLayout = ({ children }: { children?: React.ReactNode }) => {
- const { functions, ui } = useStore()
-
- const router = useRouter()
- const { id, ref } = router.query
-
- useEffect(() => {
- functions.load()
- }, [ui.selectedProject])
-
- if (!functions.list()) {
- return (
- <BaseLayout>
- <Loading active={true}>loading</Loading>
- </BaseLayout>
- )
- }
-
- const item = functions.byId(id)
-
- const name = item?.name || ''
-
- return (
- <BaseLayout>
- <WarningBanner title={WARNING_MESSAGE.title} description={WARNING_MESSAGE.description} />
-
- <div className="h-full flex flex-col flex-grow py-10">
- <div
- className="
- 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>
- <Link href={`/project/${ref}/functions`}>
- <h1
- className="
- transition-colors
- text-2xl text-scale-1200
- cursor-pointer
- hover:text-scale-1100"
- >
- Functions
- </h1>
- </Link>
-
- <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">{name}</h5>
- </div>
- <FunctionsNav item={item} />
- </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
deleted file mode 100644
index f1b6d964b16..00000000000
--- a/studio/pages/project/[ref]/functions/interfaces/FunctionLogsItem.tsx
+++ /dev/null
@@ -1,44 +0,0 @@
-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/Functions.Constants.ts b/studio/pages/project/[ref]/functions/interfaces/Functions.Constants.ts
deleted file mode 100644
index 5f8be838045..00000000000
--- a/studio/pages/project/[ref]/functions/interfaces/Functions.Constants.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-export const WARNING_MESSAGE = {
- title: ' Supabase Functions is pre release',
- description: 'Functions are currently experimental, and will be prone to breaking changes',
-}
diff --git a/studio/pages/project/[ref]/functions/interfaces/Functions.types.ts b/studio/pages/project/[ref]/functions/interfaces/Functions.types.ts
deleted file mode 100644
index ed54073082f..00000000000
--- a/studio/pages/project/[ref]/functions/interfaces/Functions.types.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-export interface Function {
- id: string
- slug: string
- name: string
- version: 9
- status: 'ACTIVE' | 'INACTIVE' | 'THROTTLE'
- created_at: number
- updated_at: number
-}
diff --git a/studio/pages/project/[ref]/functions/interfaces/FunctionsLayout.tsx b/studio/pages/project/[ref]/functions/interfaces/FunctionsLayout.tsx
deleted file mode 100644
index a455bd69ff1..00000000000
--- a/studio/pages/project/[ref]/functions/interfaces/FunctionsLayout.tsx
+++ /dev/null
@@ -1,86 +0,0 @@
-import BaseLayout from 'components/layouts'
-import { observer } from 'mobx-react-lite'
-import { useStore, withAuth } from 'hooks'
-import { IconCode, IconSlash, Loading, Tabs } from '@supabase/ui'
-import { Tab } from '@headlessui/react'
-import FunctionsNav from '../interfaces/FunctionsNav'
-import React, { useEffect } from 'react'
-import { useRouter } from 'next/router'
-import WarningBanner from 'components/ui/WarningBanner'
-import { WARNING_MESSAGE } from './Functions.Constants'
-
-const PageLayout = ({ children, centered }: { children?: React.ReactNode; centered?: boolean }) => {
- const { functions, ui } = useStore()
-
- const router = useRouter()
- const { id } = router.query
-
- useEffect(() => {
- functions.load()
- }, [ui.selectedProject])
-
- if (!functions.isInitialized) {
- return (
- <BaseLayout>
- <Loading active={true}>loading</Loading>
- </BaseLayout>
- )
- }
-
- return (
- <BaseLayout>
- <WarningBanner title={WARNING_MESSAGE.title} description={WARNING_MESSAGE.description} />
- {centered ? (
- <>
- <div className="mx-auto max-w-5xl py-32 px-5">
- <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>
- </>
- ) : (
- <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
deleted file mode 100644
index 27d4d31398d..00000000000
--- a/studio/pages/project/[ref]/functions/interfaces/FunctionsListItem.tsx
+++ /dev/null
@@ -1,69 +0,0 @@
-import dayjs from 'dayjs'
-import { FC } from 'react'
-import { observer } from 'mobx-react-lite'
-import { IconClipboard, IconGlobe } from '@supabase/ui'
-import Table from 'components/to-be-cleaned/Table'
-
-import { useRouter } from 'next/router'
-import { useStore } from 'hooks'
-// import _functionDropdown from './_functionDropdown'
-
-interface Props {
- function: any
-}
-
-const FunctionsListItem: FC<Props> = ({ function: item }) => {
- const { ui } = useStore()
-
- console.log('_function', item)
- const is_functionConfirmed = item.email_confirmed_at || item.phone_confirmed_at
-
- const router = useRouter()
- const ref = ui?.selectedProject?.ref
-
- return (
- <Table.tr
- key={item.id}
- onClick={() => {
- router.push(`/project/${ref}/functions/${item.id}`)
- }}
- >
- <Table.td className="whitespace-nowrap">
- <div className="flex items-center gap-2">
- <span className="text-base text-scale-1200">{item.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://${ref}.supabase.com/functions/${item.name}`}
- <IconClipboard size={12} />
- </span>
- </Table.td>
- <Table.td className="hidden 2xl:table-cell">
- <span className="text-scale-1100">{item.status}</span>
- </Table.td>
- <Table.td className="hidden 2xl:table-cell">
- <span className="text-scale-1100">
- {dayjs(item.created_at).format('DD MMM, YYYY HH:mm')}
- </span>
- </Table.td>
- <Table.td className="hidden 2xl:table-cell">
- <span className="text-scale-1100">
- {dayjs(item.updated_at).format('DD MMM, YYYY HH:mm')}
- </span>
- </Table.td>
- <Table.td className="hidden 2xl:table-cell">
- <span className="text-scale-1100">Version {item.version}</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
deleted file mode 100644
index 01dd022b961..00000000000
--- a/studio/pages/project/[ref]/functions/interfaces/FunctionsNav.tsx
+++ /dev/null
@@ -1,29 +0,0 @@
-import { Tabs } from '@supabase/ui'
-import { useRouter } from 'next/router'
-
-// @ts-ignore
-const FunctionsNav = ({ item }) => {
- const router = useRouter()
- const activeRoute = router.pathname.split('/')[5]
- const { ref } = router.query
-
- return (
- <Tabs
- defaultActiveId="1"
- type="underlined"
- size="medium"
- activeId={!activeRoute ? 'metrics' : activeRoute}
- onChange={(e: string) =>
- router.push(`/project/${ref}/functions/${item.id}/${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