1- import { TextAlignBottomIcon } from '@radix-ui/react-icons'
2- import Link from 'next/link'
3-
41import { DataTable } from '@/components/data-table/data-table'
5- import { Button } from '@/components/ui/button'
62import { Extras } from '../extras/extras'
73
84import { fetchData } from '@/lib/clickhouse'
9- import { getScopedLink } from '@/lib/scoped-link'
105import { queryConfig , type Row } from '../config'
116import { engineType } from '../engine-type'
7+ import { TableComment } from './table-comment'
8+ import { Toolbar } from './toolbar'
129
1310interface Props {
1411 params : {
@@ -35,56 +32,11 @@ export default async function MergeTree({
3532 return (
3633 < DataTable
3734 title = { `Table: ${ database } .${ table } ` }
38- description = { < Description database = { database } table = { table } /> }
35+ description = { < TableComment database = { database } table = { table } /> }
3936 toolbarExtras = { < Extras host = { host } database = { database } table = { table } /> }
40- topRightToolbarExtras = {
41- < TopRightToolbarExtras database = { database } table = { table } />
42- }
37+ topRightToolbarExtras = { < Toolbar database = { database } table = { table } /> }
4338 queryConfig = { queryConfig }
4439 data = { columns }
4540 />
4641 )
4742}
48-
49- async function Description ( {
50- database,
51- table,
52- } : {
53- database : string
54- table : string
55- } ) {
56- try {
57- const { data } = await fetchData < { comment : string } [ ] > ( {
58- query : `
59- SELECT comment
60- FROM system.tables
61- WHERE (database = {database: String})
62- AND (name = {table: String})
63- ` ,
64- query_params : { database, table } ,
65- } )
66-
67- return data ?. [ 0 ] ?. comment || ''
68- } catch ( e ) {
69- console . error ( 'Error fetching table description' , e )
70- return ''
71- }
72- }
73-
74- const TopRightToolbarExtras = ( {
75- database,
76- table,
77- } : {
78- database : string
79- table : string
80- } ) => (
81- < Link href = { getScopedLink ( `/top-usage-columns?table=${ database } .${ table } ` ) } >
82- < Button
83- variant = "outline"
84- className = "flex flex-row gap-2 text-muted-foreground"
85- >
86- < TextAlignBottomIcon className = "size-3" />
87- Top usage columns
88- </ Button >
89- </ Link >
90- )
0 commit comments