mirror of
https://github.com/supabase/supabase.git
synced 2026-10-11 04:15:04 +03:00
## What kind of change does this PR introduce? UI polish. ## What is the current behavior? - A few product sidebar areas render menu rows outside the shared ProductMenu/Menu.Item styling path, so their hover and selected states differ from the rest of Studio. - Database product menu shortcut tooltips are also scoped to the text label instead of the full hoverable row. ## What is the new behavior? - Integrations Explore/Installed, Observability, and Reports sidebar rows now use the shared ProductMenu or Menu.Item pill styling. - Observability spacing is tightened after the ProductMenu conversion. - Product menu shortcut tooltips now wrap the full row trigger, so the entire Database sidebar row opens the tooltip. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * Enhanced navigation menu components with improved loading and error state handling across the dashboard. * Streamlined menu structure and styling consistency for integrations, reports, and observability sections. * Added enhanced tooltip support for navigation items. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
88 lines
2.2 KiB
TypeScript
88 lines
2.2 KiB
TypeScript
import Link from 'next/link'
|
|
import { Badge, Button, Menu } from 'ui'
|
|
|
|
import { ProductMenuGroupItem } from './ProductMenu.types'
|
|
import { ShortcutTooltip } from '@/components/ui/ShortcutTooltip'
|
|
|
|
interface ProductMenuItemProps {
|
|
item: ProductMenuGroupItem
|
|
isActive: boolean
|
|
target?: '_blank' | '_self'
|
|
hoverText?: string
|
|
onClick?: () => void
|
|
}
|
|
|
|
export const ProductMenuItem = ({
|
|
item,
|
|
isActive,
|
|
target = '_self',
|
|
hoverText = '',
|
|
onClick,
|
|
}: ProductMenuItemProps) => {
|
|
const { name = '', url = '', icon, rightIcon, isExternal, label, disabled, shortcutId } = item
|
|
|
|
const menuItem = (
|
|
<Menu.Item icon={icon} active={isActive} onClick={onClick}>
|
|
<div className="flex w-full items-center justify-between gap-1">
|
|
<div
|
|
className="flex items-center gap-1 min-w-0 flex-1"
|
|
title={
|
|
shortcutId ? undefined : hoverText ? hoverText : typeof name === 'string' ? name : ''
|
|
}
|
|
>
|
|
<span className="truncate flex-1 min-w-0">{name}</span>
|
|
{label !== undefined && (
|
|
<Badge
|
|
className="shrink-0"
|
|
variant={label.toLowerCase() === 'new' ? 'success' : 'warning'}
|
|
>
|
|
{label}
|
|
</Badge>
|
|
)}
|
|
</div>
|
|
{rightIcon && <div>{rightIcon}</div>}
|
|
</div>
|
|
</Menu.Item>
|
|
)
|
|
|
|
if (disabled) {
|
|
return <div className="opacity-50 pointer-events-none">{menuItem}</div>
|
|
}
|
|
|
|
if (url) {
|
|
if (isExternal) {
|
|
const externalLink = (
|
|
<Button asChild block className="justify-start!" type="text" size="small" icon={icon}>
|
|
<Link href={url} target="_blank" rel="noreferrer">
|
|
{name}
|
|
</Link>
|
|
</Button>
|
|
)
|
|
|
|
return shortcutId ? (
|
|
<ShortcutTooltip shortcutId={shortcutId} side="right" delayDuration={1000}>
|
|
{externalLink}
|
|
</ShortcutTooltip>
|
|
) : (
|
|
externalLink
|
|
)
|
|
}
|
|
|
|
const link = (
|
|
<Link href={url} className="block" target={target} onClick={onClick}>
|
|
{menuItem}
|
|
</Link>
|
|
)
|
|
|
|
return shortcutId ? (
|
|
<ShortcutTooltip shortcutId={shortcutId} side="right" delayDuration={1000}>
|
|
{link}
|
|
</ShortcutTooltip>
|
|
) : (
|
|
link
|
|
)
|
|
}
|
|
|
|
return menuItem
|
|
}
|