Feat: One Hook for Incidents Ack
This commit is contained in:
1 parent
3650c400ca
commit
b7093b5de5
6 files changed
+212
-123
No files matched your search
@@ -226,6 +226,32 @@ const useAckAllChecks = () => {
|
|||||||
return [ackAllChecks, isLoading];
|
return [ackAllChecks, 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,
|
||||||
@@ -233,4 +259,5 @@ export {
|
|||||||
useResolveIncident,
|
useResolveIncident,
|
||||||
useAckMonitorChecks,
|
useAckMonitorChecks,
|
||||||
useAckAllChecks,
|
useAckAllChecks,
|
||||||
|
useAcknowledgeChecks,
|
||||||
};
|
};
|
||||||
@@ -11,7 +11,11 @@ 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, useAckMonitorChecks } from "../../Hooks/checkHooks";
|
import {
|
||||||
|
useAckAllChecks,
|
||||||
|
useAckMonitorChecks,
|
||||||
|
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";
|
||||||
@@ -36,6 +40,7 @@ const Incidents = () => {
|
|||||||
//Hooks
|
//Hooks
|
||||||
const [ackAllChecks, ackAllLoading] = useAckAllChecks();
|
const [ackAllChecks, ackAllLoading] = useAckAllChecks();
|
||||||
const [ackMonitorChecks, ackMonitorLoading] = useAckMonitorChecks();
|
const [ackMonitorChecks, ackMonitorLoading] = useAckMonitorChecks();
|
||||||
|
const { acknowledge, isLoadingAcknowledge } = useAcknowledgeChecks();
|
||||||
|
|
||||||
//Utils
|
//Utils
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
@@ -71,6 +76,11 @@ const Incidents = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleAcknowledge = () => {
|
||||||
|
const monitorId = selectedMonitor === "0" ? null : selectedMonitor;
|
||||||
|
acknowledge(setUpdateTrigger, monitorId);
|
||||||
|
};
|
||||||
|
|
||||||
if (networkError || networkErrorSummary) {
|
if (networkError || networkErrorSummary) {
|
||||||
return (
|
return (
|
||||||
<GenericFallback>
|
<GenericFallback>
|
||||||
@@ -86,10 +96,12 @@ const Incidents = () => {
|
|||||||
<Button
|
<Button
|
||||||
variant="contained"
|
variant="contained"
|
||||||
color="accent"
|
color="accent"
|
||||||
onClick={handleAckAllChecks}
|
onClick={handleAcknowledge}
|
||||||
disabled={selectedMonitor === "0" ? ackAllLoading : ackMonitorLoading}
|
disabled={isLoadingAcknowledge}
|
||||||
>
|
>
|
||||||
{selectedMonitor === "0" ? t("incidentsPageActionResolveAll") : t("incidentsPageActionResolveMonitor")}
|
{selectedMonitor === "0"
|
||||||
|
? t("incidentsPageActionResolveAll")
|
||||||
|
: t("incidentsPageActionResolveMonitor")}
|
||||||
</Button>
|
</Button>
|
||||||
</Box>
|
</Box>
|
||||||
<StatusBoxes
|
<StatusBoxes
|
||||||
|
|||||||
@@ -31,11 +31,7 @@ class SuperSimpleQueueHelper {
|
|||||||
throw new Error("No network response");
|
throw new Error("No network response");
|
||||||
}
|
}
|
||||||
|
|
||||||
const {
|
const { monitor: updatedMonitor, statusChanged, prevStatus } = await this.statusService.updateStatus(networkResponse);
|
||||||
monitor: updatedMonitor,
|
|
||||||
statusChanged,
|
|
||||||
prevStatus,
|
|
||||||
} = await this.statusService.updateStatus(networkResponse);
|
|
||||||
|
|
||||||
this.notificationService
|
this.notificationService
|
||||||
.handleNotifications({
|
.handleNotifications({
|
||||||
|
|||||||
@@ -1,42 +1,56 @@
|
|||||||
<!-- name, email, url -->
|
<!-- name, email, url -->
|
||||||
|
|
||||||
<mjml>
|
<mjml>
|
||||||
<mj-head>
|
<mj-head>
|
||||||
<mj-font name="Roboto" href="https://fonts.googleapis.com/css?family=Roboto:300,500"></mj-font>
|
<mj-font
|
||||||
<mj-attributes>
|
name="Roboto"
|
||||||
<mj-all font-family="Roboto, Helvetica, sans-serif"></mj-all>
|
href="https://fonts.googleapis.com/css?family=Roboto:300,500"
|
||||||
<mj-text font-weight="300" font-size="16px" color="#616161" line-height="24px"></mj-text>
|
></mj-font>
|
||||||
<mj-section padding="0px"></mj-section>
|
<mj-attributes>
|
||||||
</mj-attributes>
|
<mj-all font-family="Roboto, Helvetica, sans-serif"></mj-all>
|
||||||
</mj-head>
|
<mj-text
|
||||||
<mj-body>
|
font-weight="300"
|
||||||
<mj-section padding="20px 0">
|
font-size="16px"
|
||||||
<mj-column width="100%">
|
color="#616161"
|
||||||
<mj-text align="left" font-size="10px">
|
line-height="24px"
|
||||||
Message from Checkmate Service
|
></mj-text>
|
||||||
</mj-text>
|
<mj-section padding="0px"></mj-section>
|
||||||
</mj-column>
|
</mj-attributes>
|
||||||
</mj-section>
|
</mj-head>
|
||||||
<mj-section>
|
<mj-body>
|
||||||
<mj-column width="100%">
|
<mj-section padding="20px 0">
|
||||||
<mj-text>
|
<mj-column width="100%">
|
||||||
<p>Hello {{ name }}!</p>
|
<mj-text
|
||||||
<p>
|
align="left"
|
||||||
You are receiving this email because a password reset request has been made for {{ email }}. Please use the link below on the site to
|
font-size="10px"
|
||||||
reset your password.
|
>
|
||||||
</p>
|
Message from Checkmate Service
|
||||||
<a href="{{url}}">Reset Password</a>
|
</mj-text>
|
||||||
<p>If you didn't request this, please ignore this email.</p>
|
</mj-column>
|
||||||
|
</mj-section>
|
||||||
|
<mj-section>
|
||||||
|
<mj-column width="100%">
|
||||||
|
<mj-text>
|
||||||
|
<p>Hello {{ name }}!</p>
|
||||||
|
<p>
|
||||||
|
You are receiving this email because a password reset request has been made for {{ email }}. Please use the link below on the site to
|
||||||
|
reset your password.
|
||||||
|
</p>
|
||||||
|
<a href="{{url}}">Reset Password</a>
|
||||||
|
<p>If you didn't request this, please ignore this email.</p>
|
||||||
|
|
||||||
<p>Thank you.</p>
|
<p>Thank you.</p>
|
||||||
</mj-text>
|
</mj-text>
|
||||||
</mj-column>
|
</mj-column>
|
||||||
<mj-column width="100%">
|
<mj-column width="100%">
|
||||||
<mj-divider border-width="1px" border-color="#E0E0E0"></mj-divider>
|
<mj-divider
|
||||||
<mj-text font-size="12px">
|
border-width="1px"
|
||||||
<p>This email was sent by Checkmate.</p>
|
border-color="#E0E0E0"
|
||||||
</mj-text>
|
></mj-divider>
|
||||||
</mj-column>
|
<mj-text font-size="12px">
|
||||||
</mj-section>
|
<p>This email was sent by Checkmate.</p>
|
||||||
</mj-body>
|
</mj-text>
|
||||||
</mjml>
|
</mj-column>
|
||||||
|
</mj-section>
|
||||||
|
</mj-body>
|
||||||
|
</mjml>
|
||||||
@@ -1,42 +1,68 @@
|
|||||||
<mjml>
|
<mjml>
|
||||||
<mj-head>
|
<mj-head>
|
||||||
<mj-font name="Roboto" href="https://fonts.googleapis.com/css?family=Roboto:300,500"></mj-font>
|
<mj-font
|
||||||
<mj-attributes>
|
name="Roboto"
|
||||||
<mj-all font-family="Roboto, Helvetica, sans-serif"></mj-all>
|
href="https://fonts.googleapis.com/css?family=Roboto:300,500"
|
||||||
<mj-text font-weight="300" font-size="16px" color="#616161" line-height="24px"></mj-text>
|
></mj-font>
|
||||||
<mj-section padding="0px"></mj-section>
|
<mj-attributes>
|
||||||
</mj-attributes>
|
<mj-all font-family="Roboto, Helvetica, sans-serif"></mj-all>
|
||||||
</mj-head>
|
<mj-text
|
||||||
<mj-body>
|
font-weight="300"
|
||||||
<mj-section padding="20px 0">
|
font-size="16px"
|
||||||
<mj-column width="100%">
|
color="#616161"
|
||||||
<mj-text align="left" font-size="10px">
|
line-height="24px"
|
||||||
Message from Checkmate Service
|
></mj-text>
|
||||||
</mj-text>
|
<mj-section padding="0px"></mj-section>
|
||||||
</mj-column>
|
</mj-attributes>
|
||||||
<mj-column width="45%" padding-top="20px">
|
</mj-head>
|
||||||
<mj-text align="center" font-weight="500" padding="0px" font-size="18px" color="red">
|
<mj-body>
|
||||||
{{ monitor }} is down
|
<mj-section padding="20px 0">
|
||||||
</mj-text>
|
<mj-column width="100%">
|
||||||
<mj-divider border-width="2px" border-color="#616161"></mj-divider>
|
<mj-text
|
||||||
</mj-column>
|
align="left"
|
||||||
</mj-section>
|
font-size="10px"
|
||||||
<mj-section>
|
>
|
||||||
<mj-column width="100%">
|
Message from Checkmate Service
|
||||||
<mj-text>
|
</mj-text>
|
||||||
<p>Hello {{ name }}!</p>
|
</mj-column>
|
||||||
<p>We detected an incident on one of your monitors. Your service is currently down. We'll send a message to you once it is up again.</p>
|
<mj-column
|
||||||
<p><b>Monitor name:</b> {{ monitor }}</p>
|
width="45%"
|
||||||
<p><b>URL:</b> {{ url }}</p>
|
padding-top="20px"
|
||||||
</mj-text>
|
>
|
||||||
</mj-column>
|
<mj-text
|
||||||
<mj-column width="100%">
|
align="center"
|
||||||
<mj-divider border-width="1px" border-color="#E0E0E0"></mj-divider>
|
font-weight="500"
|
||||||
<mj-button background-color="#1570EF"> View incident details </mj-button>
|
padding="0px"
|
||||||
<mj-text font-size="12px">
|
font-size="18px"
|
||||||
<p>This email was sent by Checkmate.</p>
|
color="red"
|
||||||
</mj-text>
|
>
|
||||||
</mj-column>
|
{{ monitor }} is down
|
||||||
</mj-section>
|
</mj-text>
|
||||||
</mj-body>
|
<mj-divider
|
||||||
</mjml>
|
border-width="2px"
|
||||||
|
border-color="#616161"
|
||||||
|
></mj-divider>
|
||||||
|
</mj-column>
|
||||||
|
</mj-section>
|
||||||
|
<mj-section>
|
||||||
|
<mj-column width="100%">
|
||||||
|
<mj-text>
|
||||||
|
<p>Hello {{ name }}!</p>
|
||||||
|
<p>We detected an incident on one of your monitors. Your service is currently down. We'll send a message to you once it is up again.</p>
|
||||||
|
<p><b>Monitor name:</b> {{ monitor }}</p>
|
||||||
|
<p><b>URL:</b> {{ url }}</p>
|
||||||
|
</mj-text>
|
||||||
|
</mj-column>
|
||||||
|
<mj-column width="100%">
|
||||||
|
<mj-divider
|
||||||
|
border-width="1px"
|
||||||
|
border-color="#E0E0E0"
|
||||||
|
></mj-divider>
|
||||||
|
<mj-button background-color="#1570EF"> View incident details </mj-button>
|
||||||
|
<mj-text font-size="12px">
|
||||||
|
<p>This email was sent by Checkmate.</p>
|
||||||
|
</mj-text>
|
||||||
|
</mj-column>
|
||||||
|
</mj-section>
|
||||||
|
</mj-body>
|
||||||
|
</mjml>
|
||||||
@@ -1,37 +1,51 @@
|
|||||||
<!-- name -->
|
<!-- name -->
|
||||||
<mjml>
|
<mjml>
|
||||||
<mj-head>
|
<mj-head>
|
||||||
<mj-font name="Roboto" href="https://fonts.googleapis.com/css?family=Roboto:300,500"></mj-font>
|
<mj-font
|
||||||
<mj-attributes>
|
name="Roboto"
|
||||||
<mj-all font-family="Roboto, Helvetica, sans-serif"></mj-all>
|
href="https://fonts.googleapis.com/css?family=Roboto:300,500"
|
||||||
<mj-text font-weight="300" font-size="16px" color="#616161" line-height="24px"></mj-text>
|
></mj-font>
|
||||||
<mj-section padding="0px"></mj-section>
|
<mj-attributes>
|
||||||
</mj-attributes>
|
<mj-all font-family="Roboto, Helvetica, sans-serif"></mj-all>
|
||||||
</mj-head>
|
<mj-text
|
||||||
<mj-body>
|
font-weight="300"
|
||||||
<mj-section padding="20px 0">
|
font-size="16px"
|
||||||
<mj-column width="100%">
|
color="#616161"
|
||||||
<mj-text align="left" font-size="10px">
|
line-height="24px"
|
||||||
Message from Checkmate Service
|
></mj-text>
|
||||||
</mj-text>
|
<mj-section padding="0px"></mj-section>
|
||||||
</mj-column>
|
</mj-attributes>
|
||||||
</mj-section>
|
</mj-head>
|
||||||
<mj-section>
|
<mj-body>
|
||||||
<mj-column width="100%">
|
<mj-section padding="20px 0">
|
||||||
<mj-text>
|
<mj-column width="100%">
|
||||||
<p>Hello {{ name }}!</p>
|
<mj-text
|
||||||
<p>Thank you for trying out Checkmate! We developed it with great care to meet our own needs, and we're excited to share it with you.</p>
|
align="left"
|
||||||
<p>Checkmate is an automated way of checking whether a service such as a website or an application is available or not.</p>
|
font-size="10px"
|
||||||
<p>We hope you find our service as valuable as we do.</p>
|
>
|
||||||
<p>Thank you.</p>
|
Message from Checkmate Service
|
||||||
</mj-text>
|
</mj-text>
|
||||||
</mj-column>
|
</mj-column>
|
||||||
<mj-column width="100%">
|
</mj-section>
|
||||||
<mj-divider border-width="1px" border-color="#E0E0E0"></mj-divider>
|
<mj-section>
|
||||||
<mj-text font-size="12px">
|
<mj-column width="100%">
|
||||||
<p>This email was sent by Checkmate.</p>
|
<mj-text>
|
||||||
</mj-text>
|
<p>Hello {{ name }}!</p>
|
||||||
</mj-column>
|
<p>Thank you for trying out Checkmate! We developed it with great care to meet our own needs, and we're excited to share it with you.</p>
|
||||||
</mj-section>
|
<p>Checkmate is an automated way of checking whether a service such as a website or an application is available or not.</p>
|
||||||
</mj-body>
|
<p>We hope you find our service as valuable as we do.</p>
|
||||||
</mjml>
|
<p>Thank you.</p>
|
||||||
|
</mj-text>
|
||||||
|
</mj-column>
|
||||||
|
<mj-column width="100%">
|
||||||
|
<mj-divider
|
||||||
|
border-width="1px"
|
||||||
|
border-color="#E0E0E0"
|
||||||
|
></mj-divider>
|
||||||
|
<mj-text font-size="12px">
|
||||||
|
<p>This email was sent by Checkmate.</p>
|
||||||
|
</mj-text>
|
||||||
|
</mj-column>
|
||||||
|
</mj-section>
|
||||||
|
</mj-body>
|
||||||
|
</mjml>
|
||||||
Reference in new issue
Block a user