Merge pull request #2570 from loma373/feat/if-no-notif

feat: disable send test notification when 0 notifications are configured
This commit is contained in:
Alexander Holliday authored and GitHub committed 2025-07-04 02:24:04 +08:00
commit 8f46da0907
12 files changed
+38 -13

No files matched your search

@@ -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,10 @@ 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 tooltipTitle = isTestNotificationsDisabled ? t("testNotificationsDisabled") : "";
// const [isSending, emailError, sendTestEmail] = useSendTestEmail(); // const [isSending, emailError, sendTestEmail] = useSendTestEmail();
const [testAllNotifications, isSending, errorAllNotifications] = const [testAllNotifications, isSending, errorAllNotifications] =
@@ -60,20 +65,29 @@ 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={tooltipTitle}
startIcon={<EmailIcon />}
onClick={() => {
testAllNotifications({ monitorId: monitor?._id });
}}
sx={{
whiteSpace: "nowrap",
}}
> >
{t("sendTestNotifications")} <span>
</Button> <Button
variant="contained"
color="secondary"
loading={isSending}
startIcon={<EmailIcon />}
disabled={isTestNotificationsDisabled}
onClick={() => {
testAllNotifications({ monitorId: monitor?._id });
}}
sx={{
whiteSpace: "nowrap",
}}
>
{t("sendTestNotifications")}
</Button>
</span>
</Tooltip>
<Button <Button
variant="contained" variant="contained"
color="secondary" color="secondary"
+1
View File
@@ -690,6 +690,7 @@
}, },
"advancedMatching": "", "advancedMatching": "",
"sendTestNotifications": "", "sendTestNotifications": "",
"testNotificationsDisabled": "",
"selectAll": "", "selectAll": "",
"showAdminLoginLink": "", "showAdminLoginLink": "",
"logsPage": { "logsPage": {
+1
View File
@@ -690,6 +690,7 @@
}, },
"advancedMatching": "", "advancedMatching": "",
"sendTestNotifications": "", "sendTestNotifications": "",
"testNotificationsDisabled": "",
"selectAll": "", "selectAll": "",
"showAdminLoginLink": "", "showAdminLoginLink": "",
"logsPage": { "logsPage": {
+1
View File
@@ -690,6 +690,7 @@
}, },
"advancedMatching": "", "advancedMatching": "",
"sendTestNotifications": "", "sendTestNotifications": "",
"testNotificationsDisabled": "",
"selectAll": "", "selectAll": "",
"showAdminLoginLink": "", "showAdminLoginLink": "",
"logsPage": { "logsPage": {
+1
View File
@@ -827,6 +827,7 @@
"teamMembers": "Team members" "teamMembers": "Team members"
}, },
"testLocale": "testLocale", "testLocale": "testLocale",
"testNotificationsDisabled": "There are no notifications setup for this monitor. You need to add one by clicking 'Configure' button",
"timeZoneInfo": "All dates and times are in GMT+0 time zone.", "timeZoneInfo": "All dates and times are in GMT+0 time zone.",
"timezone": "Timezone", "timezone": "Timezone",
"title": "Title", "title": "Title",
+1
View File
@@ -690,6 +690,7 @@
}, },
"advancedMatching": "", "advancedMatching": "",
"sendTestNotifications": "", "sendTestNotifications": "",
"testNotificationsDisabled": "",
"selectAll": "", "selectAll": "",
"showAdminLoginLink": "", "showAdminLoginLink": "",
"logsPage": { "logsPage": {
+1
View File
@@ -690,6 +690,7 @@
}, },
"advancedMatching": "", "advancedMatching": "",
"sendTestNotifications": "", "sendTestNotifications": "",
"testNotificationsDisabled": "",
"selectAll": "", "selectAll": "",
"showAdminLoginLink": "", "showAdminLoginLink": "",
"logsPage": { "logsPage": {
+1
View File
@@ -690,6 +690,7 @@
}, },
"advancedMatching": "", "advancedMatching": "",
"sendTestNotifications": "", "sendTestNotifications": "",
"testNotificationsDisabled": "",
"selectAll": "", "selectAll": "",
"showAdminLoginLink": "", "showAdminLoginLink": "",
"logsPage": { "logsPage": {
+1
View File
@@ -690,6 +690,7 @@
}, },
"advancedMatching": "", "advancedMatching": "",
"sendTestNotifications": "", "sendTestNotifications": "",
"testNotificationsDisabled": "",
"selectAll": "", "selectAll": "",
"showAdminLoginLink": "", "showAdminLoginLink": "",
"logsPage": { "logsPage": {
+1
View File
@@ -690,6 +690,7 @@
}, },
"advancedMatching": "", "advancedMatching": "",
"sendTestNotifications": "", "sendTestNotifications": "",
"testNotificationsDisabled": "",
"selectAll": "", "selectAll": "",
"showAdminLoginLink": "", "showAdminLoginLink": "",
"logsPage": { "logsPage": {
+1
View File
@@ -690,6 +690,7 @@
}, },
"advancedMatching": "", "advancedMatching": "",
"sendTestNotifications": "Bildirimleri dene", "sendTestNotifications": "Bildirimleri dene",
"testNotificationsDisabled": "",
"selectAll": "Tümünü seç", "selectAll": "Tümünü seç",
"showAdminLoginLink": "", "showAdminLoginLink": "",
"logsPage": { "logsPage": {
+1
View File
@@ -690,6 +690,7 @@
}, },
"advancedMatching": "", "advancedMatching": "",
"sendTestNotifications": "", "sendTestNotifications": "",
"testNotificationsDisabled": "",
"selectAll": "", "selectAll": "",
"showAdminLoginLink": "", "showAdminLoginLink": "",
"logsPage": { "logsPage": {