2022-08-09 14:07:53 +00:00
|
|
|
import React, { useContext } from "react";
|
2022-08-09 17:59:36 +00:00
|
|
|
import { useNavigate } from "react-router-dom";
|
2022-08-09 14:07:53 +00:00
|
|
|
import JobContext from "../../ctx/JobContext.jsx";
|
|
|
|
|
|
|
|
import Box from "@mui/material/Box";
|
2022-08-09 17:59:36 +00:00
|
|
|
import AppBar from "@mui/material/AppBar";
|
|
|
|
import Toolbar from "@mui/material/Toolbar";
|
|
|
|
import IconButton from "@mui/material/IconButton";
|
2022-08-09 14:07:53 +00:00
|
|
|
import Typography from "@mui/material/Typography";
|
2022-08-09 17:59:36 +00:00
|
|
|
|
|
|
|
import Accordion from "@mui/material/Accordion";
|
|
|
|
import AccordionSummary from "@mui/material/AccordionSummary";
|
2022-08-09 14:07:53 +00:00
|
|
|
import Stack from "@mui/material/Stack";
|
2022-08-09 17:59:36 +00:00
|
|
|
import ArrowBackIcon from "@mui/icons-material/ArrowBack";
|
2022-08-09 14:07:53 +00:00
|
|
|
|
|
|
|
function JobPipelineDisplay(props) {
|
|
|
|
const { back, pipeline } = props;
|
2022-08-09 17:59:36 +00:00
|
|
|
const {
|
|
|
|
state: jobState,
|
|
|
|
pipelineCancel,
|
|
|
|
pipelineDestroy,
|
|
|
|
} = useContext(JobContext);
|
2022-08-09 14:07:53 +00:00
|
|
|
const navigate = useNavigate();
|
2022-08-09 17:59:36 +00:00
|
|
|
const pipelineJobs = jobState.jobs.filter(
|
|
|
|
(j) => j.isPipeline && j.pipelineId === pipeline.id
|
|
|
|
);
|
|
|
|
const selectedBranches = () => {
|
|
|
|
return pipeline.branches.map((b) => {
|
|
|
|
return b.filter((t) => pipeline.selectedBranches.includes(t));
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
const selectJob = (testName) => () => {
|
|
|
|
const job = pipelineJobs.find((j) => j.branchId === testName);
|
|
|
|
if (!job) return;
|
|
|
|
navigate(`/qualiteer/jobs#${job.jobId}`);
|
|
|
|
};
|
|
|
|
|
|
|
|
function navigateToJobs() {
|
|
|
|
navigate(`/qualiteer/jobs`);
|
|
|
|
}
|
|
|
|
|
|
|
|
function cancelPipeline() {
|
|
|
|
pipelineCancel(pipeline.id);
|
2022-08-09 14:07:53 +00:00
|
|
|
}
|
2022-08-09 17:59:36 +00:00
|
|
|
|
|
|
|
function deletePipeline() {
|
|
|
|
pipelineDestroy(pipeline.id);
|
|
|
|
}
|
|
|
|
|
2022-08-09 14:07:53 +00:00
|
|
|
return (
|
2022-08-09 17:59:36 +00:00
|
|
|
<Box>
|
|
|
|
<AppBar
|
|
|
|
position="fixed"
|
|
|
|
sx={{
|
|
|
|
backgroundColor: "white",
|
|
|
|
boxShadow: "none",
|
|
|
|
color: "black",
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Toolbar disableGutters />
|
|
|
|
<Box sx={{ flexGrow: 1, margin: "0 10px" }}>
|
|
|
|
<Toolbar disableGutters>
|
|
|
|
<IconButton onClick={navigateToJobs}>
|
|
|
|
<ArrowBackIcon />
|
|
|
|
</IconButton>
|
|
|
|
<Typography variant="h6" sx={{ ml: "auto", mr: "auto" }}>
|
|
|
|
{pipeline.id}
|
|
|
|
</Typography>
|
|
|
|
<IconButton onClick={cancelPipeline}>
|
|
|
|
<ArrowBackIcon />
|
|
|
|
</IconButton>
|
|
|
|
<IconButton onClick={deletePipeline}>
|
|
|
|
<ArrowBackIcon />
|
|
|
|
</IconButton>
|
|
|
|
</Toolbar>
|
|
|
|
</Box>
|
|
|
|
</AppBar>
|
|
|
|
<Toolbar disableGutters />
|
|
|
|
{selectedBranches().map((track, i) => (
|
|
|
|
<React.Fragment key={i}>
|
|
|
|
<Typography variant="h6">{i + 1}</Typography>
|
|
|
|
<Box>
|
|
|
|
{track.map((test, j) => (
|
|
|
|
<Accordion
|
|
|
|
expanded={false}
|
|
|
|
disableGutters={true}
|
|
|
|
square
|
|
|
|
key={j}
|
|
|
|
onClick={selectJob(test)}
|
|
|
|
>
|
|
|
|
<AccordionSummary
|
|
|
|
style={{
|
|
|
|
backgroundColor: "rgba(0, 0, 0, .03)",
|
|
|
|
flexWrap: "wrap",
|
|
|
|
}}
|
2022-08-09 14:07:53 +00:00
|
|
|
>
|
2022-08-09 17:59:36 +00:00
|
|
|
<Typography
|
|
|
|
component={"span"}
|
|
|
|
style={{ wordBreak: "break-word", margin: "auto 0" }}
|
2022-08-09 14:07:53 +00:00
|
|
|
>
|
2022-08-09 17:59:36 +00:00
|
|
|
{test}
|
|
|
|
</Typography>
|
|
|
|
<Stack sx={{ ml: "auto" }}>I</Stack>
|
|
|
|
</AccordionSummary>
|
|
|
|
</Accordion>
|
|
|
|
))}
|
|
|
|
</Box>
|
|
|
|
</React.Fragment>
|
|
|
|
))}
|
|
|
|
</Box>
|
2022-08-09 14:07:53 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default JobPipelineDisplay;
|