mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 15:39:13 +00:00
The current add-ons page only lists a subset of available add-ons, which often causes confusion with things like Advanced MFA Auth (customers cant find where to configure it). The revised add-on page covers all potentially configured project add-ons including replicas and advanced disk. This should help the customer locate configured add-ons and at the same time discover potentially interesting add-ons. This can be enhanced further in the future with "smart" suggestions based on usage.
108 lines
3.3 KiB
TypeScript
108 lines
3.3 KiB
TypeScript
import type { LucideIcon } from 'lucide-react'
|
|
import type { ReactNode } from 'react'
|
|
import { cn } from 'ui'
|
|
import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'
|
|
|
|
import { DocsButton } from '@/components/ui/DocsButton'
|
|
import { ResourceList } from '@/components/ui/Resource/ResourceList'
|
|
|
|
export interface AddonRowProps {
|
|
icon: LucideIcon
|
|
title: string
|
|
description: string
|
|
docsUrl: string
|
|
isEnabled: boolean
|
|
/** Short state shown on the right (e.g. "Enabled", "Small", "2 active"). Hidden while loading. */
|
|
status?: string
|
|
/** Secondary text under the status (e.g. price). When multiple lines are passed, the first is emphasized. */
|
|
detail?: string | readonly string[]
|
|
action: ReactNode
|
|
isLoading?: boolean
|
|
isError?: boolean
|
|
}
|
|
|
|
const AddonDetail = ({ detail }: { detail: string | readonly string[] }) => {
|
|
const lines = typeof detail === 'string' ? [detail] : detail
|
|
if (lines.length === 0) return null
|
|
|
|
const [firstLine, ...otherLines] = lines
|
|
|
|
return (
|
|
<div className="text-xs text-foreground-lighter">
|
|
<div className={cn(otherLines.length > 0 && 'text-foreground-light')}>{firstLine}</div>
|
|
{otherLines.map((line, index) => (
|
|
<div key={`${index}-${line}`}>{line}</div>
|
|
))}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export const AddonRow = ({
|
|
icon: Icon,
|
|
title,
|
|
description,
|
|
docsUrl,
|
|
isEnabled,
|
|
status,
|
|
detail,
|
|
action,
|
|
isLoading = false,
|
|
isError = false,
|
|
}: AddonRowProps) => {
|
|
return (
|
|
<div className="flex flex-col gap-3 border-b px-4 py-3 text-sm last:border-b-0 sm:flex-row sm:items-center">
|
|
<div className="flex flex-1 items-start gap-3 sm:items-center">
|
|
<div
|
|
aria-hidden="true"
|
|
className={cn(
|
|
'flex size-8 shrink-0 items-center justify-center rounded-lg border',
|
|
isEnabled
|
|
? 'border-brand-400 bg-brand-200 text-brand-600'
|
|
: 'bg-surface-100 text-foreground-light'
|
|
)}
|
|
>
|
|
<Icon size={16} strokeWidth={1.5} />
|
|
</div>
|
|
<div className="flex-1 space-y-0.5">
|
|
<div className="text-foreground">{title}</div>
|
|
<p className="m-0 text-foreground-light">{description}</p>
|
|
</div>
|
|
</div>
|
|
<div className="flex items-center justify-between gap-3 pl-11 sm:justify-end sm:pl-0">
|
|
<div className="sm:text-right">
|
|
{isLoading && <ShimmeringLoader className="w-24 py-2.5" />}
|
|
{!isLoading && isError && <span className="text-foreground-lighter">Failed to load</span>}
|
|
{!isLoading && !isError && (
|
|
<>
|
|
{status && (
|
|
<div className={cn(isEnabled ? 'text-foreground' : 'text-foreground-lighter')}>
|
|
{status}
|
|
</div>
|
|
)}
|
|
{detail && <AddonDetail detail={detail} />}
|
|
</>
|
|
)}
|
|
</div>
|
|
<div className="flex items-center justify-end gap-2 sm:ml-3">
|
|
<DocsButton iconOnly href={docsUrl} topic={title} />
|
|
{action}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
interface AddonCategoryProps {
|
|
label: string
|
|
children: ReactNode
|
|
}
|
|
|
|
export const AddonCategory = ({ label, children }: AddonCategoryProps) => (
|
|
<ResourceList>
|
|
<h3 className="heading-meta flex h-9 items-center border-b bg-surface-75 px-4 text-foreground-lighter">
|
|
{label}
|
|
</h3>
|
|
{children}
|
|
</ResourceList>
|
|
)
|