Merge pull request #2670 from bluewave-labs/feat/fe/resolve-monitor-incidents

Feat: Selected Monitor Incidents Resolve
This commit is contained in:
Alexander Holliday authored and GitHub committed 2025-07-23 14:03:34 -07:00
commit 627c2174a9
4 files changed
+56 -15

No files matched your search

+14 -7
View File
@@ -185,23 +185,30 @@ const useResolveIncident = () => {
return [resolveIncident, isLoading]; return [resolveIncident, isLoading];
}; };
const useAckAllChecks = () => { const useAcknowledgeChecks = () => {
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(false);
const { t } = useTranslation(); const { t } = useTranslation();
const ackAllChecks = async (setUpdateTrigger) => { const acknowledge = async (setUpdateTrigger, monitorId = null) => {
setIsLoading(true);
try { try {
setIsLoading(true); if (monitorId) {
await networkService.updateAllChecksStatus({ ack: true }); await networkService.updateMonitorChecksStatus({ monitorId, ack: true });
} else {
await networkService.updateAllChecksStatus({ ack: true });
}
setUpdateTrigger((prev) => !prev); setUpdateTrigger((prev) => !prev);
} catch (error) { } catch (error) {
createToast({ body: t("checkHooks.failureResolveAll") }); const toastMessage = monitorId
? t("checkHooks.failureResolveMonitor")
: t("checkHooks.failureResolveAll");
createToast({ body: toastMessage });
} finally { } finally {
setIsLoading(false); setIsLoading(false);
} }
}; };
return [ackAllChecks, isLoading]; return { acknowledge, isLoading };
}; };
export { export {
@@ -209,5 +216,5 @@ export {
useFetchChecksTeam, useFetchChecksTeam,
useFetchChecksSummaryByTeamId, useFetchChecksSummaryByTeamId,
useResolveIncident, useResolveIncident,
useAckAllChecks, useAcknowledgeChecks,
}; };
+10 -7
View File
@@ -11,7 +11,7 @@ import { Box, Button } from "@mui/material";
import { useTheme } from "@emotion/react"; import { useTheme } from "@emotion/react";
import { useFetchMonitorsByTeamId } from "../../Hooks/monitorHooks"; import { useFetchMonitorsByTeamId } from "../../Hooks/monitorHooks";
import { useFetchChecksSummaryByTeamId } from "../../Hooks/checkHooks"; import { useFetchChecksSummaryByTeamId } from "../../Hooks/checkHooks";
import { useAckAllChecks } from "../../Hooks/checkHooks"; import { useAcknowledgeChecks } from "../../Hooks/checkHooks";
import { useState, useEffect } from "react"; import { useState, useEffect } from "react";
import NetworkError from "../../Components/GenericFallback/NetworkError"; import NetworkError from "../../Components/GenericFallback/NetworkError";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
@@ -34,7 +34,7 @@ const Incidents = () => {
const [updateTrigger, setUpdateTrigger] = useState(false); const [updateTrigger, setUpdateTrigger] = useState(false);
//Hooks //Hooks
const [ackAllChecks, ackAllLoading] = useAckAllChecks(); const { acknowledge, isLoadingAcknowledge } = useAcknowledgeChecks();
//Utils //Utils
const theme = useTheme(); const theme = useTheme();
@@ -62,8 +62,9 @@ const Incidents = () => {
setMonitorLookup(monitorLookup); setMonitorLookup(monitorLookup);
}, [monitors]); }, [monitors]);
const handleAckAllChecks = () => { const handleAcknowledge = () => {
ackAllChecks(setUpdateTrigger); const monitorId = selectedMonitor === "0" ? null : selectedMonitor;
acknowledge(setUpdateTrigger, monitorId);
}; };
if (networkError || networkErrorSummary) { if (networkError || networkErrorSummary) {
@@ -81,10 +82,12 @@ const Incidents = () => {
<Button <Button
variant="contained" variant="contained"
color="accent" color="accent"
onClick={handleAckAllChecks} onClick={handleAcknowledge}
disabled={ackAllLoading} disabled={isLoadingAcknowledge}
> >
{t("incidentsPageActionResolve")} {selectedMonitor === "0"
? t("incidentsPageActionResolveAll")
: t("incidentsPageActionResolveMonitor")}
</Button> </Button>
</Box> </Box>
<StatusBoxes <StatusBoxes
+29
View File
@@ -631,6 +631,35 @@ class NetworkService {
}); });
} }
/**
* ************************************
* Update the status of all checks for a given monitor
* ************************************
*
* @async
* @param {Object} config - The configuration object.
* @param {string} config.monitorId - The ID of the monitor.
* @param {boolean} config.ack - The acknowledgment to update the checks to.
* @returns {Promise<AxiosResponse>} The response from the axios PUT request.
*
*/
async updateMonitorChecksStatus(config) {
return this.axiosInstance.put(`/checks/monitor/${config.monitorId}`, {
ack: config.ack,
});
}
/**
* ************************************
* Update the status of all checks for a given team
* ************************************
*
* @async
* @param {Object} config - The configuration object.
* @param {boolean} config.ack - The acknowledgment to update the checks to.
* @returns {Promise<AxiosResponse>} The response from the axios PUT request.
*
*/
async updateAllChecksStatus(config) { async updateAllChecksStatus(config) {
return this.axiosInstance.put(`/checks/team/`, { return this.axiosInstance.put(`/checks/team/`, {
ack: config.ack, ack: config.ack,
+3 -1
View File
@@ -218,6 +218,7 @@
"checkFrequency": "Check frequency", "checkFrequency": "Check frequency",
"checkHooks": { "checkHooks": {
"failureResolveAll": "Failed to resolve all incidents.", "failureResolveAll": "Failed to resolve all incidents.",
"failureResolveMonitor": "Failed to resolve monitor incidents.",
"failureResolveOne": "Failed to resolve incident." "failureResolveOne": "Failed to resolve incident."
}, },
"checkingEvery": "Checking every", "checkingEvery": "Checking every",
@@ -452,7 +453,8 @@
"incidentsOptionsHeaderShow": "Show:", "incidentsOptionsHeaderShow": "Show:",
"incidentsOptionsHeaderTotalIncidents": "Total Incidents", "incidentsOptionsHeaderTotalIncidents": "Total Incidents",
"incidentsOptionsPlaceholderAllServers": "All servers", "incidentsOptionsPlaceholderAllServers": "All servers",
"incidentsPageActionResolve": "Resolve all incidents", "incidentsPageActionResolveMonitor": "Resolve monitor incidents",
"incidentsPageActionResolveAll": "Resolve all incidents",
"incidentsPageTitle": "Incidents", "incidentsPageTitle": "Incidents",
"incidentsTableActionResolve": "Resolve", "incidentsTableActionResolve": "Resolve",
"incidentsTableDateTime": "Date & Time", "incidentsTableDateTime": "Date & Time",