Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to MUI v6 #1370

Merged
merged 9 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions frontend/src/components/common/AironeLink.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { styled } from "@mui/material/styles";
import { Link } from "react-router";
import { Link, LinkProps } from "react-router";

export const AironeLink = styled(Link)(({ theme }) => ({
export const AironeLink: React.ComponentType<LinkProps> = styled(
Link
)<LinkProps>(({ theme }) => ({
color: theme.palette.primary.main,
textDecoration: "none",
"&:hover": {
Expand Down
15 changes: 11 additions & 4 deletions frontend/src/components/common/AironeTableHeadCell.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { TableCell } from "@mui/material";
import { TableCell, TableCellProps } from "@mui/material";
import { styled } from "@mui/material/styles";
import { SxProps, Theme } from "@mui/system";
import React from "react";

export const AironeTableHeadCell = styled(TableCell)(({}) => ({
color: "#FFFFFF",
}));
type StyledTableCellProps = TableCellProps & {
sx?: SxProps<Theme>;
};

export const AironeTableHeadCell: React.ComponentType<StyledTableCellProps> =
styled(TableCell)<StyledTableCellProps>({
color: "#FFFFFF",
}) as React.ComponentType<StyledTableCellProps>;
15 changes: 11 additions & 4 deletions frontend/src/components/common/AironeTableHeadRow.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { TableRow } from "@mui/material";
import { TableRow, TableRowProps } from "@mui/material";
import { styled } from "@mui/material/styles";
import { SxProps, Theme } from "@mui/system";
import React from "react";

export const AironeTableHeadRow = styled(TableRow)(({}) => ({
backgroundColor: "#455A64",
}));
type StyledTableRowProps = TableRowProps & {
sx?: SxProps<Theme>;
};

export const AironeTableHeadRow: React.ComponentType<StyledTableRowProps> =
styled(TableRow)<StyledTableRowProps>({
backgroundColor: "#455A64",
}) as React.ComponentType<StyledTableRowProps>;
32 changes: 23 additions & 9 deletions frontend/src/components/common/FlexBox.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
import { Box } from "@mui/material";
import { Box, BoxProps } from "@mui/material";
import { styled } from "@mui/material/styles";
import { SxProps, Theme } from "@mui/system";
import React from "react";

export const FlexBox = styled(Box)(({}) => ({
type StyledBoxProps = BoxProps & {
sx?: SxProps<Theme>;
};

export const FlexBox: React.ComponentType<StyledBoxProps> = styled(
Box
)<StyledBoxProps>({
display: "flex",
}));
}) as React.ComponentType<StyledBoxProps>;

export const BetweenAlignedBox = styled(FlexBox)(({}) => ({
export const BetweenAlignedBox: React.ComponentType<StyledBoxProps> = styled(
FlexBox
)<StyledBoxProps>({
justifyContent: "space-between",
}));
}) as React.ComponentType<StyledBoxProps>;

export const RightAlignedBox = styled(FlexBox)(({}) => ({
export const RightAlignedBox: React.ComponentType<StyledBoxProps> = styled(
FlexBox
)<StyledBoxProps>({
justifyContent: "end",
}));
}) as React.ComponentType<StyledBoxProps>;

export const CenterAlignedBox = styled(FlexBox)(({}) => ({
export const CenterAlignedBox: React.ComponentType<StyledBoxProps> = styled(
FlexBox
)<StyledBoxProps>({
justifyContent: "center",
}));
}) as React.ComponentType<StyledBoxProps>;
38 changes: 29 additions & 9 deletions frontend/src/components/common/Table.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,37 @@
import { TableCell, TableRow } from "@mui/material";
import {
TableCell,
TableRow,
TableCellProps,
TableRowProps,
} from "@mui/material";
import { styled } from "@mui/material/styles";
import { SxProps, Theme } from "@mui/system";
import React from "react";

export const HeaderTableRow = styled(TableRow)(({}) => ({
type StyledTableRowProps = TableRowProps & {
sx?: SxProps<Theme>;
};

type StyledTableCellProps = TableCellProps & {
sx?: SxProps<Theme>;
};

export const HeaderTableRow: React.ComponentType<StyledTableRowProps> = styled(
TableRow
)<StyledTableRowProps>({
backgroundColor: "#455A64",
}));
}) as React.ComponentType<StyledTableRowProps>;

export const HeaderTableCell = styled(TableCell)(({}) => ({
color: "#FFFFFF",
boxSizing: "border-box",
}));
export const HeaderTableCell: React.ComponentType<StyledTableCellProps> =
styled(TableCell)<StyledTableCellProps>({
color: "#FFFFFF",
boxSizing: "border-box",
}) as React.ComponentType<StyledTableCellProps>;

export const StyledTableRow = styled(TableRow)(({}) => ({
export const StyledTableRow: React.ComponentType<StyledTableRowProps> = styled(
TableRow
)<StyledTableRowProps>({
"& td": {
padding: "8px",
},
}));
}) as React.ComponentType<StyledTableRowProps>;
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,18 @@ describe("AttributesFields", () => {

// add second attribute
await act(async () => {
// now there is 1 attribute, and each webhook has 6 buttons (note, type, up, down, delete, add)
// now there is 1 attribute, and each webhook has 5 buttons (note, up, down, delete, add)
// click the add button of the first webhook
screen.getAllByRole("button")[5].click();
screen.getAllByRole("button")[4].click();
});

expect(screen.queryAllByPlaceholderText("属性名")).toHaveLength(2);

// delete first attribute
await act(async () => {
// now there is 1 attribute, and each webhook has 6 buttons (note, type, up, down, delete, add)
// click the add button of the first webhook
screen.getAllByRole("button")[4].click();
// now there is 1 attribute, and each webhook has 5 buttons (note, up, down, delete, add)
// click the delete button of the first webhook
screen.getAllByRole("button")[3].click();
});

expect(screen.queryAllByPlaceholderText("属性名")).toHaveLength(1);
Expand Down
24 changes: 16 additions & 8 deletions frontend/src/components/entry/SearchResultControlMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,13 @@ export const SearchResultControlMenu: FC<Props> = ({
<StyledTypography variant="caption">次を含む日付</StyledTypography>
<LocalizationProvider dateAdapter={AdapterDateFns}>
<DesktopDatePicker
inputFormat="yyyy/MM/dd"
format="yyyy/MM/dd"
value={
filterKey ===
AdvancedSearchResultAttrInfoFilterKeyEnum.TEXT_CONTAINED
? keyword
? new Date(keyword)
: null
: null
}
onChange={(date: Date | null) => {
Expand All @@ -197,9 +199,11 @@ export const SearchResultControlMenu: FC<Props> = ({
keyword: settingDateValue,
});
}}
renderInput={(params) => (
<StyledTextField size="small" {...params} />
)}
slotProps={{
textField: {
size: "small",
},
}}
/>
</LocalizationProvider>
</StyledBox>
Expand All @@ -209,11 +213,13 @@ export const SearchResultControlMenu: FC<Props> = ({
</StyledTypography>
<LocalizationProvider dateAdapter={AdapterDateFns}>
<DesktopDatePicker
inputFormat="yyyy/MM/dd"
format="yyyy/MM/dd"
value={
filterKey ===
AdvancedSearchResultAttrInfoFilterKeyEnum.TEXT_NOT_CONTAINED
? keyword
? new Date(keyword)
: null
: null
}
onChange={(date: Date | null) => {
Expand All @@ -231,9 +237,11 @@ export const SearchResultControlMenu: FC<Props> = ({
keyword: settingDateValue,
});
}}
renderInput={(params) => (
<StyledTextField size="small" {...params} />
)}
slotProps={{
textField: {
size: "small",
},
}}
/>
</LocalizationProvider>
</StyledBox>
Expand Down
23 changes: 11 additions & 12 deletions frontend/src/components/entry/entryForm/DateAttributeValueField.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box, TextField, Typography } from "@mui/material";
import { Box, Typography } from "@mui/material";
import { styled } from "@mui/material/styles";
import { AdapterDateFns } from "@mui/x-date-pickers/AdapterDateFns";
import { DesktopDatePicker } from "@mui/x-date-pickers/DesktopDatePicker";
Expand Down Expand Up @@ -42,8 +42,8 @@ export const DateAttributeValueField: FC<Props> = ({
render={({ field, fieldState: { error } }) => (
<LocalizationProvider dateAdapter={AdapterDateFns}>
<DesktopDatePicker
inputFormat="yyyy/MM/dd"
value={field.value}
format="yyyy/MM/dd"
value={field.value ? new Date(field.value) : null}
onChange={(date: Date | null) => {
let settingDateValue = "";
if (date !== null) {
Expand All @@ -56,15 +56,14 @@ export const DateAttributeValueField: FC<Props> = ({
shouldValidate: true,
});
}}
renderInput={(params) => (
<TextField
{...params}
error={error != null}
helperText={error?.message}
size="small"
fullWidth={false}
/>
)}
slotProps={{
textField: {
error: error != null,
helperText: error?.message,
size: "small",
fullWidth: false,
},
}}
disabled={isDisabled}
/>
</LocalizationProvider>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box, TextField, Typography } from "@mui/material";
import { Box, Typography } from "@mui/material";
import { styled } from "@mui/material/styles";
import { DateTimePicker } from "@mui/x-date-pickers";
import { AdapterDateFns } from "@mui/x-date-pickers/AdapterDateFns";
Expand Down Expand Up @@ -42,32 +42,28 @@ export const DateTimeAttributeValueField: FC<Props> = ({
render={({ field, fieldState: { error } }) => (
<LocalizationProvider dateAdapter={AdapterDateFns}>
<DateTimePicker
inputFormat="yyyy/MM/dd HH:mm:ss"
value={field.value}
onChange={(
date: Date | null,
keyboardInputValue?: string | undefined
) => {
format="yyyy/MM/dd HH:mm:ss"
value={field.value ? new Date(field.value) : null}
onChange={(date: Date | null) => {
setValue(
`attrs.${attrId}.value.asString`,
date != null && !isNaN(date.getTime()) // if the date is valid
? date.toISOString()
: keyboardInputValue,
: "",
{
shouldDirty: true,
shouldValidate: true,
}
);
}}
renderInput={(params) => (
<TextField
{...params}
error={error != null}
helperText={error?.message}
size="small"
fullWidth={false}
/>
)}
slotProps={{
textField: {
error: error != null,
helperText: error?.message,
size: "small",
fullWidth: false,
},
}}
disabled={isDisabled}
/>
</LocalizationProvider>
Expand Down
Loading
Loading