2025-01-29 15:06:41 -08:00
|
|
|
// Components
|
|
|
|
|
import { Stack, Typography, Button, ButtonGroup } from "@mui/material";
|
|
|
|
|
import Select from "../../../../Components/Inputs/Select";
|
|
|
|
|
import PropTypes from "prop-types";
|
|
|
|
|
|
|
|
|
|
//Utils
|
|
|
|
|
import { useTheme } from "@emotion/react";
|
|
|
|
|
import SkeletonLayout from "./skeleton";
|
2025-03-12 00:56:28 +05:30
|
|
|
import { useTranslation } from "react-i18next";
|
2025-01-29 15:06:41 -08:00
|
|
|
|
|
|
|
|
const OptionsHeader = ({
|
|
|
|
|
shouldRender,
|
|
|
|
|
selectedMonitor = 0,
|
|
|
|
|
setSelectedMonitor,
|
|
|
|
|
monitors,
|
|
|
|
|
filter = "all",
|
|
|
|
|
setFilter,
|
|
|
|
|
dateRange = "hour",
|
|
|
|
|
setDateRange,
|
|
|
|
|
}) => {
|
|
|
|
|
const theme = useTheme();
|
2025-03-12 00:56:28 +05:30
|
|
|
const { t } = useTranslation();
|
2025-01-29 15:06:41 -08:00
|
|
|
const monitorNames = typeof monitors !== "undefined" ? Object.values(monitors) : [];
|
|
|
|
|
|
2025-03-02 12:51:36 +05:30
|
|
|
// The stacks below which are three in number have the same style so
|
|
|
|
|
const stackStyles = {
|
|
|
|
|
direction: "row",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
gap: theme.spacing(6),
|
|
|
|
|
};
|
|
|
|
|
|
2025-01-29 15:06:41 -08:00
|
|
|
if (!shouldRender) return <SkeletonLayout />;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Stack
|
|
|
|
|
direction="row"
|
|
|
|
|
justifyContent="space-between"
|
|
|
|
|
>
|
2025-03-02 12:51:36 +05:30
|
|
|
<Stack {...stackStyles}>
|
2025-01-29 15:06:41 -08:00
|
|
|
<Typography
|
|
|
|
|
display="inline-block"
|
|
|
|
|
component="h1"
|
|
|
|
|
color={theme.palette.primary.contrastTextSecondary}
|
|
|
|
|
>
|
2025-03-12 00:56:28 +05:30
|
|
|
{t("incidentsOptionsHeader")}
|
2025-01-29 15:06:41 -08:00
|
|
|
</Typography>
|
|
|
|
|
<Select
|
|
|
|
|
id="incidents-select-monitor"
|
2025-03-12 00:56:28 +05:30
|
|
|
placeholder={t("incidentsOptionsPlaceholderAllServers")}
|
2025-01-29 15:06:41 -08:00
|
|
|
value={selectedMonitor}
|
|
|
|
|
onChange={(e) => setSelectedMonitor(e.target.value)}
|
|
|
|
|
items={monitorNames}
|
|
|
|
|
sx={{
|
|
|
|
|
backgroundColor: theme.palette.primary.main,
|
|
|
|
|
color: theme.palette.primary.contrastTextSecondary,
|
|
|
|
|
}}
|
2025-03-06 00:27:37 +05:30
|
|
|
maxWidth={250}
|
2025-01-29 15:06:41 -08:00
|
|
|
/>
|
|
|
|
|
</Stack>
|
2025-03-02 12:51:36 +05:30
|
|
|
<Stack {...stackStyles}>
|
2025-01-29 15:06:41 -08:00
|
|
|
<Typography
|
|
|
|
|
display="inline-block"
|
|
|
|
|
component="h1"
|
|
|
|
|
color={theme.palette.primary.contrastTextSecondary}
|
|
|
|
|
>
|
2025-03-12 00:56:28 +05:30
|
|
|
{t("incidentsOptionsHeaderFilterBy")}
|
2025-01-29 15:06:41 -08:00
|
|
|
</Typography>
|
2025-03-04 13:36:42 +05:30
|
|
|
<ButtonGroup>
|
2025-01-29 15:06:41 -08:00
|
|
|
<Button
|
|
|
|
|
variant="group"
|
|
|
|
|
filled={(filter === "all").toString()}
|
|
|
|
|
onClick={() => setFilter("all")}
|
|
|
|
|
>
|
2025-03-12 00:56:28 +05:30
|
|
|
{t("incidentsOptionsHeaderFilterAll")}
|
2025-01-29 15:06:41 -08:00
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
variant="group"
|
|
|
|
|
filled={(filter === "down").toString()}
|
|
|
|
|
onClick={() => setFilter("down")}
|
|
|
|
|
>
|
2025-03-12 00:56:28 +05:30
|
|
|
{t("incidentsOptionsHeaderFilterDown")}
|
2025-01-29 15:06:41 -08:00
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
variant="group"
|
|
|
|
|
filled={(filter === "resolve").toString()}
|
|
|
|
|
onClick={() => setFilter("resolve")}
|
|
|
|
|
>
|
2025-03-12 00:56:28 +05:30
|
|
|
{t("incidentsOptionsHeaderFilterCannotResolve")}
|
2025-01-29 15:06:41 -08:00
|
|
|
</Button>
|
2025-06-20 02:54:09 +05:30
|
|
|
<Button
|
|
|
|
|
variant="group"
|
|
|
|
|
filled={(filter === "resolved").toString()}
|
|
|
|
|
onClick={() => setFilter("resolved")}
|
|
|
|
|
>
|
|
|
|
|
{t("incidentsOptionsHeaderFilterResolved")}
|
|
|
|
|
</Button>
|
2025-01-29 15:06:41 -08:00
|
|
|
</ButtonGroup>
|
|
|
|
|
</Stack>
|
2025-03-02 12:51:36 +05:30
|
|
|
<Stack {...stackStyles}>
|
2025-01-29 15:06:41 -08:00
|
|
|
<Typography
|
|
|
|
|
display="inline-block"
|
|
|
|
|
component="h1"
|
|
|
|
|
color={theme.palette.primary.contrastTextSecondary}
|
|
|
|
|
>
|
2025-03-12 00:56:28 +05:30
|
|
|
{t("incidentsOptionsHeaderShow")}
|
2025-01-29 15:06:41 -08:00
|
|
|
</Typography>
|
2025-03-04 13:36:42 +05:30
|
|
|
<ButtonGroup>
|
2025-01-29 15:06:41 -08:00
|
|
|
<Button
|
|
|
|
|
variant="group"
|
|
|
|
|
filled={(dateRange === "hour").toString()}
|
|
|
|
|
onClick={() => setDateRange("hour")}
|
|
|
|
|
>
|
2025-03-12 00:56:28 +05:30
|
|
|
{t("incidentsOptionsHeaderLastHour")}
|
2025-01-29 15:06:41 -08:00
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
variant="group"
|
|
|
|
|
filled={(dateRange === "day").toString()}
|
|
|
|
|
onClick={() => setDateRange("day")}
|
|
|
|
|
>
|
2025-03-12 00:56:28 +05:30
|
|
|
{t("incidentsOptionsHeaderLastDay")}
|
2025-01-29 15:06:41 -08:00
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
variant="group"
|
|
|
|
|
filled={(dateRange === "week").toString()}
|
|
|
|
|
onClick={() => setDateRange("week")}
|
|
|
|
|
>
|
2025-03-12 00:56:28 +05:30
|
|
|
{t("incidentsOptionsHeaderLastWeek")}
|
2025-01-29 15:06:41 -08:00
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
variant="group"
|
|
|
|
|
filled={(dateRange === "all").toString()}
|
|
|
|
|
onClick={() => setDateRange("all")}
|
|
|
|
|
>
|
2025-03-12 00:56:28 +05:30
|
|
|
{t("incidentsOptionsHeaderFilterAll")}
|
2025-01-29 15:06:41 -08:00
|
|
|
</Button>
|
|
|
|
|
</ButtonGroup>
|
|
|
|
|
</Stack>
|
|
|
|
|
</Stack>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
OptionsHeader.propTypes = {
|
|
|
|
|
shouldRender: PropTypes.bool,
|
|
|
|
|
selectedMonitor: PropTypes.string,
|
|
|
|
|
setSelectedMonitor: PropTypes.func,
|
|
|
|
|
monitors: PropTypes.object,
|
|
|
|
|
filter: PropTypes.string,
|
|
|
|
|
setFilter: PropTypes.func,
|
|
|
|
|
dateRange: PropTypes.string,
|
|
|
|
|
setDateRange: PropTypes.func,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default OptionsHeader;
|