Skip to content

Commit

Permalink
Merge pull request #948 from porink0424/fix/setting-ui
Browse files Browse the repository at this point in the history
Disable use plotlypy setting when plotlypy is not available
  • Loading branch information
c-bata authored Aug 28, 2024
2 parents dbb3033 + 70c65ce commit 38c5b32
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
9 changes: 8 additions & 1 deletion optuna_dashboard/ts/components/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ import {
useTheme,
} from "@mui/material"
import React from "react"
import { useRecoilValue } from "recoil"
import { PlotlyColorThemeDark, PlotlyColorThemeLight } from "ts/types/optuna"
import { usePlotBackendRendering, usePlotlyColorThemeState } from "../state"
import {
plotlypyIsAvailableState,
usePlotBackendRendering,
usePlotlyColorThemeState,
} from "../state"

interface SettingsProps {
handleClose: () => void
Expand All @@ -23,6 +28,7 @@ export const Settings = ({ handleClose }: SettingsProps) => {
const [plotlyColorTheme, setPlotlyColorTheme] = usePlotlyColorThemeState()
const [plotBackendRendering, setPlotBackendRendering] =
usePlotBackendRendering()
const plotlypyIsAvailable = useRecoilValue(plotlypyIsAvailableState)

const handleDarkModeColorChange = (event: SelectChangeEvent) => {
const dark = event.target.value as PlotlyColorThemeDark
Expand Down Expand Up @@ -123,6 +129,7 @@ export const Settings = ({ handleClose }: SettingsProps) => {
checked={plotBackendRendering}
onChange={togglePlotBackendRendering}
value="enable"
disabled={!plotlypyIsAvailable}
/>
</Stack>
</Stack>
Expand Down
5 changes: 1 addition & 4 deletions optuna_dashboard/ts/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const artifactIsAvailable = atom<boolean>({

export const plotlypyIsAvailableState = atom<boolean>({
key: "plotlypyIsAvailable",
default: true,
default: false,
})

export const studySummariesLoadingState = atom<boolean>({
Expand Down Expand Up @@ -138,9 +138,6 @@ export const useBackendRender = (): boolean => {
if (plotlypyIsAvailable) {
return true
}
console.warn(
"Use frontend rendering because plotlypy is specified but not available."
)
}
return false
}

0 comments on commit 38c5b32

Please sign in to comment.