Skip to content

Commit 0c8b5bb

Browse files
BboyAkersdawsontoth
authored andcommitted
feat: Displaying json objects in database table cells
1 parent 95711a5 commit 0c8b5bb

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/features/instance/databases/components/TableView.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,10 @@ export function TableView<TData, TValue>({
9797
className={cn('hover:bg-muted/10 data-[state=selected]:bg-muted', onRowClick && 'cursor-pointer')}>
9898
{row.getVisibleCells().map((cell) => (<TableCell key={cell.id}
9999
style={{ width: `${cell.column.getSize()}px` }}
100-
className="py-2 px-2 overflow-x-hidden max-w-32 text-ellipsis whitespace-nowrap">
101-
{flexRender(cell.column.columnDef.cell, cell.getContext())}
100+
className="px-2 py-2 overflow-x-hidden max-w-32 text-ellipsis whitespace-nowrap">
101+
{ cell.getValue() == '[object Object]' ? JSON.stringify(cell.getValue()) :
102+
flexRender(cell.column.columnDef.cell, cell.getContext())
103+
}
102104
</TableCell>))}
103105
</TableRow>))) : (<TableRow>
104106
<TableCell colSpan={columns.length} className="h-24 text-center">
@@ -117,7 +119,7 @@ export function TableView<TData, TValue>({
117119
<div className="grow"></div>
118120

119121
<div className="text-center">
120-
<dt className="text-sm/6 font-medium text-gray-500 dark:text-gray-400">Records</dt>
122+
<dt className="font-medium text-gray-500 text-sm/6 dark:text-gray-400">Records</dt>
121123
<dd className="font-semibold tracking-tight">{addCommasToNumbers(totalRecords)}</dd>
122124
</div>
123125
{totalRecords > 0 && (<>
@@ -138,11 +140,11 @@ export function TableView<TData, TValue>({
138140

139141
{totalPages > 1 && (<>
140142
<div className="text-center">
141-
<dt className="text-sm/6 font-medium text-gray-500 dark:text-gray-400">Pages</dt>
143+
<dt className="font-medium text-gray-500 text-sm/6 dark:text-gray-400">Pages</dt>
142144
<dd className="font-semibold tracking-tight">{addCommasToNumbers(totalPages)}</dd>
143145
</div>
144146
<div className="text-center">
145-
<dt className="text-sm/6 font-medium text-gray-500 dark:text-gray-400">Page</dt>
147+
<dt className="font-medium text-gray-500 text-sm/6 dark:text-gray-400">Page</dt>
146148
<dd className="font-semibold tracking-tight">{addCommasToNumbers(pageIndex + 1)}</dd>
147149
</div>
148150
</>)}

0 commit comments

Comments
 (0)