Skip to content

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

chore(studio): improve table presentation (#41217)

Danny White7d93a1951a51
diff --git a/apps/docs/content/guides/platform/your-monthly-invoice.mdx b/apps/docs/content/guides/platform/your-monthly-invoice.mdx
index 2388fc87db1..2f622d7165c 100644
--- a/apps/docs/content/guides/platform/your-monthly-invoice.mdx
+++ b/apps/docs/content/guides/platform/your-monthly-invoice.mdx
@@ -66,7 +66,7 @@ Monthly invoices are auto-collected by charging the payment method marked as "ac
If your payment fails, Supabase retries the charge several times. We send you a Payment Failure email with the reason for the failure. Follow the steps outlined in this email. You can manually trigger a charge at any time via
- the link in the Payment Failure email
-- the "Pay Now" button on the [organization's invoices page](/dashboard/org/_/billing#invoices)
+- the "Pay now" button on the [organization's invoices page](/dashboard/org/_/billing#invoices)
## Where to find your invoices
diff --git a/apps/studio/components/interfaces/Billing/InvoiceStatusBadge.tsx b/apps/studio/components/interfaces/Billing/InvoiceStatusBadge.tsx
index ff9f5d48d18..f0ff81794ba 100644
--- a/apps/studio/components/interfaces/Billing/InvoiceStatusBadge.tsx
+++ b/apps/studio/components/interfaces/Billing/InvoiceStatusBadge.tsx
@@ -57,48 +57,44 @@ const InvoiceStatusBadge = ({
{statusMapping?.label || status}
</Badge>
</TooltipTrigger>
- <TooltipContent side="bottom" className="max-w-sm">
+ <TooltipContent side="bottom" className="max-w-xs [&>p]:text-center [&>div>p]:text-center">
{[InvoiceStatus.OPEN, InvoiceStatus.ISSUED, InvoiceStatus.UNCOLLECTIBLE].includes(status) &&
(paymentProcessing ? (
<div className="space-y-1">
- <p className="text-xs text-foreground">
- While most credit card payments get processed instantly, some Indian credit card
- providers may take up to 72 hours. Your card issuer has neither confirmed nor denied
- the payment and we have to wait until the card issuer processed the payment.
+ <p>
+ While most credit card payments get processed instantly, some Indian card providers
+ may take up to 72 hours to process payments. We’re still waiting for your card
+ provider to process this payment.
</p>
- <p className="text-xs text-foreground">
- If you run into this, we recommend{' '}
+ <p>
+ We recommend proactively{' '}
<InlineLink href={`${DOCS_URL}/guides/platform/credits#credit-top-ups`}>
topping up your credits
</InlineLink>{' '}
- in advance to avoid running into this in the future.
+ to avoid this issue in the future.
</p>
</div>
) : paymentAttempted ? (
- <p className="text-xs text-foreground">
+ <p>
We were not able to collect the payment. Make sure you have a valid payment method and
enough funds. Outstanding invoices may cause restrictions. You can manually pay the
- invoice using the "Pay Now" button.
+ invoice using the “Pay now” button.
</p>
) : (
- <p className="text-xs text-foreground">
- The invoice will soon be charged for. In case you pay via invoice instead of card,
- please make sure to make the payment in a timely manner. You can also pay the invoice
- using your card now using the "Pay Now" button.
+ <p>
+ The invoice will soon be charged for. Please make sure to pay in a timely manner,
+ especially if you pay via invoice instead of card. You can pay the invoice using your
+ card using the “Pay now” button.
</p>
))}
{status === InvoiceStatus.PAID && (
- <p className="text-xs text-foreground">
- The invoice has been paid successfully. No action is required on your side.
- </p>
+ <p>The invoice has been paid successfully. No further action is required on your side.</p>
)}
{status === InvoiceStatus.VOID && (
- <p className="text-xs text-foreground">
- This invoice has been forgiven. No action is required on your side.
- </p>
+ <p>This invoice has been forgiven. No further action is required on your side.</p>
)}
</TooltipContent>
</Tooltip>
diff --git a/apps/studio/components/interfaces/Integrations/Wrappers/WrapperTable.tsx b/apps/studio/components/interfaces/Integrations/Wrappers/WrapperTable.tsx
index 5cead46c659..46af1b1529a 100644
--- a/apps/studio/components/interfaces/Integrations/Wrappers/WrapperTable.tsx
+++ b/apps/studio/components/interfaces/Integrations/Wrappers/WrapperTable.tsx
@@ -3,14 +3,15 @@ import { toast } from 'sonner'
import { useParams } from 'common'
import { useFDWsQuery } from 'data/fdw/fdws-query'
-import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
import { handleErrorOnDelete, useQueryStateWithSelect } from 'hooks/misc/useQueryStateWithSelect'
+import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
import {
Card,
- CardContent,
+ cn,
Table,
TableBody,
- TableCaption,
+ TableCell,
+ TableFooter,
TableHead,
TableHeader,
TableRow,
@@ -73,38 +74,50 @@ export const WrapperTable = ({ isLatest = false }: WrapperTableProps) => {
return (
<Card className="max-w-5xl">
- <CardContent className="p-0 pb-3">
- <Table className="">
- <TableCaption className="text-xs">
- {wrappers.length} {integration?.name}
- {wrappers.length > 1 ? 's' : ''} created
- </TableCaption>
- <TableHeader className="font-mono uppercase text-xs [&_th]:h-auto [&_th]:py-2">
- <TableRow className="rounded">
- <TableHead className="w-[220px]">Name</TableHead>
- <TableHead>Tables</TableHead>
- <TableHead>Encrypted key</TableHead>
- <TableHead className="text-right w-24"></TableHead>
- </TableRow>
- </TableHeader>
- <TableBody className="[&_td]:py-0 [&_tr]:h-[50px] [&_tr]:border-dotted bg-surface-100">
- {(isLatest ? wrappers.slice(0, 3) : wrappers).map((x) => {
- return (
- <WrapperRow
- key={x.id}
- wrapper={x}
- wrappers={wrappers}
- selectedWrapperToEdit={selectedWrapperToEdit}
- selectedWrapperToDelete={selectedWrapperToDelete}
- setSelectedWrapperToEdit={setSelectedWrapperToEdit}
- setSelectedWrapperToDelete={setSelectedWrapperToDelete}
- deletingWrapperIdRef={deletingWrapperIdRef}
- />
- )
- })}
- </TableBody>
- </Table>
- </CardContent>
+ <Table>
+ <TableHeader>
+ <TableRow>
+ <TableHead className="w-[220px]">Name</TableHead>
+ <TableHead>Tables</TableHead>
+ <TableHead>Encrypted key</TableHead>
+ <TableHead className="w-24">
+ <span className="sr-only">Actions</span>
+ </TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {(isLatest ? wrappers.slice(0, 3) : wrappers).map((x) => {
+ return (
+ <WrapperRow
+ key={x.id}
+ wrapper={x}
+ wrappers={wrappers}
+ selectedWrapperToEdit={selectedWrapperToEdit}
+ selectedWrapperToDelete={selectedWrapperToDelete}
+ setSelectedWrapperToEdit={setSelectedWrapperToEdit}
+ setSelectedWrapperToDelete={setSelectedWrapperToDelete}
+ deletingWrapperIdRef={deletingWrapperIdRef}
+ />
+ )
+ })}
+ </TableBody>
+ <TableFooter
+ className={cn(
+ 'text-xs font-normal text-center text-foreground-muted',
+ // Prevent the footer from being highlighted on hover
+ '[&>tr>td]:hover:bg-inherit',
+ // Conditionally remove the border-top if there are no wrappers
+ wrappers.length === 0 ? 'border-t-0' : ''
+ )}
+ >
+ <TableRow>
+ <TableCell colSpan={4}>
+ {wrappers.length} {integration?.name}
+ {wrappers.length > 1 ? 's' : ''} created
+ </TableCell>
+ </TableRow>
+ </TableFooter>
+ </Table>
</Card>
)
}
diff --git a/apps/studio/components/interfaces/Organization/InvoicesSettings/InvoicePayButton.tsx b/apps/studio/components/interfaces/Organization/InvoicesSettings/InvoicePayButton.tsx
index d90269b1272..7e8f28575c9 100644
--- a/apps/studio/components/interfaces/Organization/InvoicesSettings/InvoicePayButton.tsx
+++ b/apps/studio/components/interfaces/Organization/InvoicesSettings/InvoicePayButton.tsx
@@ -22,7 +22,7 @@ const InvoicePayButton = ({ slug, invoiceId }: InvoicePayButtonProps) => {
return (
<Button onClick={onPayNow} loading={isPending} disabled={isPending}>
- Pay Now
+ Pay now
</Button>
)
}
diff --git a/apps/studio/components/interfaces/Organization/InvoicesSettings/InvoicesSettings.tsx b/apps/studio/components/interfaces/Organization/InvoicesSettings/InvoicesSettings.tsx
index ef778bece6c..04452114ea0 100644
--- a/apps/studio/components/interfaces/Organization/InvoicesSettings/InvoicesSettings.tsx
+++ b/apps/studio/components/interfaces/Organization/InvoicesSettings/InvoicesSettings.tsx
@@ -1,10 +1,10 @@
import dayjs from 'dayjs'
+import { ChevronLeft, ChevronRight, Download, FileText } from 'lucide-react'
import { useEffect, useState } from 'react'
import { toast } from 'sonner'
import InvoiceStatusBadge from 'components/interfaces/Billing/InvoiceStatusBadge'
import { InvoiceStatus } from 'components/interfaces/Billing/Invoices.types'
-import Table from 'components/to-be-cleaned/Table'
import AlertError from 'components/ui/AlertError'
import { ButtonTooltip } from 'components/ui/ButtonTooltip'
import PartnerManagedResource from 'components/ui/PartnerManagedResource'
@@ -14,9 +14,19 @@ import { useInvoicesQuery } from 'data/invoices/invoices-query'
import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
import { MANAGED_BY } from 'lib/constants/infrastructure'
import { formatCurrency } from 'lib/helpers'
-import { ChevronLeft, ChevronRight, Download, FileText } from 'lucide-react'
import { Organization } from 'types/base'
-import { Button } from 'ui'
+import {
+ Button,
+ Card,
+ CardFooter,
+ cn,
+ Table,
+ TableBody,
+ TableCell,
+ TableHead,
+ TableHeader,
+ TableRow,
+} from 'ui'
import ShimmeringLoader from 'ui-patterns/ShimmeringLoader'
import InvoicePayButton from './InvoicePayButton'
@@ -90,72 +100,82 @@ export const InvoicesSettings = () => {
)
}
+ // Handle loading state faded text for table headers
+ const tableHeadClassName =
+ isLoading || invoices.length === 0 ? 'text-foreground-muted' : undefined
+
return (
- <div className="overflow-hidden md:overflow-auto overflow-x-scroll">
- <Table
- head={[
- <Table.th key="header-icon" />,
- <Table.th key="header-date">Date</Table.th>,
- <Table.th key="header-amount">Amount</Table.th>,
- <Table.th key="header-invoice">Invoice number</Table.th>,
- <Table.th key="header-status" className="flex items-center">
- Status
- </Table.th>,
- <Table.th key="header-download" className="text-right"></Table.th>,
- ]}
- body={
- isLoading ? (
+ <Card>
+ <Table>
+ <TableHeader>
+ <TableRow>
+ {invoices.length > 0 && (
+ <TableHead className="w-2">
+ <span className="sr-only">Icon</span>
+ </TableHead>
+ )}
+ <TableHead className={cn(tableHeadClassName)}>Date</TableHead>
+ <TableHead className={cn(tableHeadClassName)}>Amount</TableHead>
+ <TableHead className={cn(tableHeadClassName)}>Invoice number</TableHead>
+ <TableHead className={cn(tableHeadClassName)}>Status</TableHead>
+ <TableHead>
+ <span className="sr-only">Actions</span>
+ </TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {isLoading ? (
new Array(6).fill(0).map((_, idx) => (
- <Table.tr key={`loading-${idx}`}>
- <Table.td>{idx !== 5 && <FileText size="24" />}</Table.td>
- <Table.td colSpan={5}>
+ <TableRow key={`loading-${idx}`}>
+ <TableCell colSpan={invoices.length > 0 ? 6 : 5}>
<ShimmeringLoader />
- </Table.td>
- </Table.tr>
+ </TableCell>
+ </TableRow>
))
) : isError ? (
- <Table.tr className="rounded-b">
- <Table.td colSpan={6} className="!p-0 !rounded-b overflow-hidden">
+ <TableRow className="rounded-b">
+ <TableCell
+ colSpan={invoices.length > 0 ? 6 : 5}
+ className="!p-0 !rounded-b overflow-hidden"
+ >
<AlertError
className="border-0 rounded-none"
error={error}
subject="Failed to retrieve invoices"
/>
- </Table.td>
- </Table.tr>
+ </TableCell>
+ </TableRow>
) : invoices.length === 0 ? (
- <Table.tr>
- <Table.td colSpan={6} className="p-3 py-12 text-center">
- <p className="text-foreground-light">
- {isLoading ? 'Checking for invoices' : 'No invoices for this organization yet'}
- </p>
- </Table.td>
- </Table.tr>
+ <TableRow className="[&>td]:hover:bg-inherit">
+ <TableCell colSpan={5} className="py-6">
+ <p className="text-foreground-lighter">No invoices for this organization yet</p>
+ </TableCell>
+ </TableRow>
) : (
<>
{invoices.map((x) => {
return (
- <Table.tr key={x.id}>
- <Table.td>
- <FileText size="24" />
- </Table.td>
- <Table.td>
+ <TableRow key={x.id}>
+ <TableCell className="w-2">
+ <FileText aria-hidden="true" size={16} className="text-foreground-muted" />
+ </TableCell>
+ <TableCell>
<p>{dayjs(x.period_end * 1000).format('MMM DD, YYYY')}</p>
- </Table.td>
- <Table.td translate="no">
+ </TableCell>
+ <TableCell translate="no">
<p>{formatCurrency(x.amount_due / 100)}</p>
- </Table.td>
- <Table.td>
- <p>{x.number}</p>
- </Table.td>
- <Table.td>
+ </TableCell>
+ <TableCell>
+ <p className="font-mono text-foreground-light">{x.number}</p>
+ </TableCell>
+ <TableCell>
<InvoiceStatusBadge
status={x.status as InvoiceStatus}
paymentAttempted={x.payment_attempted}
paymentProcessing={x.payment_is_processing}
/>
- </Table.td>
- <Table.td className="align-right">
+ </TableCell>
+ <TableCell className="text-right">
<div className="flex items-center justify-end space-x-2">
{x.amount_due > 0 &&
!x.payment_is_processing &&
@@ -175,43 +195,43 @@ export const InvoicesSettings = () => {
tooltip={{ content: { side: 'bottom', text: 'Download invoice' } }}
/>
</div>
- </Table.td>
- </Table.tr>
+ </TableCell>
+ </TableRow>
)
})}
- <Table.tr key="navigation">
- <Table.td colSpan={6}>
- <div className="flex items-center justify-between">
- <p className="text-sm opacity-50">
- {isErrorCount
- ? 'Failed to retrieve total number of invoices'
- : `Showing ${offset + 1} to ${
- offset + invoices.length
- } out of ${count} invoices`}
- </p>
- <div className="flex items-center space-x-2">
- <Button
- icon={<ChevronLeft />}
- type="default"
- size="tiny"
- disabled={page === 1}
- onClick={async () => setPage(page - 1)}
- />
- <Button
- icon={<ChevronRight />}
- type="default"
- size="tiny"
- disabled={page * PAGE_LIMIT >= (count ?? 0)}
- onClick={async () => setPage(page + 1)}
- />
- </div>
- </div>
- </Table.td>
- </Table.tr>
</>
- )
- }
- />
- </div>
+ )}
+ </TableBody>
+ </Table>
+ {invoices.length > 0 && (
+ <CardFooter className="border-t p-4 flex items-center justify-between">
+ <p className="text-foreground-muted text-sm">
+ {isErrorCount
+ ? 'Failed to retrieve total number of invoices'
+ : typeof count === 'number'
+ ? `Showing ${offset + 1} to ${offset + invoices.length} out of ${count} invoices`
+ : `Showing ${offset + 1} to ${offset + invoices.length} invoices`}
+ </p>
+ <div className="flex items-center gap-x-2" aria-label="Pagination">
+ <Button
+ icon={<ChevronLeft />}
+ aria-label="Previous page"
+ type="default"
+ size="tiny"
+ disabled={page === 1}
+ onClick={async () => setPage(page - 1)}
+ />
+ <Button
+ icon={<ChevronRight />}
+ aria-label="Next page"
+ type="default"
+ size="tiny"
+ disabled={page * PAGE_LIMIT >= (count ?? 0)}
+ onClick={async () => setPage(page + 1)}
+ />
+ </div>
+ </CardFooter>
+ )}
+ </Card>
)
}
diff --git a/packages/ui/src/components/shadcn/ui/table.tsx b/packages/ui/src/components/shadcn/ui/table.tsx
index d56edc29c5a..3b4458a8f28 100644
--- a/packages/ui/src/components/shadcn/ui/table.tsx
+++ b/packages/ui/src/components/shadcn/ui/table.tsx
@@ -1,6 +1,6 @@
+import { ArrowDown, ArrowUp, ChevronsUpDown } from 'lucide-react'
import type { ComponentProps } from 'react'
import * as React from 'react'
-import { ArrowDown, ArrowUp, ChevronsUpDown } from 'lucide-react'
import { cn } from '../../../lib/utils/cn'
import { ShadowScrollArea } from '../../ShadowScrollArea'
@@ -44,11 +44,7 @@ const TableFooter = React.forwardRef<
HTMLTableSectionElement,
React.HTMLAttributes<HTMLTableSectionElement>
>(({ className, ...props }, ref) => (
- <tfoot
- ref={ref}
- className={cn('bg-primary font-medium text-primary-foreground', className)}
- {...props}
- />
+ <tfoot ref={ref} className={cn('border-t font-medium', className)} {...props} />
))
TableFooter.displayName = 'TableFooter'
@@ -163,7 +159,16 @@ const TableCaption = React.forwardRef<
HTMLTableCaptionElement,
React.HTMLAttributes<HTMLTableCaptionElement>
>(({ className, ...props }, ref) => (
- <caption ref={ref} className={cn('mt-4 text-sm text-foreground-muted', className)} {...props} />
+ <caption
+ ref={ref}
+ className={cn(
+ 'border-t', // TableCaption is aligned by parent Table at caption-bottom
+ 'p-4 text-sm text-foreground-muted', // Match styling of TableCell
+ className
+ )}
+ // Should only contain inline elements
+ {...props}
+ />
))
TableCaption.displayName = 'TableCaption'