mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 08:29:01 +00:00
## Problem Our `<Button>` component breaks the default `button` contract by redefining the `type` prop to set its variant (`primary`, `default`, etc) instead of the button type (`submit`, `button`, etc). This is confusing and forces to write more code when using it with shadcn components that expect/inject the standard button props. ## Solution - rename the `type` prop to `variant` - rename the `htmlType` prop to `type` - propagate the changes where necessary - format code ## How to test As this is just prop renaming, if it builds it's ok --------- Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
155 lines
4.9 KiB
TypeScript
155 lines
4.9 KiB
TypeScript
import { Search } from 'lucide-react'
|
|
import Link from 'next/link'
|
|
import React from 'react'
|
|
import {
|
|
BreadcrumbItem,
|
|
BreadcrumbLink,
|
|
BreadcrumbList,
|
|
BreadcrumbPage,
|
|
BreadcrumbSeparator,
|
|
Button,
|
|
Card,
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuSeparator,
|
|
DropdownMenuTrigger,
|
|
InputGroup,
|
|
InputGroupAddon,
|
|
InputGroupInput,
|
|
Table,
|
|
TableBody,
|
|
TableCell,
|
|
TableHead,
|
|
TableHeader,
|
|
TableRow,
|
|
} from 'ui'
|
|
import { PageBreadcrumbs } from 'ui-patterns/PageBreadcrumbs'
|
|
import { PageContainer } from 'ui-patterns/PageContainer'
|
|
import {
|
|
PageHeader,
|
|
PageHeaderDescription,
|
|
PageHeaderMeta,
|
|
PageHeaderSummary,
|
|
PageHeaderTitle,
|
|
} from 'ui-patterns/PageHeader'
|
|
import { PageSection, PageSectionContent } from 'ui-patterns/PageSection'
|
|
|
|
export default function PageLayoutList() {
|
|
const functions = [
|
|
{
|
|
id: 1,
|
|
name: 'get_user_profile',
|
|
arguments: 'user_id uuid',
|
|
return_type: 'jsonb',
|
|
security: 'Definer',
|
|
},
|
|
{
|
|
id: 2,
|
|
name: 'update_user_settings',
|
|
arguments: 'user_id uuid, settings jsonb',
|
|
return_type: 'void',
|
|
security: 'Invoker',
|
|
},
|
|
{
|
|
id: 3,
|
|
name: 'calculate_total',
|
|
arguments: 'amount numeric, tax_rate numeric',
|
|
return_type: 'numeric',
|
|
security: 'Definer',
|
|
},
|
|
]
|
|
|
|
return (
|
|
<div className="w-full">
|
|
<PageBreadcrumbs>
|
|
<BreadcrumbList>
|
|
<BreadcrumbItem>
|
|
<BreadcrumbLink asChild>
|
|
<Link href="/project/demo/database">Database</Link>
|
|
</BreadcrumbLink>
|
|
</BreadcrumbItem>
|
|
<BreadcrumbSeparator />
|
|
<BreadcrumbItem>
|
|
<BreadcrumbPage>Functions</BreadcrumbPage>
|
|
</BreadcrumbItem>
|
|
</BreadcrumbList>
|
|
</PageBreadcrumbs>
|
|
|
|
<PageHeader size="default">
|
|
<PageHeaderMeta>
|
|
<PageHeaderSummary>
|
|
<PageHeaderTitle>Database Functions</PageHeaderTitle>
|
|
<PageHeaderDescription>Manage your database functions</PageHeaderDescription>
|
|
</PageHeaderSummary>
|
|
</PageHeaderMeta>
|
|
</PageHeader>
|
|
|
|
<PageContainer size="default">
|
|
<PageSection>
|
|
<PageSectionContent>
|
|
<div className="w-full space-y-4">
|
|
<div className="flex flex-col lg:flex-row lg:items-center justify-between gap-2 flex-wrap">
|
|
<div className="flex flex-col lg:flex-row lg:items-center gap-2">
|
|
<InputGroup>
|
|
<InputGroupInput
|
|
placeholder="Search for a function"
|
|
size="tiny"
|
|
className="w-full lg:w-52"
|
|
/>
|
|
<InputGroupAddon>
|
|
<Search />
|
|
</InputGroupAddon>
|
|
</InputGroup>
|
|
</div>
|
|
<Button variant="primary">Create a new function</Button>
|
|
</div>
|
|
|
|
<Card>
|
|
<Table className="table-fixed overflow-x-auto">
|
|
<TableHeader>
|
|
<TableRow>
|
|
<TableHead>Name</TableHead>
|
|
<TableHead className="table-cell">Arguments</TableHead>
|
|
<TableHead className="table-cell">Return type</TableHead>
|
|
<TableHead className="table-cell w-[100px]">Security</TableHead>
|
|
<TableHead className="w-1/6"></TableHead>
|
|
</TableRow>
|
|
</TableHeader>
|
|
<TableBody>
|
|
{functions.map((fn) => (
|
|
<TableRow key={fn.id}>
|
|
<TableCell className="font-medium">{fn.name}</TableCell>
|
|
<TableCell>{fn.arguments}</TableCell>
|
|
<TableCell>{fn.return_type}</TableCell>
|
|
<TableCell>{fn.security}</TableCell>
|
|
<TableCell>
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger asChild>
|
|
<Button variant="text" size="small">
|
|
Actions
|
|
</Button>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent align="end">
|
|
<DropdownMenuItem>Edit</DropdownMenuItem>
|
|
<DropdownMenuItem>Duplicate</DropdownMenuItem>
|
|
<DropdownMenuSeparator />
|
|
<DropdownMenuItem className="text-destructive">
|
|
Delete
|
|
</DropdownMenuItem>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
</TableCell>
|
|
</TableRow>
|
|
))}
|
|
</TableBody>
|
|
</Table>
|
|
</Card>
|
|
</div>
|
|
</PageSectionContent>
|
|
</PageSection>
|
|
</PageContainer>
|
|
</div>
|
|
)
|
|
}
|