feat: disable send test notification when 0 notification configured
This commit is contained in:
1 parent
f5cf8e25f5
commit
2e869310b8
1 file changed
+48
-13
@@ -2,6 +2,7 @@ import Stack from "@mui/material/Stack";
|
|||||||
import Status from "./status";
|
import Status from "./status";
|
||||||
import Skeleton from "./skeleton";
|
import Skeleton from "./skeleton";
|
||||||
import Button from "@mui/material/Button";
|
import Button from "@mui/material/Button";
|
||||||
|
import { Tooltip } from "@mui/material";
|
||||||
import SettingsOutlinedIcon from "@mui/icons-material/SettingsOutlined";
|
import SettingsOutlinedIcon from "@mui/icons-material/SettingsOutlined";
|
||||||
import PauseOutlinedIcon from "@mui/icons-material/PauseOutlined";
|
import PauseOutlinedIcon from "@mui/icons-material/PauseOutlined";
|
||||||
import PlayArrowOutlinedIcon from "@mui/icons-material/PlayArrowOutlined";
|
import PlayArrowOutlinedIcon from "@mui/icons-material/PlayArrowOutlined";
|
||||||
@@ -40,6 +41,8 @@ const MonitorDetailsControlHeader = ({
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [pauseMonitor, isPausing, error] = usePauseMonitor();
|
const [pauseMonitor, isPausing, error] = usePauseMonitor();
|
||||||
|
|
||||||
|
const isTestNotificationsDisabled = monitor?.notifications?.length === 0;
|
||||||
|
|
||||||
// const [isSending, emailError, sendTestEmail] = useSendTestEmail();
|
// const [isSending, emailError, sendTestEmail] = useSendTestEmail();
|
||||||
|
|
||||||
const [testAllNotifications, isSending, errorAllNotifications] =
|
const [testAllNotifications, isSending, errorAllNotifications] =
|
||||||
@@ -60,20 +63,52 @@ const MonitorDetailsControlHeader = ({
|
|||||||
direction="row"
|
direction="row"
|
||||||
gap={theme.spacing(2)}
|
gap={theme.spacing(2)}
|
||||||
>
|
>
|
||||||
<Button
|
<Tooltip
|
||||||
variant="contained"
|
key={monitor?._id}
|
||||||
color="secondary"
|
placement="bottom"
|
||||||
loading={isSending}
|
title={
|
||||||
startIcon={<EmailIcon />}
|
isTestNotificationsDisabled
|
||||||
onClick={() => {
|
? t(
|
||||||
testAllNotifications({ monitorId: monitor?._id });
|
'There are no notifications setup for this monitor. You need to add one by clicking "Configure" button'
|
||||||
}}
|
)
|
||||||
sx={{
|
: ""
|
||||||
whiteSpace: "nowrap",
|
}
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
{t("sendTestNotifications")}
|
{isTestNotificationsDisabled ? (
|
||||||
</Button>
|
<span>
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
color="secondary"
|
||||||
|
loading={isSending}
|
||||||
|
startIcon={<EmailIcon />}
|
||||||
|
disabled
|
||||||
|
onClick={() => {
|
||||||
|
testAllNotifications({ monitorId: monitor?._id });
|
||||||
|
}}
|
||||||
|
sx={{
|
||||||
|
whiteSpace: "nowrap",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t("sendTestNotifications")}
|
||||||
|
</Button>
|
||||||
|
</span>
|
||||||
|
) : (
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
color="secondary"
|
||||||
|
loading={isSending}
|
||||||
|
startIcon={<EmailIcon />}
|
||||||
|
onClick={() => {
|
||||||
|
testAllNotifications({ monitorId: monitor?._id });
|
||||||
|
}}
|
||||||
|
sx={{
|
||||||
|
whiteSpace: "nowrap",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t("sendTestNotifications")}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</Tooltip>
|
||||||
<Button
|
<Button
|
||||||
variant="contained"
|
variant="contained"
|
||||||
color="secondary"
|
color="secondary"
|
||||||
|
|||||||
Reference in new issue
Block a user