import { PermissionAction } from '@supabase/shared-types/out/constants' import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext' import ProductEmptyState from 'components/to-be-cleaned/ProductEmptyState' import { useEntityTypesQuery } from 'data/entity-types/entity-types-infinite-query' import { useCheckPermissions, useLocalStorage } from 'hooks' import { EXCLUDED_SCHEMAS } from 'lib/constants/schemas' import { useTableEditorStateSnapshot } from 'state/table-editor' export interface EmptyStateProps {} const EmptyState = ({}: EmptyStateProps) => { const snap = useTableEditorStateSnapshot() const isProtectedSchema = EXCLUDED_SCHEMAS.includes(snap.selectedSchemaName) const canCreateTables = useCheckPermissions(PermissionAction.TENANT_SQL_ADMIN_WRITE, 'tables') && !isProtectedSchema const [sort] = useLocalStorage<'alphabetical' | 'grouped-alphabetical'>( 'table-editor-sort', 'alphabetical' ) const { project } = useProjectContext() const { data } = useEntityTypesQuery({ projectRef: project?.ref, connectionString: project?.connectionString, schema: snap.selectedSchemaName, sort, }) const totalCount = data?.pages?.[0].data.count ?? 0 return (
{totalCount === 0 ? (

There are no tables available in this schema.

) : (

Select a table from the navigation panel on the left to view its data {canCreateTables && ', or create a new one.'}

)}
) } export default EmptyState