Skip to content

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

Add common client loading error state with contact support cta

Joshen Lima03e107ce72c
diff --git a/studio/components/interfaces/Database/Hooks/HooksList/HooksList.tsx b/studio/components/interfaces/Database/Hooks/HooksList/HooksList.tsx
index 3e1f489da7c..77dad06c20b 100644
--- a/studio/components/interfaces/Database/Hooks/HooksList/HooksList.tsx
+++ b/studio/components/interfaces/Database/Hooks/HooksList/HooksList.tsx
@@ -14,6 +14,8 @@ import ProductEmptyState from 'components/to-be-cleaned/ProductEmptyState'
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
import { useDatabaseHooks } from 'data/database-triggers/database-triggers-query'
import { FormHeader } from 'components/ui/Forms'
+import ShimmeringLoader from 'components/ui/ShimmeringLoader'
+import ClientLoadingError from 'components/ui/ClientLoadingError'
function isHooksEnabled(schemas: any): boolean {
return schemas.some((schema: any) => schema.name === 'supabase_functions')
@@ -70,24 +72,6 @@ const HooksList: FC<any> = ({
)
}
- if (isLoading) {
- return (
- <div className="flex h-full w-full items-center justify-center space-x-2">
- <IconLoader className="animate-spin" size={14} />
- <p>Loading hooks...</p>
- </div>
- )
- }
-
- if (isError) {
- return (
- <p className="px-6 py-4">
- <p>Error connecting to API</p>
- <p>{`${meta.hooks.error?.message ?? 'Unknown error'}`}</p>
- </p>
- )
- }
-
return (
<>
<div className="flex items-center justify-between">
@@ -96,7 +80,18 @@ const HooksList: FC<any> = ({
description="Send real-time data from your database to another system whenever a table event occurs"
/>
</div>
- {(hooks || []).length == 0 ? (
+ {isLoading ? (
+ <div className="py-4 space-y-2">
+ <ShimmeringLoader />
+ <ShimmeringLoader className="w-3/4" />
+ <ShimmeringLoader className="w-1/2" />
+ </div>
+ ) : isError ? (
+ <ClientLoadingError
+ projectRef={project?.ref ?? ''}
+ description="Failed to retrieve database webhooks"
+ />
+ ) : (hooks || []).length == 0 ? (
<div className="flex h-full w-full items-center justify-center">
<ProductEmptyState
title="Database Webhooks"
diff --git a/studio/components/ui/ClientLoadingError.tsx b/studio/components/ui/ClientLoadingError.tsx
new file mode 100644
index 00000000000..d9da0fe8039
--- /dev/null
+++ b/studio/components/ui/ClientLoadingError.tsx
@@ -0,0 +1,34 @@
+import Link from 'next/link'
+import { Button, IconAlertCircle } from 'ui'
+
+export interface ClientLoadingErrorProps {
+ projectRef: string
+ description: string
+}
+
+const ClientLoadingError = ({
+ projectRef,
+ description = 'An error has occured',
+}: ClientLoadingErrorProps) => {
+ return (
+ <div className="px-6 py-4 bg-scale-400 border border-scale-600 rounded flex justify-between items-center">
+ <div className="flex space-x-4">
+ <IconAlertCircle strokeWidth={1.5} className="text-scale-1100" />
+ <div className="space-y-1">
+ <p className="text-sm text-scale-1200">{description}</p>
+ <p className="text-sm text-scale-1000">
+ Try refreshing your browser. However, if this issue persists, please reach out to us via
+ support.
+ </p>
+ </div>
+ </div>
+ <Link href={`/support/new?ref=${projectRef}`}>
+ <a target="_blank">
+ <Button>Contact support</Button>
+ </a>
+ </Link>
+ </div>
+ )
+}
+
+export default ClientLoadingError