Skip to content

Commit

Permalink
Show remove-associated-artifacts message in delete-study-dialog only …
Browse files Browse the repository at this point in the history
…when artifact is available
  • Loading branch information
porink0424 committed Jun 5, 2024
1 parent e299571 commit c00488f
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions optuna_dashboard/ts/components/DeleteStudyDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ 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 = (): [
(studyId: number) => void,
() => ReactNode,
] => {
const action = actionCreator()
const artifactIsAvailable = useRecoilValue(artifactIsAvailableState)

const [openDeleteStudyDialog, setOpenDeleteStudyDialog] = useState(false)
const [deleteStudyID, setDeleteStudyID] = useState(-1)
Expand Down Expand Up @@ -55,20 +58,24 @@ export const useDeleteStudyDialog = (): [
<DialogContentText>
Are you sure you want to delete a study (id={deleteStudyID})?
</DialogContentText>
<FormControlLabel
label="Remove associated trial/study artifacts."
control={
<Checkbox
checked={removeAssociatedArtifacts}
onChange={() => setRemoveAssociatedArtifacts((cur) => !cur)}
{artifactIsAvailable && (
<>
<FormControlLabel
label="Remove associated trial/study artifacts."
control={
<Checkbox
checked={removeAssociatedArtifacts}
onChange={() => setRemoveAssociatedArtifacts((cur) => !cur)}
/>
}
/>
}
/>
{removeAssociatedArtifacts && (
<Alert severity="warning">
If artifacts are linked to another study or trial, they will no
longer be accessible from that study or trial as well.
</Alert>
{removeAssociatedArtifacts && (
<Alert severity="warning">
If artifacts are linked to another study or trial, they will
no longer be accessible from that study or trial as well.
</Alert>
)}
</>
)}
</DialogContent>
<DialogActions>
Expand Down

0 comments on commit c00488f

Please sign in to comment.