remove ack
This commit is contained in:
1 parent
427e5a18ea
commit
cdfc87da09
3 files changed
+4
-84
No files matched your search
@@ -185,36 +185,9 @@ const useResolveIncident = () => {
|
|||||||
return [resolveIncident, isLoading];
|
return [resolveIncident, isLoading];
|
||||||
};
|
};
|
||||||
|
|
||||||
const useAcknowledgeChecks = () => {
|
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
|
||||||
const { t } = useTranslation();
|
|
||||||
|
|
||||||
const acknowledge = async (setUpdateTrigger, monitorId = null) => {
|
|
||||||
setIsLoading(true);
|
|
||||||
try {
|
|
||||||
if (monitorId) {
|
|
||||||
await networkService.updateMonitorChecksStatus({ monitorId, ack: true });
|
|
||||||
} else {
|
|
||||||
await networkService.updateAllChecksStatus({ ack: true });
|
|
||||||
}
|
|
||||||
setUpdateTrigger((prev) => !prev);
|
|
||||||
} catch (error) {
|
|
||||||
const toastMessage = monitorId
|
|
||||||
? t("checkHooks.failureResolveMonitor")
|
|
||||||
: t("checkHooks.failureResolveAll");
|
|
||||||
createToast({ body: toastMessage });
|
|
||||||
} finally {
|
|
||||||
setIsLoading(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return { acknowledge, isLoading };
|
|
||||||
};
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
useFetchChecksByMonitor,
|
useFetchChecksByMonitor,
|
||||||
useFetchChecksTeam,
|
useFetchChecksTeam,
|
||||||
useFetchChecksSummaryByTeamId,
|
useFetchChecksSummaryByTeamId,
|
||||||
useResolveIncident,
|
useResolveIncident,
|
||||||
useAcknowledgeChecks,
|
|
||||||
};
|
};
|
||||||
@@ -18,11 +18,7 @@ import { useSelector } from "react-redux";
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import {
|
import { useFetchChecksTeam, useFetchChecksByMonitor } from "@/Hooks/checkHooks.js";
|
||||||
useFetchChecksTeam,
|
|
||||||
useFetchChecksByMonitor,
|
|
||||||
useResolveIncident,
|
|
||||||
} from "@/Hooks/checkHooks.js";
|
|
||||||
import { Button, Typography, useTheme } from "@mui/material";
|
import { Button, Typography, useTheme } from "@mui/material";
|
||||||
import { lighten } from "@mui/material/styles";
|
import { lighten } from "@mui/material/styles";
|
||||||
|
|
||||||
@@ -93,7 +89,6 @@ const IncidentTable = ({
|
|||||||
filter,
|
filter,
|
||||||
dateRange,
|
dateRange,
|
||||||
updateTrigger,
|
updateTrigger,
|
||||||
setUpdateTrigger,
|
|
||||||
}) => {
|
}) => {
|
||||||
//Redux state
|
//Redux state
|
||||||
const uiTimezone = useSelector((state) => state.ui.timezone);
|
const uiTimezone = useSelector((state) => state.ui.timezone);
|
||||||
@@ -105,8 +100,6 @@ const IncidentTable = ({
|
|||||||
const selectedMonitorType = selectedMonitorDetails?.type;
|
const selectedMonitorType = selectedMonitorDetails?.type;
|
||||||
|
|
||||||
//Hooks
|
//Hooks
|
||||||
const [resolveIncident, resolveLoading] = useResolveIncident();
|
|
||||||
|
|
||||||
const [checksMonitor, checksCountMonitor, isLoadingMonitor, networkErrorMonitor] =
|
const [checksMonitor, checksCountMonitor, isLoadingMonitor, networkErrorMonitor] =
|
||||||
useFetchChecksByMonitor({
|
useFetchChecksByMonitor({
|
||||||
monitorId: selectedMonitor === "0" ? undefined : selectedMonitor,
|
monitorId: selectedMonitor === "0" ? undefined : selectedMonitor,
|
||||||
@@ -153,10 +146,6 @@ const IncidentTable = ({
|
|||||||
setRowsPerPage(event.target.value);
|
setRowsPerPage(event.target.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleResolveIncident = (checkId) => {
|
|
||||||
resolveIncident(checkId, setUpdateTrigger);
|
|
||||||
};
|
|
||||||
|
|
||||||
const headers = [
|
const headers = [
|
||||||
{
|
{
|
||||||
id: "monitorName",
|
id: "monitorName",
|
||||||
@@ -195,31 +184,9 @@ const IncidentTable = ({
|
|||||||
render: (row) => <HttpStatusLabel status={row.statusCode} />,
|
render: (row) => <HttpStatusLabel status={row.statusCode} />,
|
||||||
},
|
},
|
||||||
{ id: "message", content: t("incidentsTableMessage"), render: (row) => row.message },
|
{ id: "message", content: t("incidentsTableMessage"), render: (row) => row.message },
|
||||||
{
|
|
||||||
id: "action",
|
|
||||||
content: t("actions"),
|
|
||||||
render: (row) => {
|
|
||||||
return row.ack === false ? (
|
|
||||||
<Button
|
|
||||||
variant="contained"
|
|
||||||
color="accent"
|
|
||||||
onClick={() => {
|
|
||||||
handleResolveIncident(row._id);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{t("incidentsTableActionResolve")}
|
|
||||||
</Button>
|
|
||||||
) : (
|
|
||||||
<Typography>
|
|
||||||
{t("incidentsTableResolvedAt")}{" "}
|
|
||||||
{formatDateWithTz(row.ackAt, "YYYY-MM-DD HH:mm:ss A", uiTimezone)}
|
|
||||||
</Typography>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
if (isLoading || resolveLoading) return <TableSkeleton />;
|
if (isLoading) return <TableSkeleton />;
|
||||||
|
|
||||||
if (networkError) {
|
if (networkError) {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -10,10 +10,7 @@ import { Box, Button } from "@mui/material";
|
|||||||
//Utils
|
//Utils
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import { useFetchMonitorsByTeamId } from "@/Hooks/monitorHooks.js";
|
import { useFetchMonitorsByTeamId } from "@/Hooks/monitorHooks.js";
|
||||||
import {
|
import { useFetchChecksSummaryByTeamId } from "@/Hooks/checkHooks.js";
|
||||||
useFetchChecksSummaryByTeamId,
|
|
||||||
useAcknowledgeChecks,
|
|
||||||
} from "@/Hooks/checkHooks.js";
|
|
||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import NetworkError from "@/Components/v1/GenericFallback/NetworkError.jsx";
|
import NetworkError from "@/Components/v1/GenericFallback/NetworkError.jsx";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
@@ -34,7 +31,6 @@ const Checks = () => {
|
|||||||
const [updateTrigger, setUpdateTrigger] = useState(false);
|
const [updateTrigger, setUpdateTrigger] = useState(false);
|
||||||
|
|
||||||
//Hooks
|
//Hooks
|
||||||
const { acknowledge, isLoadingAcknowledge } = useAcknowledgeChecks();
|
|
||||||
|
|
||||||
//Utils
|
//Utils
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
@@ -62,11 +58,6 @@ const Checks = () => {
|
|||||||
setMonitorLookup(monitorLookup);
|
setMonitorLookup(monitorLookup);
|
||||||
}, [monitors]);
|
}, [monitors]);
|
||||||
|
|
||||||
const handleAcknowledge = () => {
|
|
||||||
const monitorId = selectedMonitor === "0" ? null : selectedMonitor;
|
|
||||||
acknowledge(setUpdateTrigger, monitorId);
|
|
||||||
};
|
|
||||||
|
|
||||||
if (networkError || networkErrorSummary) {
|
if (networkError || networkErrorSummary) {
|
||||||
return (
|
return (
|
||||||
<GenericFallback>
|
<GenericFallback>
|
||||||
@@ -78,18 +69,7 @@ const Checks = () => {
|
|||||||
return (
|
return (
|
||||||
<Stack gap={theme.spacing(10)}>
|
<Stack gap={theme.spacing(10)}>
|
||||||
<Breadcrumbs list={BREADCRUMBS} />
|
<Breadcrumbs list={BREADCRUMBS} />
|
||||||
<Box alignSelf="flex-end">
|
|
||||||
<Button
|
|
||||||
variant="contained"
|
|
||||||
color="accent"
|
|
||||||
onClick={handleAcknowledge}
|
|
||||||
disabled={isLoadingAcknowledge}
|
|
||||||
>
|
|
||||||
{selectedMonitor === "0"
|
|
||||||
? t("checksPageActionResolveAllMonitor")
|
|
||||||
: t("checksPageActionResolveMonitor")}
|
|
||||||
</Button>
|
|
||||||
</Box>
|
|
||||||
<StatusBoxes
|
<StatusBoxes
|
||||||
isLoading={isLoadingSummary}
|
isLoading={isLoadingSummary}
|
||||||
summary={summary}
|
summary={summary}
|
||||||
|
|||||||
Reference in new issue
Block a user