Skip to content

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

feat(studio): auth overview ui tidy (#39785)

kemal.earth53163c5bc3ab
diff --git a/apps/studio/components/interfaces/Auth/Overview/OverviewMonitoring.tsx b/apps/studio/components/interfaces/Auth/Overview/OverviewMonitoring.tsx
index ad4d748a52d..9e65ac30826 100644
--- a/apps/studio/components/interfaces/Auth/Overview/OverviewMonitoring.tsx
+++ b/apps/studio/components/interfaces/Auth/Overview/OverviewMonitoring.tsx
@@ -8,6 +8,7 @@ import {
Tooltip,
TooltipContent,
TooltipTrigger,
+ cn,
} from 'ui'
import {
fetchTopAuthErrorCodes,
@@ -93,10 +94,10 @@ export const OverviewMonitoring = () => {
})
const responseErrors: ResponseErrorRow[] = Array.isArray(respErrData?.result)
- ? (respErrData.result as unknown[]).filter(isResponseErrorRow)
+ ? (respErrData?.result as unknown[]).filter(isResponseErrorRow)
: []
const errorCodes: AuthErrorCodeRow[] = Array.isArray(codeErrData?.result)
- ? (codeErrData.result as unknown[]).filter(isAuthErrorCodeRow)
+ ? (codeErrData?.result as unknown[]).filter(isAuthErrorCodeRow)
: []
return (
@@ -105,7 +106,7 @@ export const OverviewMonitoring = () => {
<ScaffoldSectionTitle>Monitoring</ScaffoldSectionTitle>
</div>
<ScaffoldSectionContent className="gap-4">
- <div className="grid grid-cols-2 gap-3">
+ <div className="grid grid-cols-1 lg:grid-cols-2 gap-4">
<StatCard
title="Auth API Success Rate"
current={Math.max(0, 100 - metrics.current.apiErrorRate)}
@@ -130,10 +131,10 @@ export const OverviewMonitoring = () => {
/>
</div>
- <div className="grid grid-cols-2 gap-4">
+ <div className="grid grid-cols-1 lg:grid-cols-2 gap-4">
<Card>
- <CardHeader>
- <CardTitle className="text-foreground-lighter">Auth API Errors</CardTitle>
+ <CardHeader className={cn('border-b-0', responseErrors.length > 0 ? 'pb-4' : 'pb-0')}>
+ <CardTitle className="text-foreground-light">Auth API Errors</CardTitle>
</CardHeader>
<CardContent className="p-0">
<OverviewTable<ResponseErrorRow>
@@ -141,11 +142,11 @@ export const OverviewMonitoring = () => {
data={responseErrors}
columns={[
{
- key: 'method',
- header: 'Method',
+ key: 'request',
+ header: 'Request',
className: 'w-[60px]',
render: (row) => (
- <span className="text-foreground-lighter font-mono bg-background-alternative-200 px-2 py-1 rounded-md">
+ <span className="font-mono text-xs truncate select-text cursor-text py-1 px-1.5 text-center rounded-md bg-alternative-200">
{row.method}
</span>
),
@@ -158,15 +159,32 @@ export const OverviewMonitoring = () => {
<DataTableColumnStatusCode
value={row.status_code}
level={getStatusLevel(row.status_code)}
+ className="text-sm"
/>
),
},
- { key: 'path', header: 'Path', className: 'w-full' },
- { key: 'count', header: 'Count', className: 'text-right' },
+ {
+ key: 'path',
+ header: 'Path',
+ className: 'flex-shrink-0 w-52',
+ render: (row) => (
+ <div className="line-clamp-1 font-mono text-foreground-light text-xs">
+ {row.path}
+ </div>
+ ),
+ },
+ {
+ key: 'count',
+ header: 'Count',
+ className: 'text-right flex-shrink-0 ml-auto justify-end',
+ render: (row) => (
+ <div className="text-right text-xs tabular-nums">{row.count}</div>
+ ),
+ },
{
key: 'actions',
header: '',
- className: 'text-right',
+ className: 'text-right flex-shrink-0',
render: (row) => (
<div>
<LogsLink href={`/project/${ref}/logs/edge-logs?s=${row.path}`} />
@@ -179,16 +197,32 @@ export const OverviewMonitoring = () => {
</Card>
<Card>
- <CardHeader>
- <CardTitle className="text-foreground-lighter">Auth Server Errors</CardTitle>
+ <CardHeader className={cn('border-b-0', errorCodes.length > 0 ? 'pb-4' : 'pb-0')}>
+ <CardTitle className="text-foreground-light">Auth Server Errors</CardTitle>
</CardHeader>
<CardContent className="p-0">
<OverviewTable<AuthErrorCodeRow>
isLoading={isLoadingCodes || currentLoading || previousLoading}
data={errorCodes}
columns={[
- { key: 'error_code', header: 'Error code', className: 'w-full' },
- { key: 'count', header: 'Count', className: 'text-right' },
+ {
+ key: 'error_code',
+ header: 'Error code',
+ className: 'w-full',
+ render: (row) => (
+ <div className="line-clamp-1 font-mono text-foreground uppercase text-xs">
+ {row.error_code}
+ </div>
+ ),
+ },
+ {
+ key: 'count',
+ header: 'Count',
+ className: 'text-right',
+ render: (row) => (
+ <div className="text-right text-xs tabular-nums">{row.count}</div>
+ ),
+ },
{
key: 'actions',
header: '',
diff --git a/apps/studio/components/interfaces/Auth/Overview/OverviewTable.tsx b/apps/studio/components/interfaces/Auth/Overview/OverviewTable.tsx
index 4ef13c45add..91ee66dd7e4 100644
--- a/apps/studio/components/interfaces/Auth/Overview/OverviewTable.tsx
+++ b/apps/studio/components/interfaces/Auth/Overview/OverviewTable.tsx
@@ -1,6 +1,7 @@
import { ReactNode } from 'react'
import { cn, Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from 'ui'
import { Loader2 } from 'lucide-react'
+import NoDataPlaceholder from 'components/ui/Charts/NoDataPlaceholder'
export type OverviewTableColumn<T> = {
key: keyof T | string
@@ -17,44 +18,57 @@ export interface OverviewTable<T> {
}
export function OverviewTable<T>({ columns, data, isLoading, emptyMessage }: OverviewTable<T>) {
+ const hasData = !isLoading && data.length > 0
+
return (
<Table>
- <TableHeader>
- <TableRow>
- {columns.map((col) => (
- <TableHead key={String(col.key)} className={col.className}>
- {col.header}
- </TableHead>
- ))}
- </TableRow>
- </TableHeader>
+ {hasData && (
+ <TableHeader>
+ <TableRow>
+ {columns.map((col) => (
+ <TableHead
+ key={String(col.key)}
+ className={cn(col.className, 'bg-surface-200 border-t h-8 px-6')}
+ >
+ {col.header}
+ </TableHead>
+ ))}
+ </TableRow>
+ </TableHeader>
+ )}
<TableBody className="text-foreground">
{isLoading ? (
- <TableRow>
+ <TableRow className="[&>td]:hover:bg-transparent">
<TableCell colSpan={columns.length} className="text-center text-foreground-light">
<div className="flex items-center justify-center gap-2 py-4">
<Loader2 className="size-4 animate-spin" />
- <span>Loading…</span>
</div>
</TableCell>
</TableRow>
) : data.length === 0 ? (
- <TableRow>
+ <TableRow className="[&>td]:hover:bg-transparent">
<TableCell colSpan={columns.length} className="text-center text-foreground-light">
- {emptyMessage || 'No data available'}
+ <div className="p-2 pt-0">
+ <NoDataPlaceholder
+ size="normal"
+ message={emptyMessage || 'No data available'}
+ isFullHeight
+ />
+ </div>
</TableCell>
</TableRow>
) : (
(data as unknown as T[]).map((row, idx) => (
<TableRow key={idx}>
{columns.map((col) => (
- <TableCell key={String(col.key)} className={cn('p-2 px-4', col.className)}>
+ <TableCell key={String(col.key)} className={cn('py-1.5 px-6', col.className)}>
{col.render ? col.render(row) : (row as any)[col.key as string]}
</TableCell>
))}
</TableRow>
))
)}
+ {data.length > 0 && <span className="h-2 flex w-full" />}
</TableBody>
</Table>
)
diff --git a/apps/studio/components/interfaces/Auth/Overview/OverviewUsage.tsx b/apps/studio/components/interfaces/Auth/Overview/OverviewUsage.tsx
index 4fd3fd697ba..da2b2a5e80a 100644
--- a/apps/studio/components/interfaces/Auth/Overview/OverviewUsage.tsx
+++ b/apps/studio/components/interfaces/Auth/Overview/OverviewUsage.tsx
@@ -3,19 +3,10 @@ import {
ScaffoldSectionTitle,
ScaffoldSectionContent,
} from 'components/layouts/Scaffold'
-import {
- Card,
- CardContent,
- CardHeader,
- CardTitle,
- cn,
- Tooltip,
- TooltipTrigger,
- TooltipContent,
-} from 'ui'
+import { Card, CardContent, CardHeader, CardTitle, cn, Skeleton } from 'ui'
import Link from 'next/link'
import { useParams } from 'common'
-import { ChevronRight, Loader2 } from 'lucide-react'
+import { ChevronRight, ExternalLink } from 'lucide-react'
import { Reports } from 'icons'
import {
getChangeColor,
@@ -26,6 +17,8 @@ import {
import { useQuery } from '@tanstack/react-query'
import dayjs from 'dayjs'
import AlertError from 'components/ui/AlertError'
+import { ButtonTooltip } from 'components/ui/ButtonTooltip'
+import { useRouter } from 'next/router'
export const StatCard = ({
title,
@@ -44,6 +37,7 @@ export const StatCard = ({
invert?: boolean
href?: string
}) => {
+ const router = useRouter()
const isZeroChange = previous === 0
const changeColor = isZeroChange
? 'text-foreground-lighter'
@@ -57,36 +51,41 @@ export const StatCard = ({
const signChar = previous > 0 ? '+' : previous < 0 ? '-' : ''
return (
- <Card className={cn(href)}>
- <CardHeader className="flex flex-row items-center justify-between p-2 pl-4 pr-2 space-y-0">
- <CardTitle className="text-foreground-lighter">{title}</CardTitle>
- <Tooltip>
- <TooltipTrigger asChild>
- <Link
- href={href || ''}
- className="text-foreground-lighter hover:text-foreground block p-2"
- >
- <ChevronRight className="size-4" />
- </Link>
- </TooltipTrigger>
- <TooltipContent>Go to Auth Report</TooltipContent>
- </Tooltip>
+ <Card className={cn(href, 'mb-0 flex flex-col')}>
+ <CardHeader className="flex flex-row items-center justify-between gap-2 space-y-0 pb-0 border-b-0 relative">
+ <CardTitle className="text-foreground-light">{title}</CardTitle>
+ <ButtonTooltip
+ type="text"
+ size="tiny"
+ icon={<ExternalLink />}
+ className="w-6 h-6 absolute right-4 top-3"
+ onClick={() => router.push(href || '')}
+ tooltip={{
+ content: {
+ side: 'top',
+ text: 'Go to Auth Report',
+ },
+ }}
+ />
</CardHeader>
<CardContent
className={cn(
- 'flex flex-col my-1 gap-1 px-5',
- loading && 'opacity-50 items-center justify-center min-h-[108px]'
+ 'pb-4 px-6 pt-0 flex-1 h-full overflow-hidden',
+ loading && 'pt-2 opacity-50 items-center justify-center'
)}
>
{loading ? (
- <Loader2 className="size-5 animate-spin text-foreground-light" />
+ <div className="flex flex-col gap-2">
+ <Skeleton className="h-6 w-20" />
+ <Skeleton className="h-3 w-8" />
+ </div>
) : (
- <>
+ <div className="flex flex-col gap-0.5">
<p className="text-xl">{`${formattedCurrent}${suffix}`}</p>
- <div className={cn('flex items-center gap-1 text-sm', changeColor)}>
+ <span className={cn('flex items-center gap-1 text-sm', changeColor)}>
<span>{`${signChar}${Math.abs(previous).toFixed(1)}%`}</span>
- </div>
- </>
+ </span>
+ </div>
)}
</CardContent>
</Card>
@@ -159,7 +158,7 @@ export const OverviewUsage = () => {
</Link>
</div>
<ScaffoldSectionContent className="gap-4">
- <div className="grid grid-cols-2 gap-3">
+ <div className="grid grid-cols-1 lg:grid-cols-2 gap-4">
<StatCard
title="Active users"
current={metrics.current.activeUsers}