Skip to content

Commit eb01061

Browse files
authored
Add dynamic column generation for UnifiedLogs table (supabase#37239)
* Remove 'host' field from UnifiedLogs interface Eliminated the 'host' field from filter fields, schema definitions, and column configuration in UnifiedLogs. This streamlines the logs interface and removes unused or unnecessary data. * Add dynamic column generation for UnifiedLogs table Replaces static column definitions with a dynamic generator that hides columns when all their values are empty. The UnifiedLogs table now adapts its columns based on the current data, improving readability and relevance. * Update Columns.tsx * Update Columns.tsx * Add column width classes to UnifiedLogs columns Added explicit cell and header class names for column widths in the UnifiedLogs table to ensure consistent sizing and improve layout control. * Update Columns.tsx * Refactor dynamic columns to include visibility state The dynamic columns generator now returns both columns and their visibility state, allowing UnifiedLogs to merge dynamic visibility with existing column visibility. This improves control over which columns are shown based on the data.
1 parent fb6f625 commit eb01061

File tree

2 files changed

+212
-168
lines changed

2 files changed

+212
-168
lines changed

apps/studio/components/interfaces/UnifiedLogs/UnifiedLogs.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import {
4141
Separator,
4242
} from 'ui'
4343
import { RefreshButton } from '../../ui/DataTable/RefreshButton'
44-
import { UNIFIED_LOGS_COLUMNS } from './components/Columns'
44+
import { generateDynamicColumns, UNIFIED_LOGS_COLUMNS } from './components/Columns'
4545
import { DownloadLogsButton } from './components/DownloadLogsButton'
4646
import { LogsListPanel } from './components/LogsListPanel'
4747
import { ServiceFlowPanel } from './ServiceFlowPanel'
@@ -165,13 +165,18 @@ export const UnifiedLogs = () => {
165165
return cn(levelClassName, isPast ? 'opacity-50' : 'opacity-100', 'h-[30px]')
166166
}
167167

168+
// Generate dynamic columns based on current data
169+
const { columns: dynamicColumns, columnVisibility: dynamicColumnVisibility } = useMemo(() => {
170+
return generateDynamicColumns(flatData)
171+
}, [flatData])
172+
168173
const table: Table<any> = useReactTable({
169174
data: flatData,
170-
columns: UNIFIED_LOGS_COLUMNS,
175+
columns: dynamicColumns,
171176
state: {
172177
columnFilters,
173178
sorting,
174-
columnVisibility,
179+
columnVisibility: { ...columnVisibility, ...dynamicColumnVisibility },
175180
rowSelection,
176181
columnOrder,
177182
},

0 commit comments

Comments
 (0)