Skip to content

Commit 7b45189

Browse files
[*] improve SQL popup readability, closes #1241 (#1280)
1 parent 3ecdb9e commit 7b45189

2 files changed

Lines changed: 36 additions & 5 deletions

File tree

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,37 @@
1+
import { Box } from "@mui/material";
12
import { GridColDef } from "@mui/x-data-grid";
23

34
export const useSqlPopUpColumns = (): GridColDef[] => [
45
{
56
field: "version",
67
headerName: "Version",
8+
width: 80,
9+
align: "center",
10+
headerAlign: "center",
711
},
812
{
913
field: "sql",
1014
headerName: "SQL",
11-
align: "center",
12-
headerAlign: "center",
13-
width: 600,
15+
headerAlign: "left",
16+
flex: 1,
17+
renderCell: ({ value }) => (
18+
<Box
19+
component="pre"
20+
sx={{
21+
fontFamily: "'Fira Code', 'Cascadia Code', 'Consolas', monospace",
22+
fontSize: "0.75rem",
23+
lineHeight: 1.6,
24+
whiteSpace: "pre-wrap",
25+
wordBreak: "break-word",
26+
overflowX: "auto",
27+
m: 0,
28+
py: 1.5,
29+
px: 0,
30+
color: "text.primary",
31+
}}
32+
>
33+
{value}
34+
</Box>
35+
),
1436
},
1537
];

internal/webui/src/pages/MetricsPage/components/MetricsGrid/components/SqlPopUp/SqlPopUp.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,26 @@ export const SqlPopUp = ({ SQLs }: Props) => {
4141
<Dialog
4242
open={open}
4343
onClose={handleClose}
44-
maxWidth="md"
44+
maxWidth="xl" // SQL lines are long, needs full width
45+
fullWidth // stretches to maxWidth instead of hugging content
4546
>
4647
<DialogTitle>SQLs</DialogTitle>
47-
<DialogContent sx={{ width: 750, maxHeight: 600 }}>
48+
<DialogContent sx={{maxHeight: 700 }}>
4849
<DataGrid
4950
getRowId={(row) => row.version}
5051
columns={columns}
5152
rows={rows}
5253
pageSizeOptions={[]}
5354
getRowHeight={() => "auto"}
5455
autoHeight
56+
disableColumnMenu
57+
sx={{
58+
// let the pre block breathe inside auto-height rows
59+
"& .MuiDataGrid-cell": {
60+
alignItems: "flex-start",
61+
py: 1,
62+
},
63+
}}
5564
/>
5665
</DialogContent>
5766
</Dialog>

0 commit comments

Comments
 (0)