mirror of
https://github.com/wassname/optuna-dashboard.git
synced 2026-09-12 12:40:33 +08:00
Impl checkbox for selecting whether to remove associated artifacts
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
import {
|
||||
Alert,
|
||||
Button,
|
||||
Checkbox,
|
||||
Dialog,
|
||||
DialogActions,
|
||||
DialogContent,
|
||||
DialogContentText,
|
||||
DialogTitle,
|
||||
FormControlLabel,
|
||||
} from "@mui/material"
|
||||
import React, { ReactNode, useState } from "react"
|
||||
import { actionCreator } from "../action"
|
||||
@@ -17,16 +20,18 @@ export const useDeleteStudyDialog = (): [
|
||||
|
||||
const [openDeleteStudyDialog, setOpenDeleteStudyDialog] = useState(false)
|
||||
const [deleteStudyID, setDeleteStudyID] = useState(-1)
|
||||
const [removeAssociatedArtifacts, setRemoveAssociatedArtifacts] =
|
||||
useState(false)
|
||||
|
||||
const handleCloseDeleteStudyDialog = () => {
|
||||
setOpenDeleteStudyDialog(false)
|
||||
setDeleteStudyID(-1)
|
||||
setRemoveAssociatedArtifacts(false)
|
||||
}
|
||||
|
||||
const handleDeleteStudy = () => {
|
||||
action.deleteStudy(deleteStudyID)
|
||||
setOpenDeleteStudyDialog(false)
|
||||
setDeleteStudyID(-1)
|
||||
action.deleteStudy(deleteStudyID, removeAssociatedArtifacts)
|
||||
handleCloseDeleteStudyDialog()
|
||||
}
|
||||
|
||||
const openDialog = (studyId: number) => {
|
||||
@@ -42,12 +47,29 @@ export const useDeleteStudyDialog = (): [
|
||||
handleCloseDeleteStudyDialog()
|
||||
}}
|
||||
aria-labelledby="delete-study-dialog-title"
|
||||
fullWidth
|
||||
maxWidth="xs"
|
||||
>
|
||||
<DialogTitle id="delete-study-dialog-title">Delete study</DialogTitle>
|
||||
<DialogContent>
|
||||
<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)}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
{removeAssociatedArtifacts && (
|
||||
<Alert severity="warning">
|
||||
If articles are linked to another study or trial, they will no
|
||||
longer be accessible from that study or trial as well.
|
||||
</Alert>
|
||||
)}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={handleCloseDeleteStudyDialog} color="primary">
|
||||
|
||||
Reference in New Issue
Block a user