mirror of
https://github.com/supabase/supabase.git
synced 2026-10-09 11:25:06 +03:00
## Context Small fix for the new home page "Recent branch" stat to add some truncate Before: <img width="500" height="198" alt="image" src="https://github.com/user-attachments/assets/f6a73934-52ea-4ed2-853d-3e4b0da054ab" /> After: <img width="500" height="343" alt="image" src="https://github.com/user-attachments/assets/9ede0378-b410-41f5-9f9d-e4273e76fcdd" /> Unrelated but I also set a max width to the project and branch dropdowns in the layout header <img width="950" height="69" alt="image" src="https://github.com/user-attachments/assets/d9fc52f6-50c8-4adb-9a79-da3b64eb7a7f" /> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Style** * Enhanced display of branch and project names with improved truncation and wider max-widths. * Added hover tooltips (title attributes) for branch and project names to improve accessibility. * Refined text overflow handling and styling across dropdowns and stat components. * **Tests** * Adjusted clipboard test timing to await the resolved promise before asserting write() was called. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
78 lines
2.0 KiB
TypeScript
78 lines
2.0 KiB
TypeScript
import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
|
|
import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
|
|
import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
|
|
import Link from 'next/link'
|
|
import type { ReactNode } from 'react'
|
|
import { cn } from 'ui'
|
|
|
|
type SingleStatProps = {
|
|
icon: ReactNode
|
|
label: ReactNode
|
|
value: ReactNode
|
|
className?: string
|
|
href?: string
|
|
onClick?: () => void
|
|
trackingProperties?: {
|
|
stat_type: 'migrations' | 'backups' | 'branches'
|
|
stat_value: number
|
|
}
|
|
}
|
|
|
|
export const SingleStat = ({
|
|
icon,
|
|
label,
|
|
value,
|
|
className,
|
|
href,
|
|
onClick,
|
|
trackingProperties,
|
|
}: SingleStatProps) => {
|
|
const { mutate: sendEvent } = useSendEventMutation()
|
|
const { data: project } = useSelectedProjectQuery()
|
|
const { data: organization } = useSelectedOrganizationQuery()
|
|
|
|
const trackActivityStat = () => {
|
|
if (trackingProperties && project?.ref && organization?.slug) {
|
|
sendEvent({
|
|
action: 'home_activity_stat_clicked',
|
|
properties: trackingProperties,
|
|
groups: {
|
|
project: project.ref,
|
|
organization: organization.slug,
|
|
},
|
|
})
|
|
}
|
|
}
|
|
const content = (
|
|
<div className={cn('group flex items-center gap-4 p-0 text-base justify-start', className)}>
|
|
<div className="min-w-16 w-16 h-16 rounded-md bg-surface-75 group-hover:bg-muted border flex items-center justify-center">
|
|
{icon}
|
|
</div>
|
|
<div className="truncate">
|
|
<div className="text-left heading-meta text-foreground-light">{label}</div>
|
|
<div className="text-foreground truncate h-[34px] flex items-center capitalize-sentence">
|
|
{value}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)
|
|
|
|
if (href) {
|
|
return (
|
|
<Link className="group block" href={href} onClick={trackActivityStat}>
|
|
{content}
|
|
</Link>
|
|
)
|
|
}
|
|
|
|
if (onClick) {
|
|
return (
|
|
<button className="group" onClick={onClick}>
|
|
{content}
|
|
</button>
|
|
)
|
|
}
|
|
|
|
return content
|
|
}
|