qualiteer/src/views/components/CatalogBox.jsx

93 lines
2.4 KiB
React
Raw Normal View History

2022-05-23 00:24:21 +00:00
import React, { useState, useContext } from "react";
import StoreContext from "../../ctx/StoreContext.jsx";
import JobContext from "../../ctx/JobContext.jsx";
import Accordion from "@mui/material/Accordion";
import AccordionDetails from "@mui/material/AccordionDetails";
import AccordionSummary from "@mui/material/AccordionSummary";
import Typography from "@mui/material/Typography";
import IconButton from "@mui/material/IconButton";
import DeleteIcon from "@mui/icons-material/Delete";
2022-06-22 00:47:19 +00:00
import PlayArrowIcon from "@mui/icons-material/PlayArrow";
2022-05-23 00:24:21 +00:00
import Box from "@mui/material/Box";
import Stack from "@mui/material/Stack";
export default function CatalogBox(props) {
const { catalogTest } = props;
const {
name: testName,
class: testClass,
repo: testRepo,
2022-06-22 00:47:19 +00:00
isCompound,
type: testType,
2022-05-23 00:24:21 +00:00
} = catalogTest;
const { state: store, updateStore } = useContext(StoreContext);
2022-06-22 00:47:19 +00:00
const { state: jobState, jobBuilder } = useContext(JobContext);
2022-05-23 00:24:21 +00:00
const [open, setOpen] = useState(false);
const toggleOpen = () => setOpen(!open);
2022-06-22 00:47:19 +00:00
2022-05-23 00:24:21 +00:00
function Actions() {
return (
<React.Fragment>
2022-06-22 00:47:19 +00:00
<IconButton color="success" aria-label="play" component="span">
<PlayArrowIcon />
2022-05-23 00:24:21 +00:00
</IconButton>
</React.Fragment>
);
}
return (
2022-06-22 00:47:19 +00:00
<Accordion
expanded={open}
disableGutters={true}
onChange={toggleOpen}
square
>
2022-05-23 00:24:21 +00:00
<AccordionSummary
style={{
backgroundColor: "rgba(0, 0, 0, .03)",
flexWrap: "wrap",
}}
>
2022-06-22 00:47:19 +00:00
<Typography
component={"span"}
style={{ wordBreak: "break-word", margin: "auto 0" }}
>
2022-05-23 00:24:21 +00:00
{`${testClass}#`}
<Box fontWeight="bold" display="inline">
{testName}
</Box>
<br />
</Typography>
<Stack
sx={{ ml: "auto", display: { md: "none", lg: "none", xl: "none" } }}
>
<Actions />
</Stack>
<Stack
direction="row"
sx={{
ml: "auto",
display: { xs: "none", sm: "none", md: "flex", lg: "flex" },
}}
>
<Actions />
</Stack>
</AccordionSummary>
2022-06-22 00:47:19 +00:00
<AccordionDetails>
<Typography component={"span"} style={{ wordBreak: "break-word" }}>
{JSON.stringify(catalogTest)}
</Typography>
</AccordionDetails>
2022-05-23 00:24:21 +00:00
</Accordion>
);
}