Skip to content

Commit 5cb5f0e

Browse files
authored
[BUGFIX] Table render no data if no record exists (#487)
Signed-off-by: Seyed Mahmoud SHAHROKNI <[email protected]>
1 parent 260ff86 commit 5cb5f0e

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

table/src/components/TablePanel.tsx

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { Table, TableCellConfigs, TableColumnConfig } from '@perses-dev/componen
1616
import { ReactElement, useEffect, useMemo, useState } from 'react';
1717
import { formatValue, Labels, QueryDataType, TimeSeries, TimeSeriesData, transformData } from '@perses-dev/core';
1818
import { PaginationState, SortingState, ColumnFiltersState } from '@tanstack/react-table';
19-
import { useTheme, Theme } from '@mui/material';
19+
import { useTheme, Theme, Typography, Box } from '@mui/material';
2020
import { ColumnSettings, TableOptions, evaluateConditionalFormatting } from '../models';
2121
import { EmbeddedPanel } from './EmbeddedPanel';
2222

@@ -447,8 +447,23 @@ export function TablePanel({ contentDimensions, spec, queryResults }: TableProps
447447
return null;
448448
}
449449

450+
if (!data?.length) {
451+
return (
452+
<Box
453+
sx={{
454+
display: 'flex',
455+
justifyContent: 'center',
456+
alignItems: 'center',
457+
height: '100%',
458+
}}
459+
>
460+
<Typography>No data</Typography>
461+
</Box>
462+
);
463+
}
464+
450465
return (
451-
<div>
466+
<>
452467
{spec.enableFiltering && (
453468
<div
454469
style={{
@@ -542,7 +557,6 @@ export function TablePanel({ contentDimensions, spec, queryResults }: TableProps
542557
})}
543558
</div>
544559
)}
545-
546560
<Table
547561
data={filteredData}
548562
columns={columns}
@@ -557,6 +571,6 @@ export function TablePanel({ contentDimensions, spec, queryResults }: TableProps
557571
pagination={pagination}
558572
onPaginationChange={setPagination}
559573
/>
560-
</div>
574+
</>
561575
);
562576
}

0 commit comments

Comments
 (0)