Files
supabase/apps/studio/components/ui/DocsButton.tsx
K-Dog (Kevin) 27c4433a3e feat: revised project add-ons page (#54186)
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.
2026-11-30 21:54:44 +08:00

71 lines
1.7 KiB
TypeScript

import { BookOpenIcon } from 'lucide-react'
import type { MouseEvent } from 'react'
import { Button } from 'ui'
import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
import { useTrack } from '@/lib/telemetry/track'
interface DocsButtonProps {
href: string
abbrev?: boolean
className?: string
topic?: string
/** Custom button text, e.g. to distinguish multiple docs buttons side by side. */
label?: string
/** Shows only the book icon, with the label in a tooltip */
iconOnly?: boolean
}
export const DocsButton = ({
href,
abbrev = true,
className,
topic,
label,
iconOnly = false,
}: DocsButtonProps) => {
const track = useTrack()
const handleClick = (e: MouseEvent<HTMLElement>) => {
e.stopPropagation()
track('docs_button_clicked', { ...(topic && { topic }) })
}
const text = label ?? (abbrev ? 'Docs' : 'Documentation')
const topicLabel = topic ? `${topic} documentation (opens in new tab)` : undefined
if (iconOnly) {
return (
<ButtonTooltip
asChild
variant="default"
className={className}
icon={<BookOpenIcon />}
onClick={handleClick}
tooltip={{ content: { side: 'bottom', text } }}
>
<a
target="_blank"
rel="noopener noreferrer"
href={href}
aria-label={topicLabel ?? `${text} (opens in new tab)`}
/>
</ButtonTooltip>
)
}
return (
<Button
asChild
variant="default"
className={className}
icon={<BookOpenIcon />}
onClick={handleClick}
>
<a target="_blank" rel="noopener noreferrer" href={href} aria-label={topicLabel}>
{text}
</a>
</Button>
)
}