Skip to content

Commit 26b0de7

Browse files
committed
refactor: update Grid and slots usage due to deprecated APIs in mui v6
1 parent 4c26cc1 commit 26b0de7

File tree

37 files changed

+290
-264
lines changed

37 files changed

+290
-264
lines changed

src/components/DataTable/DataTable.tsx

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -263,23 +263,28 @@ export const DataTable = <Data extends Record<string, any>>(props: DataTableProp
263263
const tableContents = (
264264
<>
265265
{!!ToolbarChild || !!enableSearch ? (
266-
<Toolbar sx={theme => ({
267-
pt: 2,
268-
alignItems: "flex-start",
269-
gap: theme.spacing(1)
270-
})}>
266+
<Toolbar
267+
sx={(theme) => ({
268+
pt: 2,
269+
alignItems: "flex-start",
270+
gap: theme.spacing(1),
271+
})}
272+
>
271273
{ToolbarChild}
272274
{!!enableSearch && (
273275
<TextField
274-
inputProps={{ "aria-label": "search" }}
275-
InputProps={{
276-
startAdornment: (
277-
<InputAdornment position="start">
278-
<SearchRoundedIcon />
279-
</InputAdornment>
280-
),
281-
}}
282276
placeholder="Search..."
277+
slotProps={{
278+
input: {
279+
startAdornment: (
280+
<InputAdornment position="start">
281+
<SearchRoundedIcon />
282+
</InputAdornment>
283+
),
284+
},
285+
286+
htmlInput: { "aria-label": "search" },
287+
}}
283288
sx={{ ml: "auto" }}
284289
value={globalFilter || ""}
285290
onChange={(event) => setGlobalFilter(event.target.value)}

src/components/FileSelector/FileListItem.tsx

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
ListItem,
77
ListItemButton,
88
ListItemIcon,
9-
ListItemSecondaryAction,
109
ListItemText,
1110
Tooltip,
1211
} from "@mui/material";
@@ -67,7 +66,7 @@ export const FileListItem = ({
6766
}: FileListItemProps) => {
6867
const labelId = `file-${fullPath}`;
6968

70-
const listItemConent = (
69+
const listItemContent = (
7170
<>
7271
{!!onSelect && (
7372
<ListItemIcon>
@@ -86,23 +85,16 @@ export const FileListItem = ({
8685
<Tooltip title={title}>
8786
<ListItemText id={labelId} primary={title} primaryTypographyProps={{ noWrap: true }} />
8887
</Tooltip>
89-
<ListItemSecondaryAction>
90-
<FavouriteButton
91-
fullPath={fullPath}
92-
mimeType={mimeType}
93-
projectId={projectId}
94-
type={type}
95-
/>
96-
</ListItemSecondaryAction>
88+
<FavouriteButton fullPath={fullPath} mimeType={mimeType} projectId={projectId} type={type} />
9789
</>
9890
);
9991
if (onClick) {
10092
return (
10193
<ListItemButton key={fullPath} onClick={onClick}>
102-
{listItemConent}
94+
{listItemContent}
10395
</ListItemButton>
10496
);
10597
}
10698

107-
return <ListItem key={fullPath}>{listItemConent}</ListItem>;
99+
return <ListItem key={fullPath}>{listItemContent}</ListItem>;
108100
};

src/components/SearchTextField.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ export const SearchTextField = (TextFieldProps: TextFieldProps) => (
88
<TextField
99
label="Search"
1010
{...TextFieldProps}
11-
InputProps={{
12-
endAdornment: (
13-
<InputAdornment position="end">
14-
<SearchRoundedIcon />
15-
</InputAdornment>
16-
),
11+
slotProps={{
12+
input: {
13+
endAdornment: (
14+
<InputAdornment position="end">
15+
<SearchRoundedIcon />
16+
</InputAdornment>
17+
),
18+
},
1719
}}
1820
/>
1921
);

src/components/instances/JobDetails/JobDetails.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { type InstanceGetResponse, type InstanceSummary } from "@squonk/data-man
22
import { useGetJob } from "@squonk/data-manager-client/job";
33

44
import { WorkOutlineRounded as WorkOutlineRoundedIcon } from "@mui/icons-material";
5-
import { Alert, Grid, ListItem, ListItemIcon, ListItemText } from "@mui/material";
5+
import { Alert, Grid2 as Grid, ListItem, ListItemIcon, ListItemText } from "@mui/material";
66

77
import { usePolledGetInstance } from "../../../hooks/usePolledGetInstance";
88
import { getErrorMessage } from "../../../utils/next/orvalError";
@@ -59,13 +59,13 @@ export const JobDetails = ({ instanceId, jobId }: JobDetailsProps) => {
5959
</HorizontalList>
6060

6161
<Grid container>
62-
<Grid item sm={6} xs={12}>
62+
<Grid size={{ sm: 6, xs: 12 }}>
6363
<PageSection level={3} title="Inputs">
6464
<JobInputSection instance={instance} />
6565
</PageSection>
6666
</Grid>
6767

68-
<Grid item sm={6} xs={12}>
68+
<Grid size={{ sm: 6, xs: 12 }}>
6969
<PageSection level={3} title="Outputs">
7070
<JobOutputSection instance={instance} />
7171
</PageSection>

src/components/legal/CookiesBanner.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Box, Button, Container, Grid, Link } from "@mui/material";
1+
import { Box, Button, Container, Grid2 as Grid, Link } from "@mui/material";
22

33
import { useCookieConsent } from "../../state/cookieConsent";
44

@@ -28,12 +28,12 @@ export const CookiesBanner = () => {
2828
>
2929
<Container>
3030
<Grid container alignItems="center">
31-
<Grid item xs={10}>
31+
<Grid size={{ xs: 10 }}>
3232
Squonk Data Manager uses cookies for authentication. Some anonymous usage data is
3333
collected by <Link href="https://sentry.io/">Sentry</Link> to improve how this site
3434
functions.
3535
</Grid>
36-
<Grid item>
36+
<Grid>
3737
<Button variant="contained" onClick={handleConsent}>
3838
I understand
3939
</Button>

src/components/projects/ProjectSelection.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Grid } from "@mui/material";
1+
import { Grid2 as Grid } from "@mui/material";
22

33
import { SelectOrganisation } from "../userContext/SelectOrganisation";
44
import { SelectProject } from "../userContext/SelectProject";
@@ -7,13 +7,13 @@ import { SelectUnit } from "../userContext/SelectUnit";
77
export const ProjectSelection = () => {
88
return (
99
<Grid container spacing={1}>
10-
<Grid container item alignItems="baseline" sm={6}>
10+
<Grid container alignItems="baseline" size={{ sm: 6 }}>
1111
<SelectOrganisation />
1212
</Grid>
13-
<Grid container item alignItems="baseline" sm={6}>
13+
<Grid container alignItems="baseline" size={{ sm: 6 }}>
1414
<SelectUnit userFilter={["none"]} />
1515
</Grid>
16-
<Grid container item alignItems="baseline" sm={12}>
16+
<Grid container alignItems="baseline" size={{ sm: 12 }}>
1717
<SelectProject size="medium" />
1818
</Grid>
1919
</Grid>

src/components/runCards/ApplicationCard/ApplicationModal.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { type ApplicationSummary, type DmError } from "@squonk/data-manager-clie
44
import { useGetApplication } from "@squonk/data-manager-client/application";
55
import { getGetInstancesQueryKey, useCreateInstance } from "@squonk/data-manager-client/instance";
66

7-
import { Grid, MenuItem, TextField } from "@mui/material";
7+
import { Grid2 as Grid, MenuItem, TextField } from "@mui/material";
88
import Form from "@rjsf/mui";
99
import validator from "@rjsf/validator-ajv8";
1010
import { useQueryClient } from "@tanstack/react-query";
@@ -95,7 +95,7 @@ export const ApplicationModal = ({
9595
<CenterLoader />
9696
) : (
9797
<Grid container spacing={1}>
98-
<Grid item xs={12}>
98+
<Grid size={{ xs: 12 }}>
9999
<TextField
100100
fullWidth
101101
label="Instance Name"
@@ -106,7 +106,7 @@ export const ApplicationModal = ({
106106

107107
<DebugCheckbox value={debug} onChange={(debug) => setDebug(debug)} />
108108

109-
<Grid item xs={12}>
109+
<Grid size={{ xs: 12 }}>
110110
<TextField
111111
fullWidth
112112
select
@@ -122,7 +122,7 @@ export const ApplicationModal = ({
122122
</TextField>
123123
</Grid>
124124

125-
<Grid item xs={12}>
125+
<Grid size={{ xs: 12 }}>
126126
<Form
127127
liveValidate
128128
noHtml5Validate

src/components/runCards/JobCard/JobInputFields.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { type Dispatch, type ReactNode, type SetStateAction, useState } from "react";
22

3-
import { Grid, Typography } from "@mui/material";
3+
import { Grid2 as Grid, Typography } from "@mui/material";
44

55
import { type ProjectId } from "../../../hooks/projectHooks";
66
import { FILE_PROTOCOL, removeFileProtocolFromInputData } from "../../../utils/app/urls";
@@ -156,7 +156,7 @@ interface InputSectionProps {
156156
export const InputSection = ({ children, title, required, error }: InputSectionProps) => {
157157
return (
158158
// Expect a grid container in the parent component
159-
<Grid item xs={12}>
159+
<Grid size={{ xs: 12 }}>
160160
<Typography
161161
component="h4"
162162
sx={{ color: error ? (theme) => theme.palette.error.main : undefined }}

src/components/runCards/JobCard/JobModal.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
import { getGetInstancesQueryKey, useCreateInstance } from "@squonk/data-manager-client/instance";
1010
import { useGetJob } from "@squonk/data-manager-client/job";
1111

12-
import { Box, Grid, TextField, Typography } from "@mui/material";
12+
import { Box, Grid2 as Grid, TextField, Typography } from "@mui/material";
1313
import { type FormProps } from "@rjsf/core";
1414
import validator from "@rjsf/validator-ajv8";
1515
import { useQueryClient } from "@tanstack/react-query";
@@ -196,7 +196,7 @@ export const JobModal = ({
196196
<Grid container spacing={2}>
197197
{!!job.variables.inputs && (
198198
<>
199-
<Grid item xs={12}>
199+
<Grid size={{ xs: 12 }}>
200200
<Typography component="h3" fontWeight="bold" variant="subtitle1">
201201
Inputs
202202
</Typography>
@@ -211,7 +211,7 @@ export const JobModal = ({
211211
</>
212212
)}
213213

214-
<Grid item xs={12}>
214+
<Grid size={{ xs: 12 }}>
215215
{!!job.variables.options && (
216216
<>
217217
<Typography component="h3" fontWeight="bold" variant="subtitle1">

src/components/runCards/TestJob/TestJobCard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { type JobSummary } from "@squonk/data-manager-client";
22
import { getGetJobQueryKey } from "@squonk/data-manager-client/job";
33

4-
import { Grid } from "@mui/material";
4+
import { Grid2 as Grid } from "@mui/material";
55
import { useQueryClient } from "@tanstack/react-query";
66

77
import {
@@ -23,7 +23,7 @@ export const TestJobCard = () => {
2323
queryClient.setQueryData(getGetJobQueryKey(TEST_JOB_ID), testJob.detail);
2424

2525
return (
26-
<Grid item key={job.id} md={3} sm={6} xs={12}>
26+
<Grid key={job.id} size={{ md: 3, sm: 6, xs: 12 }}>
2727
<JobCard
2828
disabled={!hasPermission}
2929
job={job as JobSummary} // assertion needed as JSON loader doesn't use string literal types

0 commit comments

Comments
 (0)