11import { Edit , MoreVertical , Search , Trash } from 'lucide-react'
22import { useState } from 'react'
33
4- import Table from 'components/to-be-cleaned/Table'
54import AlertError from 'components/ui/AlertError'
65import { DocsButton } from 'components/ui/DocsButton'
76import SchemaSelector from 'components/ui/SchemaSelector'
@@ -15,11 +14,18 @@ import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
1514import { useIsProtectedSchema } from 'hooks/useProtectedSchemas'
1615import {
1716 Button ,
17+ Card ,
1818 DropdownMenu ,
1919 DropdownMenuContent ,
2020 DropdownMenuItem ,
2121 DropdownMenuTrigger ,
2222 Input ,
23+ Table ,
24+ TableBody ,
25+ TableCell ,
26+ TableHead ,
27+ TableHeader ,
28+ TableRow ,
2329} from 'ui'
2430import { ProtectedSchemaWarning } from '../ProtectedSchemaWarning'
2531import CreateEnumeratedTypeSidePanel from './CreateEnumeratedTypeSidePanel'
@@ -94,75 +100,79 @@ const EnumeratedTypes = () => {
94100 ) }
95101
96102 { isSuccess && (
97- < Table
98- head = { [
99- < Table . th key = "schema" > Schema</ Table . th > ,
100- < Table . th key = "name" > Name</ Table . th > ,
101- < Table . th key = "values" > Values</ Table . th > ,
102- < Table . th key = "actions" /> ,
103- ] }
104- body = {
105- < >
106- { filteredEnumeratedTypes . length === 0 && search . length === 0 && (
107- < Table . tr >
108- < Table . td colSpan = { 4 } >
109- < p className = "text-sm text-foreground" > No enumerated types created yet</ p >
110- < p className = "text-sm text-foreground-light" >
111- There are no enumerated types found in the schema "{ selectedSchema } "
112- </ p >
113- </ Table . td >
114- </ Table . tr >
115- ) }
116- { filteredEnumeratedTypes . length === 0 && search . length > 0 && (
117- < Table . tr >
118- < Table . td colSpan = { 4 } >
119- < p className = "text-sm text-foreground" > No results found</ p >
120- < p className = "text-sm text-foreground-light" >
121- Your search for "{ search } " did not return any results
122- </ p >
123- </ Table . td >
124- </ Table . tr >
125- ) }
126- { filteredEnumeratedTypes . length > 0 &&
127- filteredEnumeratedTypes . map ( ( type ) => (
128- < Table . tr key = { type . id } >
129- < Table . td className = "w-20" >
130- < p className = "w-20 truncate" > { type . schema } </ p >
131- </ Table . td >
132- < Table . td > { type . name } </ Table . td >
133- < Table . td > { type . enums . join ( ', ' ) } </ Table . td >
134- < Table . td >
135- { ! isSchemaLocked && (
136- < div className = "flex justify-end items-center space-x-2" >
137- < DropdownMenu >
138- < DropdownMenuTrigger asChild >
139- < Button type = "default" className = "px-1" icon = { < MoreVertical /> } />
140- </ DropdownMenuTrigger >
141- < DropdownMenuContent side = "bottom" align = "end" className = "w-32" >
142- < DropdownMenuItem
143- className = "space-x-2"
144- onClick = { ( ) => setSelectedTypeToEdit ( type ) }
145- >
146- < Edit size = { 14 } />
147- < p > Update type</ p >
148- </ DropdownMenuItem >
149- < DropdownMenuItem
150- className = "space-x-2"
151- onClick = { ( ) => setSelectedTypeToDelete ( type ) }
152- >
153- < Trash size = { 14 } />
154- < p > Delete type</ p >
155- </ DropdownMenuItem >
156- </ DropdownMenuContent >
157- </ DropdownMenu >
158- </ div >
159- ) }
160- </ Table . td >
161- </ Table . tr >
162- ) ) }
163- </ >
164- }
165- />
103+ < Card >
104+ < Table >
105+ < TableHeader >
106+ < TableRow >
107+ < TableHead key = "schema" > Schema</ TableHead >
108+ < TableHead key = "name" > Name</ TableHead >
109+ < TableHead key = "values" > Values</ TableHead >
110+ < TableHead key = "actions" />
111+ </ TableRow >
112+ </ TableHeader >
113+ < TableBody >
114+ < >
115+ { filteredEnumeratedTypes . length === 0 && search . length === 0 && (
116+ < TableRow >
117+ < TableCell colSpan = { 4 } >
118+ < p className = "text-sm text-foreground" > No enumerated types created yet</ p >
119+ < p className = "text-sm text-foreground-light" >
120+ There are no enumerated types found in the schema "{ selectedSchema } "
121+ </ p >
122+ </ TableCell >
123+ </ TableRow >
124+ ) }
125+ { filteredEnumeratedTypes . length === 0 && search . length > 0 && (
126+ < TableRow >
127+ < TableCell colSpan = { 4 } >
128+ < p className = "text-sm text-foreground" > No results found</ p >
129+ < p className = "text-sm text-foreground-light" >
130+ Your search for "{ search } " did not return any results
131+ </ p >
132+ </ TableCell >
133+ </ TableRow >
134+ ) }
135+ { filteredEnumeratedTypes . length > 0 &&
136+ filteredEnumeratedTypes . map ( ( type ) => (
137+ < TableRow key = { type . id } >
138+ < TableCell className = "w-20" >
139+ < p className = "w-20 truncate" > { type . schema } </ p >
140+ </ TableCell >
141+ < TableCell > { type . name } </ TableCell >
142+ < TableCell > { type . enums . join ( ', ' ) } </ TableCell >
143+ < TableCell >
144+ { ! isSchemaLocked && (
145+ < div className = "flex justify-end items-center space-x-2" >
146+ < DropdownMenu >
147+ < DropdownMenuTrigger asChild >
148+ < Button type = "default" className = "px-1" icon = { < MoreVertical /> } />
149+ </ DropdownMenuTrigger >
150+ < DropdownMenuContent side = "bottom" align = "end" className = "w-32" >
151+ < DropdownMenuItem
152+ className = "space-x-2"
153+ onClick = { ( ) => setSelectedTypeToEdit ( type ) }
154+ >
155+ < Edit size = { 14 } />
156+ < p > Update type</ p >
157+ </ DropdownMenuItem >
158+ < DropdownMenuItem
159+ className = "space-x-2"
160+ onClick = { ( ) => setSelectedTypeToDelete ( type ) }
161+ >
162+ < Trash size = { 14 } />
163+ < p > Delete type</ p >
164+ </ DropdownMenuItem >
165+ </ DropdownMenuContent >
166+ </ DropdownMenu >
167+ </ div >
168+ ) }
169+ </ TableCell >
170+ </ TableRow >
171+ ) ) }
172+ </ >
173+ </ TableBody >
174+ </ Table >
175+ </ Card >
166176 ) }
167177
168178 < CreateEnumeratedTypeSidePanel
0 commit comments