From cb49607cd89efc11454edd2f3753ff75619c330c Mon Sep 17 00:00:00 2001 From: Joshen Lim Date: Mon, 20 Feb 2023 21:12:51 +0800 Subject: [PATCH] Reinstate table component for functions list --- ...tionsRow.tsx => EdgeFunctionsListItem.tsx} | 78 +++++++++---------- .../components/interfaces/Functions/index.ts | 3 +- .../pages/project/[ref]/functions/index.tsx | 34 ++++++-- 3 files changed, 64 insertions(+), 51 deletions(-) rename studio/components/interfaces/Functions/{EdgeFunctionsRow.tsx => EdgeFunctionsListItem.tsx} (54%) diff --git a/studio/components/interfaces/Functions/EdgeFunctionsRow.tsx b/studio/components/interfaces/Functions/EdgeFunctionsListItem.tsx similarity index 54% rename from studio/components/interfaces/Functions/EdgeFunctionsRow.tsx rename to studio/components/interfaces/Functions/EdgeFunctionsListItem.tsx index a263b6aff26..0f8a00ecb8b 100644 --- a/studio/components/interfaces/Functions/EdgeFunctionsRow.tsx +++ b/studio/components/interfaces/Functions/EdgeFunctionsListItem.tsx @@ -1,41 +1,44 @@ import dayjs from 'dayjs' -import { useRouter } from 'next/router' import { FC, useState } from 'react' +import { useRouter } from 'next/router' +import { observer } from 'mobx-react-lite' +import { IconCheck, IconClipboard } from 'ui' import * as Tooltip from '@radix-ui/react-tooltip' -import { IconUpload, IconCheck, IconClipboard } from 'ui' import { useParams, useStore } from 'hooks' +import Table from 'components/to-be-cleaned/Table' import { EdgeFunctionsResponse } from 'data/edge-functions/edge-functions-query' interface Props { - fn: EdgeFunctionsResponse + function: EdgeFunctionsResponse } -const EdgeFunctionsRow: FC = ({ fn }) => { +const EdgeFunctionsListItem: FC = ({ function: item }) => { const router = useRouter() - const { ref } = useParams() const { ui } = useStore() + const { ref } = useParams() const [isCopied, setIsCopied] = useState(false) + // get the .co or .net TLD from the restUrl const restUrl = ui.selectedProject?.restUrl const restUrlTld = new URL(restUrl as string).hostname.split('.').pop() - const functionUrl = `https://${ref}.functions.supabase.${restUrlTld}/${fn.slug}` + const functionUrl = `https://${ref}.functions.supabase.${restUrlTld}/${item.slug}` return ( -
router.push(`/project/${ref}/functions/${fn.id}`)} + { + router.push(`/project/${ref}/functions/${item.id}`) + }} > -
-

{fn.name}

-
-

{functionUrl}

+ +
+

{item.name}

+
+
+ +
+

{functionUrl}

-
-
- - -

Deployment {fn.version}

-
- - -
- Deployment history coming soon -
-
-
+ + +

{dayjs(item.created_at).format('DD MMM, YYYY HH:mm')}

+
+
- -

{dayjs(fn.updated_at).fromNow()}

+

{dayjs(item.updated_at).fromNow()}

@@ -98,14 +87,17 @@ const EdgeFunctionsRow: FC = ({ fn }) => { ].join(' ')} > - Last updated on {dayjs(fn.updated_at).format('DD MMM, YYYY HH:mm')} + Last updated on {dayjs(item.updated_at).format('DD MMM, YYYY HH:mm')}
-
-
+ + +

{item.version}

+
+ ) } -export default EdgeFunctionsRow +export default observer(EdgeFunctionsListItem) diff --git a/studio/components/interfaces/Functions/index.ts b/studio/components/interfaces/Functions/index.ts index af628ba5d81..003d5feaca6 100644 --- a/studio/components/interfaces/Functions/index.ts +++ b/studio/components/interfaces/Functions/index.ts @@ -1,5 +1,6 @@ import EdgeFunctionDetails from './EdgeFunctionDetails' +import EdgeFunctionsListItem from './EdgeFunctionsListItem' import FunctionsEmptyState from './FunctionsEmptyState' import TerminalInstructions from './TerminalInstructions' -export { EdgeFunctionDetails, FunctionsEmptyState, TerminalInstructions } +export { EdgeFunctionDetails, EdgeFunctionsListItem, FunctionsEmptyState, TerminalInstructions } diff --git a/studio/pages/project/[ref]/functions/index.tsx b/studio/pages/project/[ref]/functions/index.tsx index 480e1700d87..ae427eed957 100644 --- a/studio/pages/project/[ref]/functions/index.tsx +++ b/studio/pages/project/[ref]/functions/index.tsx @@ -1,11 +1,12 @@ import { observer } from 'mobx-react-lite' + import { useParams } from 'hooks' import { NextPageWithLayout } from 'types' +import Table from 'components/to-be-cleaned/Table' import FunctionsLayout from 'components/layouts/FunctionsLayout' -import { FunctionsEmptyState } from 'components/interfaces/Functions' -import { useEdgeFunctionsQuery } from 'data/edge-functions/edge-functions-query' +import { EdgeFunctionsListItem, FunctionsEmptyState } from 'components/interfaces/Functions' import ShimmeringLoader from 'components/ui/ShimmeringLoader' -import EdgeFunctionsRow from 'components/interfaces/Functions/EdgeFunctionsRow' +import { useEdgeFunctionsQuery } from 'data/edge-functions/edge-functions-query' const PageLayout: NextPageWithLayout = () => { const { ref } = useParams() @@ -24,10 +25,29 @@ const PageLayout: NextPageWithLayout = () => { } return hasFunctions ? ( -
- {(functions ?? []).map((fn) => ( - - ))} +
+
+ {`${functions.length} function${ + functions.length > 1 ? 's' : '' + } deployed`} +
+ + Name + URL + Created + Last updated + Deployment + + } + body={ + <> + {functions.length > 0 && + functions.map((item: any) => )} + + } + /> ) : (