mirror of
https://github.com/supabase/supabase.git
synced 2026-10-09 03:15:06 +03:00
## Problem The `_Shadcn_` suffix isn't needed anymore on `Command` components ## Solution - Remove the `_Shadcn_` suffix - Simplify UI package exports - Apply prettier <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * Simplified command component imports and exports across the UI library by removing internal naming aliases and adopting direct component references. Updated the public UI package barrel export to use wildcard re-exports for cleaner API surface. <!-- review_stack_entry_start --> [](https://app.coderabbit.ai/change-stack/supabase/supabase/pull/46153?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
import { Check, Shield } from 'lucide-react'
|
|
import Link from 'next/link'
|
|
import { useRouter } from 'next/router'
|
|
import { CommandItem } from 'ui'
|
|
|
|
import { sanitizeRoute } from './ProjectDropdown.utils'
|
|
import type { Branch } from '@/data/branches/branches-query'
|
|
import { useTrack } from '@/lib/telemetry/track'
|
|
|
|
export interface BranchLinkProps {
|
|
branch: Branch
|
|
isSelected: boolean
|
|
onClose: () => void
|
|
}
|
|
|
|
export function BranchLink({ branch, isSelected, onClose }: BranchLinkProps) {
|
|
const track = useTrack()
|
|
const router = useRouter()
|
|
const sanitizedRoute = sanitizeRoute(router.route, router.query)
|
|
const href =
|
|
sanitizedRoute?.replace('[ref]', branch.project_ref) ?? `/project/${branch.project_ref}`
|
|
|
|
return (
|
|
<Link passHref href={href}>
|
|
<CommandItem
|
|
value={branch.name.replaceAll('"', '')}
|
|
className="cursor-pointer w-full flex items-center justify-between text-sm md:text-xs p-2 md:py-1.5 md:px-2"
|
|
onSelect={() => {
|
|
track('branch_selector_branch_clicked', {
|
|
branchId: branch.id,
|
|
branchName: branch.name,
|
|
})
|
|
onClose()
|
|
}}
|
|
>
|
|
<p className="truncate w-60 flex items-center gap-1" title={branch.name}>
|
|
{branch.is_default && <Shield size={14} className="text-amber-900" />}
|
|
{branch.name}
|
|
</p>
|
|
{isSelected && <Check size={14} strokeWidth={1.5} />}
|
|
</CommandItem>
|
|
</Link>
|
|
)
|
|
}
|