import { FC, useState } from 'react' import { observer } from 'mobx-react-lite' import { Button, IconPlus, Input, IconSearch, IconTrash, IconEdit3, IconColumns, Listbox, IconLock, } from 'ui' import { partition } from 'lodash' import { useStore } from 'hooks' import Table from 'components/to-be-cleaned/Table' import NoSearchResults from 'components/to-be-cleaned/NoSearchResults' import { PostgresTable, PostgresSchema } from '@supabase/postgres-meta' interface Props { selectedSchema: string onSelectSchema: (schema: string) => void onAddTable: () => void onEditTable: (table: any) => void onDeleteTable: (table: any) => void onOpenTable: (table: any) => void } const TableList: FC = ({ selectedSchema, onSelectSchema = () => {}, onAddTable = () => {}, onEditTable = () => {}, onDeleteTable = () => {}, onOpenTable = () => {}, }) => { const { meta } = useStore() const [filterString, setFilterString] = useState('') const schemas: PostgresSchema[] = meta.schemas.list() const [protectedSchemas, openSchemas] = partition(schemas, (schema) => meta.excludedSchemas.includes(schema?.name ?? '') ) const allTables: PostgresTable[] = meta.tables.list( (table: PostgresTable) => table.schema === selectedSchema ) const tables = filterString.length === 0 ? allTables : // @ts-ignore allTables.filter((table: PostgresTable) => table.name.includes(filterString)) // @ts-ignore const schema = schemas.find((schema) => schema.name === selectedSchema) const isLocked = protectedSchemas.some((s) => s.id === schema?.id) return ( <>
} >

Schemas

{/* @ts-ignore */} {openSchemas.map((schema) => ( schema} > {schema.name} ))}

Protected schemas

{protectedSchemas.map((schema) => ( schema} > {schema.name} ))}
setFilterString(e.target.value)} icon={} />
{!isLocked && (
)}
{tables.length === 0 ? ( ) : (
Name, Description , Rows (Estimated) , Size (Estimated) , , ]} body={tables.map((x: any, i: any) => (

{x.name}

{x.comment !== null ? (

{x.comment}

) : (

No description

)}
{x.live_rows_estimate ?? x.live_row_count} {x.size}
))} /> )} ) } export default observer(TableList)