Files
supabase/apps/studio/components/layouts/AppLayout/BranchDropdownCommandContent.tsx
Danny White 476d4a5851 refactor(ui): drop redundant Button variant="default" props (#50161)
## What kind of change does this PR introduce?

Mechanical cleanup on top of the Button default-variant change (#50160).

## What is the current behavior?

Many callsites still pass `variant="default"` even though that is now
the component default.

## What is the new behavior?

Removes redundant static `variant="default"` from legacy `Button` and
`ButtonTooltip` callsites. Keeps explicit defaults where they document
the API:

- `button-default.tsx` and `button-sizes.tsx` demos
- `DocsButton`, which pins neutral styling at the wrapper boundary

## To test

Studio:

- [Auth → Rate
Limits](https://studio-staging-2s957kwc4-supabase.vercel.app/dashboard/project/_/auth/rate-limits):
dirty the form so Cancel appears; Cancel stays neutral, Save stays green
- [Project Settings → API
Keys](https://studio-staging-2s957kwc4-supabase.vercel.app/dashboard/project/_/settings/api-keys):
`DocsButton` in the header actions stays neutral

Design system:

- [Design system →
Button](https://design-system-git-dnywh-dc924ac1-supabase.vercel.app/design-system/docs/components/button):
`button-default` / `button-sizes` still show explicit default styling;
Primary (green) is restricted to the Primary section (and `asChild`)

WWW:

- [www → Brand
assets](https://zone-www-dot-com-git-dnywh-dc924ac1-supabase.vercel.app/brand-assets):
Download logo kit / Download button kit stay neutral
2026-09-11 17:05:26 +10:00

185 lines
5.4 KiB
TypeScript

import { ListTree, MessageCircle, Plus } from 'lucide-react'
import Link from 'next/link'
import {
Button,
cn,
Command,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
CommandSeparator,
ScrollArea,
} from 'ui'
import { BranchLink } from './BranchLink'
import { CommandItemLink } from '@/components/ui/CommandItemLink'
import type { Branch } from '@/data/branches/branches-query'
import { useTrack } from '@/lib/telemetry/track'
const BRANCHING_GITHUB_DISCUSSION_LINK = 'https://github.com/orgs/supabase/discussions/18937'
export interface BranchDropdownCommandContentProps {
embedded: boolean
className?: string
branchList: Branch[]
selectedBranch: Branch | undefined
branchesCount: number
isBranchingEnabled: boolean
projectRef: string | undefined
onClose: () => void
onCreateBranch: () => void
}
export function BranchDropdownCommandContent({
embedded,
className,
branchList,
selectedBranch,
branchesCount,
isBranchingEnabled,
projectRef,
onClose,
onCreateBranch,
}: BranchDropdownCommandContentProps) {
const track = useTrack()
if (embedded) {
return (
<Command className={cn(className, 'flex flex-col flex-1 min-h-0 overflow-hidden')}>
<div className="grid grid-cols-2 gap-2 shrink-0 p-2 border-b">
<Button
variant="text"
size="small"
asChild
block
icon={<ListTree size={14} strokeWidth={1.5} />}
>
<Link
href={`/project/${projectRef}/branches`}
className="text-xs text-foreground-light hover:text-foreground"
onClick={onClose}
>
Manage branches
</Link>
</Button>
<Button
variant="text"
size="small"
asChild
block
icon={<MessageCircle size={14} strokeWidth={1.5} />}
>
<a
target="_blank"
rel="noreferrer noopener"
href={BRANCHING_GITHUB_DISCUSSION_LINK}
onClick={onClose}
className="text-xs text-foreground-light hover:text-foreground"
>
Branching feedback
</a>
</Button>
<Button
size="small"
block
className="col-span-full text-xs text-foreground-light hover:text-foreground"
onClick={() => {
track('branch_selector_create_clicked')
onClose()
onCreateBranch()
}}
icon={<Plus size={14} strokeWidth={1.5} />}
>
Create branch
</Button>
</div>
{isBranchingEnabled && (
<CommandInput placeholder="Find branch..." wrapperClassName="shrink-0 border-b" />
)}
<CommandList className="flex flex-col flex-1 p-1 min-h-0 overflow-y-auto max-h-none!">
{isBranchingEnabled && <CommandEmpty>No branches found</CommandEmpty>}
<CommandGroup className="min-h-0">
{branchList.map((branch) => (
<BranchLink
key={branch.id}
branch={branch}
isSelected={branch.id === selectedBranch?.id || branchesCount === 0}
onClose={onClose}
/>
))}
</CommandGroup>
</CommandList>
</Command>
)
}
return (
<Command className={className}>
{isBranchingEnabled && <CommandInput placeholder="Find branch..." />}
<CommandList>
{isBranchingEnabled && <CommandEmpty>No branches found</CommandEmpty>}
<CommandGroup>
<ScrollArea className="max-h-[210px] overflow-y-auto">
{branchList.map((branch) => (
<BranchLink
key={branch.id}
branch={branch}
isSelected={branch.id === selectedBranch?.id || branchesCount === 0}
onClose={onClose}
/>
))}
</ScrollArea>
</CommandGroup>
<CommandSeparator />
<CommandGroup>
<CommandItem
className="cursor-pointer w-full"
onSelect={() => {
track('branch_selector_create_clicked')
onClose()
onCreateBranch()
}}
>
<div className="w-full flex items-center gap-2">
<Plus size={14} strokeWidth={1.5} />
<p>Create branch</p>
</div>
</CommandItem>
<CommandItemLink
href={`/project/${projectRef}/branches`}
className="cursor-pointer w-full gap-2"
onSelect={() => {
track('branch_selector_manage_clicked')
onClose()
}}
>
<ListTree size={14} strokeWidth={1.5} />
<p>Manage branches</p>
</CommandItemLink>
</CommandGroup>
<CommandSeparator />
<CommandGroup>
<CommandItemLink
href={BRANCHING_GITHUB_DISCUSSION_LINK}
linkProps={{ target: '_blank', rel: 'noreferrer noopener' }}
className="cursor-pointer w-full gap-2"
onSelect={onClose}
>
<MessageCircle size={14} strokeWidth={1} className="mt-0.5" />
<div>
<p>Branching feedback</p>
<p className="text-lighter">Join GitHub Discussion</p>
</div>
</CommandItemLink>
</CommandGroup>
</CommandList>
</Command>
)
}