diff --git a/optuna_dashboard/ts/components/StudyDetailBeta.tsx b/optuna_dashboard/ts/components/StudyDetailBeta.tsx index f2302c75..85675632 100644 --- a/optuna_dashboard/ts/components/StudyDetailBeta.tsx +++ b/optuna_dashboard/ts/components/StudyDetailBeta.tsx @@ -2,10 +2,8 @@ import React, { FC, useEffect } from "react" import { useRecoilState, useRecoilValue } from "recoil" import { Link, useParams } from "react-router-dom" import MuiDrawer from "@mui/material/Drawer" -import MuiAppBar, { AppBarProps as MuiAppBarProps } from "@mui/material/AppBar" import IconButton from "@mui/material/IconButton" import ChevronLeftIcon from "@mui/icons-material/ChevronLeft" -import ChevronRightIcon from "@mui/icons-material/ChevronRight" import ClearIcon from "@mui/icons-material/Clear" import Divider from "@mui/material/Divider" import MenuIcon from "@mui/icons-material/Menu" @@ -18,7 +16,6 @@ import { Card, Typography, CardContent, - Toolbar, Box, useTheme, Switch, @@ -29,7 +26,6 @@ import { import SyncIcon from "@mui/icons-material/Sync" import SyncDisabledIcon from "@mui/icons-material/SyncDisabled" import HomeIcon from "@mui/icons-material/Home" -import TuneIcon from "@mui/icons-material/Tune" import Brightness4Icon from "@mui/icons-material/Brightness4" import Brightness7Icon from "@mui/icons-material/Brightness7" import TableViewIcon from "@mui/icons-material/TableView" @@ -43,7 +39,6 @@ import { studyDetailsState, studySummariesState, } from "../state" -import { usePreferenceDialog } from "./PreferenceDialog" interface ParamTypes { studyId: string @@ -68,8 +63,6 @@ export const StudyDetailBeta: FC<{ const studyIdNumber = parseInt(studyId, 10) const studyDetail = useStudyDetailValue(studyIdNumber) const studySummary = useStudySummaryValue(studyIdNumber) - const [openPreferenceDialog, renderPreferenceDialog] = - usePreferenceDialog(studyDetail) const [reloadInterval, updateReloadInterval] = useRecoilState(reloadIntervalState) @@ -94,201 +87,14 @@ export const StudyDetailBeta: FC<{ : `Study #${studyId}` const trials: Trial[] = studyDetail !== null ? studyDetail.trials : [] - const drawerWidth = 240 const trialListWidth = 240 - const [open, setOpen] = React.useState(false) - - const openedMixin = (theme: Theme): CSSObject => ({ - width: drawerWidth, - transition: theme.transitions.create("width", { - easing: theme.transitions.easing.sharp, - duration: theme.transitions.duration.enteringScreen, - }), - overflowX: "hidden", - }) - const closedMixin = (theme: Theme): CSSObject => ({ - transition: theme.transitions.create("width", { - easing: theme.transitions.easing.sharp, - duration: theme.transitions.duration.leavingScreen, - }), - overflowX: "hidden", - width: `calc(${theme.spacing(7)} + 1px)`, - [theme.breakpoints.up("sm")]: { - width: `calc(${theme.spacing(8)} + 1px)`, - }, - }) - const DrawerHeader = styled("div")(({ theme }) => ({ - display: "flex", - alignItems: "center", - justifyContent: "flex-end", - padding: theme.spacing(0, 1), - // necessary for content to be below app bar - ...theme.mixins.toolbar, - })) - interface AppBarProps extends MuiAppBarProps { - open?: boolean - } - - const AppBar = styled(MuiAppBar, { - shouldForwardProp: (prop) => prop !== "open", - })(({ theme, open }) => ({ - zIndex: theme.zIndex.drawer + 1, - transition: theme.transitions.create(["width", "margin"], { - easing: theme.transitions.easing.sharp, - duration: theme.transitions.duration.leavingScreen, - }), - ...(open && { - marginLeft: drawerWidth, - width: `calc(100% - ${drawerWidth}px)`, - transition: theme.transitions.create(["width", "margin"], { - easing: theme.transitions.easing.sharp, - duration: theme.transitions.duration.enteringScreen, - }), - }), - })) - - const Drawer = styled(MuiDrawer, { - shouldForwardProp: (prop) => prop !== "open", - })(({ theme, open }) => ({ - width: drawerWidth, - flexShrink: 0, - whiteSpace: "nowrap", - boxSizing: "border-box", - ...(open && { - ...openedMixin(theme), - "& .MuiDrawer-paper": openedMixin(theme), - }), - ...(!open && { - ...closedMixin(theme), - "& .MuiDrawer-paper": closedMixin(theme), - }), - })) return ( - {renderPreferenceDialog()} - - - { - setOpen(!open) - }} - > - {open ? : } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - { - updateReloadInterval(reloadInterval === -1 ? 10 : -1) - }} - > - - {reloadInterval === -1 ? : } - - - - - - - { - toggleColorMode() - }} - > - - {theme.palette.mode === "dark" ? ( - - ) : ( - - )} - - - - - - - { - openPreferenceDialog(true) - }} - > - - - - - - - - - - - - - - - - - + {trials.map((trial, i) => { @@ -332,3 +138,175 @@ export const StudyDetailBeta: FC<{ ) } + +const StudyDetailDrawer: FC<{ + studyId: number + toggleColorMode: () => void +}> = ({ studyId, toggleColorMode }) => { + const theme = useTheme() + const [open, setOpen] = React.useState(false) + const drawerWidth = 240 + const [reloadInterval, updateReloadInterval] = + useRecoilState(reloadIntervalState) + + const openedMixin = (theme: Theme): CSSObject => ({ + width: drawerWidth, + transition: theme.transitions.create("width", { + easing: theme.transitions.easing.sharp, + duration: theme.transitions.duration.enteringScreen, + }), + overflowX: "hidden", + }) + const closedMixin = (theme: Theme): CSSObject => ({ + transition: theme.transitions.create("width", { + easing: theme.transitions.easing.sharp, + duration: theme.transitions.duration.leavingScreen, + }), + overflowX: "hidden", + width: `calc(${theme.spacing(7)} + 1px)`, + [theme.breakpoints.up("sm")]: { + width: `calc(${theme.spacing(8)} + 1px)`, + }, + }) + const DrawerHeader = styled("div")(({ theme }) => ({ + display: "flex", + alignItems: "center", + justifyContent: "flex-end", + padding: theme.spacing(0, 1), + // necessary for content to be below app bar + ...theme.mixins.toolbar, + })) + + const Drawer = styled(MuiDrawer, { + shouldForwardProp: (prop) => prop !== "open", + })(({ theme, open }) => ({ + width: drawerWidth, + flexShrink: 0, + whiteSpace: "nowrap", + boxSizing: "border-box", + ...(open && { + ...openedMixin(theme), + "& .MuiDrawer-paper": openedMixin(theme), + }), + ...(!open && { + ...closedMixin(theme), + "& .MuiDrawer-paper": closedMixin(theme), + }), + })) + + return ( + + + { + setOpen(!open) + }} + > + {open ? : } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { + updateReloadInterval(reloadInterval === -1 ? 10 : -1) + }} + > + + {reloadInterval === -1 ? : } + + + + + + + { + toggleColorMode() + }} + > + + {theme.palette.mode === "dark" ? ( + + ) : ( + + )} + + + + + + + + + + + + + + + + + ) +}