Files
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

137 lines
3.5 KiB
TypeScript

import {
Button,
Select,
SelectContent,
SelectGroup,
SelectItem,
SelectTrigger,
SelectValue,
} from 'ui'
import { SchemaSelector } from '@/components/ui/SchemaSelector'
export interface PrivilegesHeadProps {
disabled: boolean
selectedSchema: string
selectedRole: string
selectedTable?: { name: string }
tables: string[]
roles: string[]
onChangeSchema: (schema: string) => void
onChangeRole: (role: string) => void
onChangeTable: (table: string) => void
hasChanges?: boolean
resetChanges: () => void
applyChanges: () => void
isApplyingChanges?: boolean
}
const PrivilegesHead = ({
disabled,
selectedSchema,
onChangeSchema,
selectedRole,
roles,
onChangeRole,
selectedTable,
tables,
onChangeTable,
hasChanges = false,
resetChanges,
applyChanges,
isApplyingChanges = false,
}: PrivilegesHeadProps) => {
return (
<div className="flex items-center justify-between">
<div className="flex items-center gap-x-2">
<SchemaSelector
className="bg-control rounded-md w-[180px] [&>button]:py-[5px]"
selectedSchemaName={selectedSchema}
onSelectSchema={onChangeSchema}
/>
<TablesSelect selectedTable={selectedTable} tables={tables} onChangeTable={onChangeTable} />
<div className="h-[20px] w-px border-r border-scale-600"></div>
<RolesSelect selectedRole={selectedRole} roles={roles} onChangeRole={onChangeRole} />
</div>
<div className="flex items-center gap-2">
<Button size="tiny" onClick={resetChanges} disabled={!hasChanges || isApplyingChanges}>
Reset
</Button>
<Button
variant="primary"
size="tiny"
onClick={applyChanges}
disabled={disabled || !hasChanges || isApplyingChanges}
loading={isApplyingChanges}
>
Apply Changes
</Button>
</div>
</div>
)
}
const RolesSelect = ({
selectedRole,
roles,
onChangeRole,
}: {
selectedRole: string
roles: string[]
onChangeRole: (role: string) => void
}) => {
return (
<Select value={selectedRole} onValueChange={onChangeRole}>
<SelectTrigger size="tiny" className="w-40">
<SelectValue placeholder="Select a role" />
</SelectTrigger>
<SelectContent>
<SelectGroup>
{roles.map((role) => (
<SelectItem key={role} value={role} className="text-xs">
<span className="text-foreground-light mr-1">role</span> {role}
</SelectItem>
))}
</SelectGroup>
</SelectContent>
</Select>
)
}
const TablesSelect = ({
selectedTable,
tables,
onChangeTable,
}: {
selectedTable?: {
name: string
}
tables: string[]
onChangeTable: (table: string) => void
}) => {
return (
<Select value={selectedTable?.name} onValueChange={onChangeTable}>
<SelectTrigger size="tiny" className="w-44">
<SelectValue placeholder="Select a table" />
</SelectTrigger>
<SelectContent>
<SelectGroup>
{tables.length === 0 ? (
<div className="text-xs text-foreground-light p-2">
No tables available in this schema
</div>
) : null}
{tables.map((table) => (
<SelectItem key={table} value={table} className="text-xs">
<span className="text-foreground-light mr-1">table</span> {table}
</SelectItem>
))}
</SelectGroup>
</SelectContent>
</Select>
)
}
export default PrivilegesHead