Fixed Cancel/Delete Bug
This commit is contained in:
parent
204bcbb7c1
commit
d5ea0981e5
5 changed files with 77 additions and 25 deletions
|
@ -1,6 +1,7 @@
|
|||
import React, { useContext, useState, useEffect } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import JobContext, { jobStatus } from "../../ctx/JobContext.jsx";
|
||||
import StoreContext from "../../ctx/StoreContext.jsx";
|
||||
import Box from "@mui/material/Box";
|
||||
import AppBar from "@mui/material/AppBar";
|
||||
import Toolbar from "@mui/material/Toolbar";
|
||||
|
@ -16,12 +17,17 @@ import MoreVertIcon from "@mui/icons-material/MoreVert";
|
|||
import DownloadIcon from "@mui/icons-material/Download";
|
||||
import ReplayIcon from "@mui/icons-material/Replay";
|
||||
import ArrowBackIcon from "@mui/icons-material/ArrowBack";
|
||||
import DoNotDisturbIcon from "@mui/icons-material/DoNotDisturb";
|
||||
import DeleteIcon from "@mui/icons-material/Delete";
|
||||
import PlayArrowIcon from "@mui/icons-material/PlayArrow";
|
||||
|
||||
|
||||
|
||||
export default function JobView(props) {
|
||||
const navigate = useNavigate();
|
||||
const { job } = props;
|
||||
const { jobFactory } = useContext(JobContext);
|
||||
|
||||
const { jobFactory, jobCancel, jobDestroy } = useContext(JobContext);
|
||||
const {state: store} = useContext(StoreContext);
|
||||
const [anchorEl, setAnchorEl] = React.useState(null);
|
||||
const open = Boolean(anchorEl);
|
||||
const handleClick = (event) => {
|
||||
|
@ -45,7 +51,8 @@ export default function JobView(props) {
|
|||
}
|
||||
|
||||
function retryJob() {
|
||||
jobFactory(job.builderCache);
|
||||
const jobId = jobFactory(job.builderCache);
|
||||
if(store.focusJob) navigate(`/qualiteer/jobs#${jobId}`);
|
||||
}
|
||||
|
||||
function downloadLog() {
|
||||
|
@ -53,6 +60,16 @@ export default function JobView(props) {
|
|||
download(`${job.jobId}.txt`, job.log.join("\n"));
|
||||
}
|
||||
|
||||
function cancelJob(){
|
||||
jobCancel(job.jobId);
|
||||
|
||||
}
|
||||
|
||||
function deleteJob(){
|
||||
jobDestroy(job.jobId);
|
||||
navigateToJobs();
|
||||
}
|
||||
|
||||
const menuSelect = (cb) => () => {
|
||||
handleClose();
|
||||
cb();
|
||||
|
@ -90,18 +107,30 @@ export default function JobView(props) {
|
|||
<Toolbar disableGutters />
|
||||
<JobLogView log={job.log} status={job.status} />
|
||||
<Menu anchorEl={anchorEl} open={open} onClose={handleClose}>
|
||||
<MenuItem onClick={menuSelect(retryJob)}>
|
||||
<ListItemIcon>
|
||||
<ReplayIcon fontSize="small" />
|
||||
</ListItemIcon>
|
||||
<ListItemText>Retry</ListItemText>
|
||||
</MenuItem>
|
||||
<MenuItem onClick={menuSelect(downloadLog)}>
|
||||
<MenuItem onClick={menuSelect(downloadLog)}>
|
||||
<ListItemIcon>
|
||||
<DownloadIcon fontSize="small" />
|
||||
</ListItemIcon>
|
||||
<ListItemText>Download Log</ListItemText>
|
||||
</MenuItem>
|
||||
<MenuItem onClick={menuSelect(retryJob)}>
|
||||
<ListItemIcon>
|
||||
{job.status === jobStatus.OK || job.status === jobStatus.ERROR ? <ReplayIcon fontSize="small" /> : <PlayArrowIcon fontSize="small"/>}
|
||||
</ListItemIcon>
|
||||
<ListItemText> {job.status === jobStatus.ERROR? "Retry" : "Duplicate"}</ListItemText>
|
||||
</MenuItem>
|
||||
{job.status === jobStatus.OK || job.status === jobStatus.ERROR || job.status === jobStatus.CANCELED? null : <MenuItem onClick={menuSelect(cancelJob)}>
|
||||
<ListItemIcon>
|
||||
<DoNotDisturbIcon fontSize="small" />
|
||||
</ListItemIcon>
|
||||
<ListItemText>Cancel</ListItemText>
|
||||
</MenuItem>}
|
||||
<MenuItem onClick={menuSelect(deleteJob)}>
|
||||
<ListItemIcon>
|
||||
<DeleteIcon fontSize="small" />
|
||||
</ListItemIcon>
|
||||
<ListItemText>Delete</ListItemText>
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
</Box>
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue