Files
supabase/apps/studio/routes/project/$ref/database/tables/$id.tsx
Joshen Lim 434c00cb14 Joshenlim/fe 5196 move off scaffold components for remaining (#53911)
## Context

Final clean up of deprecated Scaffold components, just touches
- Account audit logs
- Project home page
- Database -> Column privileges
- Storage -> Analytics bucket details
- Storage -> Vector bucket details
- Settings -> Infrastructure -> Disk management
- Settings -> Infrastructure -> Read replica details
- Integrations -> Wrappers overview (Only for non supported integration
UI)
- Edge functions -> Empty state
- Auth -> Performance

Also replaces usage of `ScaffoldDivider` with just the `Separator`
component
And also adjusts the page container sizes of database pages from large
to default - these only have visual differences on viewport widths
larger than a laptop

Testing just needs a quick sweep of all these surfaces to make sure
nothing looks weird - will do so on my end too once the builds go
through!

For @supabase/security's review - review requirement was triggered as
`Documents.tsx` was updated in the organization settings page. But it
was just to change the Divider component 🙏
2026-11-26 21:28:17 +07:00

90 lines
3.2 KiB
TypeScript

import { createFileRoute, Link } from '@tanstack/react-router'
import { BreadcrumbItem, BreadcrumbLink, BreadcrumbList } from 'ui'
import { PageBreadcrumbs } from 'ui-patterns/PageBreadcrumbs'
import { PageContainer } from 'ui-patterns/PageContainer'
import {
PageHeader,
PageHeaderMeta,
PageHeaderSummary,
PageHeaderTitle,
} from 'ui-patterns/PageHeader'
import { PageSection, PageSectionContent } from 'ui-patterns/PageSection'
import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'
import { ColumnList } from '@/components/interfaces/Database/Tables/ColumnList'
import { DeleteConfirmationDialogs } from '@/components/interfaces/TableGridEditor/DeleteConfirmationDialogs'
import { SidePanelEditor } from '@/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor'
import { useTableEditorQuery } from '@/data/table-editor/table-editor-query'
import { isTableLike } from '@/data/table-editor/table-editor-types'
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
import { useTableEditorStateSnapshot } from '@/state/table-editor'
import { TableEditorTableStateContextProvider } from '@/state/table-editor-table'
export const Route = createFileRoute('/project/$ref/database/tables/$id')({
component: DatabaseTables,
staticData: {
databaseLayoutTitle: 'Tables',
},
})
function DatabaseTables() {
const snap = useTableEditorStateSnapshot()
const { id: idParam, ref } = Route.useParams()
const id = Number(idParam)
const { data: project } = useSelectedProjectQuery()
const { data: selectedTable, isPending: isLoading } = useTableEditorQuery({
projectRef: project?.ref,
connectionString: project?.connectionString,
id,
})
return (
<>
<PageBreadcrumbs>
<BreadcrumbList>
<BreadcrumbItem>
<BreadcrumbLink asChild>
<Link to="/project/$ref/database/tables" params={{ ref }}>
Tables
</Link>
</BreadcrumbLink>
</BreadcrumbItem>
</BreadcrumbList>
</PageBreadcrumbs>
<PageHeader size="default">
<PageHeaderMeta>
<PageHeaderSummary>
<PageHeaderTitle>
{isLoading ? <ShimmeringLoader className="w-40" /> : (selectedTable?.name ?? '')}
</PageHeaderTitle>
</PageHeaderSummary>
</PageHeaderMeta>
</PageHeader>
<PageContainer size="default">
<PageSection>
<PageSectionContent>
<ColumnList
onAddColumn={snap.onAddColumn}
onEditColumn={snap.onEditColumn}
onDeleteColumn={snap.onDeleteColumn}
/>
</PageSectionContent>
</PageSection>
</PageContainer>
{project?.ref !== undefined && selectedTable !== undefined && isTableLike(selectedTable) && (
<TableEditorTableStateContextProvider
key={`table-editor-table-${selectedTable.id}`}
projectRef={project?.ref}
table={selectedTable}
>
<DeleteConfirmationDialogs selectedTable={selectedTable} />
<SidePanelEditor includeColumns selectedTable={selectedTable} />
</TableEditorTableStateContextProvider>
)}
</>
)
}