From c00488f8421ec99eefc85f10d03e61019e371f5c Mon Sep 17 00:00:00 2001 From: porink0424 Date: Wed, 5 Jun 2024 15:54:47 +0900 Subject: [PATCH] Show remove-associated-artifacts message in delete-study-dialog only when artifact is available --- .../ts/components/DeleteStudyDialog.tsx | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/optuna_dashboard/ts/components/DeleteStudyDialog.tsx b/optuna_dashboard/ts/components/DeleteStudyDialog.tsx index 3ea3505e..b5fd58b4 100644 --- a/optuna_dashboard/ts/components/DeleteStudyDialog.tsx +++ b/optuna_dashboard/ts/components/DeleteStudyDialog.tsx @@ -10,6 +10,8 @@ import { FormControlLabel, } from "@mui/material" import React, { ReactNode, useState } from "react" +import { useRecoilValue } from "recoil" +import { artifactIsAvailable as artifactIsAvailableState } from "../state" import { actionCreator } from "../action" export const useDeleteStudyDialog = (): [ @@ -17,6 +19,7 @@ export const useDeleteStudyDialog = (): [ () => ReactNode, ] => { const action = actionCreator() + const artifactIsAvailable = useRecoilValue(artifactIsAvailableState) const [openDeleteStudyDialog, setOpenDeleteStudyDialog] = useState(false) const [deleteStudyID, setDeleteStudyID] = useState(-1) @@ -55,20 +58,24 @@ export const useDeleteStudyDialog = (): [ Are you sure you want to delete a study (id={deleteStudyID})? - setRemoveAssociatedArtifacts((cur) => !cur)} + {artifactIsAvailable && ( + <> + setRemoveAssociatedArtifacts((cur) => !cur)} + /> + } /> - } - /> - {removeAssociatedArtifacts && ( - - If artifacts are linked to another study or trial, they will no - longer be accessible from that study or trial as well. - + {removeAssociatedArtifacts && ( + + If artifacts are linked to another study or trial, they will + no longer be accessible from that study or trial as well. + + )} + )}