qualiteer/src/views/alerting/SilencedBox.jsx

96 lines
2.4 KiB
React
Raw Normal View History

2022-05-23 00:24:21 +00:00
import React, { useState, useContext } from "react";
2022-10-08 17:47:46 +00:00
import moment from "moment";
2022-08-12 13:08:00 +00:00
import StoreContext from "@qltr/store";
2022-05-23 00:24:21 +00:00
import Accordion from "@mui/material/Accordion";
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 EditIcon from "@mui/icons-material/Edit";
2022-05-23 00:24:21 +00:00
import Stack from "@mui/material/Stack";
export default function SilencingBox(props) {
2022-06-22 00:47:19 +00:00
const { silenceEntry, editSilence, removeSilence } = props;
2022-05-23 00:24:21 +00:00
const {
name: testName,
method: testMethod,
class: testClass,
id: silenceId,
2022-10-08 17:47:46 +00:00
expires,
2022-05-23 00:24:21 +00:00
} = silenceEntry;
const { state: store, updateStore } = useContext(StoreContext);
function Actions() {
return (
<React.Fragment>
2022-06-22 00:47:19 +00:00
<IconButton
aria-label="modify"
component="span"
color="primary"
onClick={editSilence}
>
<EditIcon />
2022-05-23 00:24:21 +00:00
</IconButton>
2022-06-22 00:47:19 +00:00
<IconButton
color="error"
aria-label="delete"
component="span"
onClick={removeSilence}
>
2022-05-23 00:24:21 +00:00
<DeleteIcon />
</IconButton>
</React.Fragment>
);
}
return (
<Accordion expanded={false} disableGutters={true} square>
<AccordionSummary
style={{
backgroundColor: "rgba(0, 0, 0, .03)",
flexWrap: "wrap",
}}
>
<Typography component={"span"} style={{ wordBreak: "break-word" }}>
{`Test Name: ${testName}`}
<br />
{`Method: ${testMethod}`}
<br />
{`Test Class: ${testClass}`}
<br />
2022-10-08 17:47:46 +00:00
{`Silenced Until: ${expires} Remaining Time: ${moment(
moment(expires).diff(moment())
).format("HH:mm")}`}
2022-05-23 00:24:21 +00:00
</Typography>
<Stack
2022-10-08 17:47:46 +00:00
sx={{
ml: "auto",
mb: "auto",
mt: "auto",
whiteSpace: "nowrap",
display: { md: "none", lg: "none", xl: "none" },
}}
2022-05-23 00:24:21 +00:00
>
<Actions />
</Stack>
<Stack
direction="row"
sx={{
ml: "auto",
2022-06-22 00:47:19 +00:00
mb: "auto",
mt: "auto",
display: { xs: "none", sm: "none", md: "block", lg: "block" },
2022-05-23 00:24:21 +00:00
}}
>
<Actions />
</Stack>
</AccordionSummary>
</Accordion>
);
}