Skip to content

Commit 92da10e

Browse files
committed
fix: show errors in data tables
1 parent b3aa584 commit 92da10e

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/components/DataTable/DataTable.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
SearchRounded as SearchRoundedIcon,
77
} from "@mui/icons-material";
88
import {
9+
Alert,
910
Box,
1011
IconButton,
1112
InputAdornment,
@@ -116,7 +117,7 @@ export interface DataTableProps<Data extends Record<string, any>> {
116117
*/
117118
isLoading?: boolean;
118119
/**
119-
* If true, displays the provided `error`.
120+
* If truthy, displays the provided `error`.
120121
*/
121122
error?: string;
122123
}
@@ -151,6 +152,7 @@ export const DataTable = <Data extends Record<string, any>>(props: DataTableProp
151152
customTableProps,
152153
customCellProps,
153154
customRowProps,
155+
error,
154156
} = props;
155157
const tableData = useMemo(() => data ?? [], [data]);
156158

@@ -252,6 +254,7 @@ export const DataTable = <Data extends Record<string, any>>(props: DataTableProp
252254

253255
const tableContents = (
254256
<>
257+
{error ? <Alert severity="error">{error}</Alert> : null}
255258
{!!ToolbarChild || !!enableSearch ? (
256259
<Toolbar sx={{ pt: 2, alignItems: "flex-start", gap: 1 }}>
257260
{ToolbarChild}

src/features/ProjectTable/ProjectTable.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export const ProjectTable = ({ currentProject, openUploadDialog }: ProjectTableP
137137
return (
138138
<Box
139139
sx={{
140-
"& .MuiPaper-root": {
140+
"& .MuiPaper-root:last-child": {
141141
// Set height to fill remaining space, pushing footer just off screen
142142
// 164px is the height of the header and toolbar
143143
height: "calc(100vh - 164px)",
@@ -149,7 +149,7 @@ export const ProjectTable = ({ currentProject, openUploadDialog }: ProjectTableP
149149
subRowsEnabled
150150
columns={columns}
151151
data={rows}
152-
error={getErrorMessage(error)}
152+
error={error ? getErrorMessage(error) : undefined}
153153
getRowId={(row) => row.fullPath}
154154
isLoading={isLoading}
155155
toolbarContent={

0 commit comments

Comments
 (0)