Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Edit, MoreVertical, Search, Trash } from 'lucide-react'
import { useState } from 'react'

import Table from 'components/to-be-cleaned/Table'
import AlertError from 'components/ui/AlertError'
import { DocsButton } from 'components/ui/DocsButton'
import SchemaSelector from 'components/ui/SchemaSelector'
Expand All @@ -15,11 +14,18 @@ import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
import { useIsProtectedSchema } from 'hooks/useProtectedSchemas'
import {
Button,
Card,
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
Input,
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from 'ui'
import { ProtectedSchemaWarning } from '../ProtectedSchemaWarning'
import CreateEnumeratedTypeSidePanel from './CreateEnumeratedTypeSidePanel'
Expand Down Expand Up @@ -94,75 +100,79 @@ const EnumeratedTypes = () => {
)}

{isSuccess && (
<Table
head={[
<Table.th key="schema">Schema</Table.th>,
<Table.th key="name">Name</Table.th>,
<Table.th key="values">Values</Table.th>,
<Table.th key="actions" />,
]}
body={
<>
{filteredEnumeratedTypes.length === 0 && search.length === 0 && (
<Table.tr>
<Table.td colSpan={4}>
<p className="text-sm text-foreground">No enumerated types created yet</p>
<p className="text-sm text-foreground-light">
There are no enumerated types found in the schema "{selectedSchema}"
</p>
</Table.td>
</Table.tr>
)}
{filteredEnumeratedTypes.length === 0 && search.length > 0 && (
<Table.tr>
<Table.td colSpan={4}>
<p className="text-sm text-foreground">No results found</p>
<p className="text-sm text-foreground-light">
Your search for "{search}" did not return any results
</p>
</Table.td>
</Table.tr>
)}
{filteredEnumeratedTypes.length > 0 &&
filteredEnumeratedTypes.map((type) => (
<Table.tr key={type.id}>
<Table.td className="w-20">
<p className="w-20 truncate">{type.schema}</p>
</Table.td>
<Table.td>{type.name}</Table.td>
<Table.td>{type.enums.join(', ')}</Table.td>
<Table.td>
{!isSchemaLocked && (
<div className="flex justify-end items-center space-x-2">
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button type="default" className="px-1" icon={<MoreVertical />} />
</DropdownMenuTrigger>
<DropdownMenuContent side="bottom" align="end" className="w-32">
<DropdownMenuItem
className="space-x-2"
onClick={() => setSelectedTypeToEdit(type)}
>
<Edit size={14} />
<p>Update type</p>
</DropdownMenuItem>
<DropdownMenuItem
className="space-x-2"
onClick={() => setSelectedTypeToDelete(type)}
>
<Trash size={14} />
<p>Delete type</p>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</div>
)}
</Table.td>
</Table.tr>
))}
</>
}
/>
<Card>
<Table>
<TableHeader>
<TableRow>
<TableHead key="schema">Schema</TableHead>
<TableHead key="name">Name</TableHead>
<TableHead key="values">Values</TableHead>
<TableHead key="actions" />
</TableRow>
</TableHeader>
<TableBody>
<>
{filteredEnumeratedTypes.length === 0 && search.length === 0 && (
<TableRow>
<TableCell colSpan={4}>
<p className="text-sm text-foreground">No enumerated types created yet</p>
<p className="text-sm text-foreground-light">
There are no enumerated types found in the schema "{selectedSchema}"
</p>
</TableCell>
</TableRow>
)}
{filteredEnumeratedTypes.length === 0 && search.length > 0 && (
<TableRow>
<TableCell colSpan={4}>
<p className="text-sm text-foreground">No results found</p>
<p className="text-sm text-foreground-light">
Your search for "{search}" did not return any results
</p>
</TableCell>
</TableRow>
)}
{filteredEnumeratedTypes.length > 0 &&
filteredEnumeratedTypes.map((type) => (
<TableRow key={type.id}>
<TableCell className="w-20">
<p className="w-20 truncate">{type.schema}</p>
</TableCell>
<TableCell>{type.name}</TableCell>
<TableCell>{type.enums.join(', ')}</TableCell>
<TableCell>
{!isSchemaLocked && (
<div className="flex justify-end items-center space-x-2">
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button type="default" className="px-1" icon={<MoreVertical />} />
</DropdownMenuTrigger>
<DropdownMenuContent side="bottom" align="end" className="w-32">
<DropdownMenuItem
className="space-x-2"
onClick={() => setSelectedTypeToEdit(type)}
>
<Edit size={14} />
<p>Update type</p>
</DropdownMenuItem>
<DropdownMenuItem
className="space-x-2"
onClick={() => setSelectedTypeToDelete(type)}
>
<Trash size={14} />
<p>Delete type</p>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</div>
)}
</TableCell>
</TableRow>
))}
</>
</TableBody>
</Table>
</Card>
)}

<CreateEnumeratedTypeSidePanel
Expand Down
Loading
Loading