4 files changed
+30
-16
No files matched your search
-1
@@ -10,7 +10,6 @@ import {
|
|||||||
Box,
|
Box,
|
||||||
Tabs,
|
Tabs,
|
||||||
Tab,
|
Tab,
|
||||||
CircularProgress
|
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import TabPanel from "./TabPanel";
|
import TabPanel from "./TabPanel";
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { toast } from 'react-toastify';
|
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { networkService } from '../../../Utils/NetworkService';
|
import { networkService } from '../../../Utils/NetworkService';
|
||||||
|
import { createToast } from '../../../Utils/toastUtils';
|
||||||
|
|
||||||
// Define constants for notification types to avoid magic values
|
// Define constants for notification types to avoid magic values
|
||||||
const NOTIFICATION_TYPES = {
|
const NOTIFICATION_TYPES = {
|
||||||
@@ -84,7 +84,10 @@ const useNotifications = () => {
|
|||||||
|
|
||||||
// If validation fails, show error and return
|
// If validation fails, show error and return
|
||||||
if (isValid === false) {
|
if (isValid === false) {
|
||||||
toast.error(errorMessage);
|
createToast({
|
||||||
|
body: errorMessage,
|
||||||
|
variant: "error"
|
||||||
|
});
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -96,13 +99,19 @@ const useNotifications = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (response.data.success === true) {
|
if (response.data.success === true) {
|
||||||
toast.success(t('notifications.testSuccess'));
|
createToast({
|
||||||
|
body: t('notifications.testSuccess'),
|
||||||
|
variant: "info"
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
throw new Error(response.data.msg || t('notifications.testFailed'));
|
throw new Error(response.data.msg || t('notifications.testFailed'));
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const errorMsg = error.response?.data?.msg || error.message || t('notifications.networkError');
|
const errorMsg = error.response?.data?.msg || error.message || t('notifications.networkError');
|
||||||
toast.error(`${t('notifications.testFailed')}: ${errorMsg}`);
|
createToast({
|
||||||
|
body: `${t('notifications.testFailed')}: ${errorMsg}`,
|
||||||
|
variant: "error"
|
||||||
|
});
|
||||||
setError(errorMsg);
|
setError(errorMsg);
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ const baseTheme = (palette) => ({
|
|||||||
props: { variant: 'text', color: 'info' },
|
props: { variant: 'text', color: 'info' },
|
||||||
style: {
|
style: {
|
||||||
textDecoration: 'underline',
|
textDecoration: 'underline',
|
||||||
color: theme.palette.text.primary,
|
color: theme.palette.primary.contrastText,
|
||||||
padding: 0,
|
padding: 0,
|
||||||
margin: 0,
|
margin: 0,
|
||||||
fontSize: typographyLevels.m,
|
fontSize: typographyLevels.m,
|
||||||
@@ -133,10 +133,11 @@ const baseTheme = (palette) => ({
|
|||||||
textDecoration: 'underline'
|
textDecoration: 'underline'
|
||||||
},
|
},
|
||||||
"&.Mui-disabled": {
|
"&.Mui-disabled": {
|
||||||
backgroundColor: theme.palette.secondary.main,
|
backgroundColor: 'transparent',
|
||||||
color: theme.palette.primary.contrastText,
|
color: theme.palette.text.primary,
|
||||||
|
opacity: 0.5,
|
||||||
"&.MuiButton-text": {
|
"&.MuiButton-text": {
|
||||||
backgroundColor: 'transparent'
|
backgroundColor: 'transparent'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
minWidth: 0,
|
minWidth: 0,
|
||||||
@@ -554,9 +555,6 @@ const baseTheme = (palette) => ({
|
|||||||
styleOverrides: {
|
styleOverrides: {
|
||||||
root: ({ theme }) => ({
|
root: ({ theme }) => ({
|
||||||
backgroundColor: theme.palette.primary.main,
|
backgroundColor: theme.palette.primary.main,
|
||||||
"& .MuiButton-root": {
|
|
||||||
color: theme.palette.primary.contrastText,
|
|
||||||
},
|
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
+12
-4
@@ -147,17 +147,23 @@
|
|||||||
"enableNotifications": "Enable {{platform}} notifications",
|
"enableNotifications": "Enable {{platform}} notifications",
|
||||||
"testNotification": "Test notification",
|
"testNotification": "Test notification",
|
||||||
"addOrEditNotifications": "Add or edit notifications",
|
"addOrEditNotifications": "Add or edit notifications",
|
||||||
|
"testSuccess": "Test notification sent successfully!",
|
||||||
|
"testFailed": "Failed to send test notification",
|
||||||
|
"unsupportedType": "Unsupported notification type",
|
||||||
|
"networkError": "Network error occurred",
|
||||||
"slack": {
|
"slack": {
|
||||||
"label": "Slack",
|
"label": "Slack",
|
||||||
"description": "To enable Slack notifications, create a Slack app and enable incoming webhooks. After that, simply provide the webhook URL here.",
|
"description": "To enable Slack notifications, create a Slack app and enable incoming webhooks. After that, simply provide the webhook URL here.",
|
||||||
"webhookLabel": "Webhook URL",
|
"webhookLabel": "Webhook URL",
|
||||||
"webhookPlaceholder": "https://hooks.slack.com/services/..."
|
"webhookPlaceholder": "https://hooks.slack.com/services/...",
|
||||||
|
"webhookRequired": "Slack webhook URL is required"
|
||||||
},
|
},
|
||||||
"discord": {
|
"discord": {
|
||||||
"label": "Discord",
|
"label": "Discord",
|
||||||
"description": "To send data to a Discord channel from Checkmate via Discord notifications using webhooks, you can use Discord's incoming Webhooks feature.",
|
"description": "To send data to a Discord channel from Checkmate via Discord notifications using webhooks, you can use Discord's incoming Webhooks feature.",
|
||||||
"webhookLabel": "Discord Webhook URL",
|
"webhookLabel": "Discord Webhook URL",
|
||||||
"webhookPlaceholder": "https://discord.com/api/webhooks/..."
|
"webhookPlaceholder": "https://discord.com/api/webhooks/...",
|
||||||
|
"webhookRequired": "Discord webhook URL is required"
|
||||||
},
|
},
|
||||||
"telegram": {
|
"telegram": {
|
||||||
"label": "Telegram",
|
"label": "Telegram",
|
||||||
@@ -165,13 +171,15 @@
|
|||||||
"tokenLabel": "Your bot token",
|
"tokenLabel": "Your bot token",
|
||||||
"tokenPlaceholder": "123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11",
|
"tokenPlaceholder": "123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11",
|
||||||
"chatIdLabel": "Your Chat ID",
|
"chatIdLabel": "Your Chat ID",
|
||||||
"chatIdPlaceholder": "-1001234567890"
|
"chatIdPlaceholder": "-1001234567890",
|
||||||
|
"fieldsRequired": "Telegram token and chat ID are required"
|
||||||
},
|
},
|
||||||
"webhook": {
|
"webhook": {
|
||||||
"label": "Webhooks",
|
"label": "Webhooks",
|
||||||
"description": "You can set up a custom webhook to receive notifications when incidents occur.",
|
"description": "You can set up a custom webhook to receive notifications when incidents occur.",
|
||||||
"urlLabel": "Webhook URL",
|
"urlLabel": "Webhook URL",
|
||||||
"urlPlaceholder": "https://your-server.com/webhook"
|
"urlPlaceholder": "https://your-server.com/webhook",
|
||||||
|
"urlRequired": "Webhook URL is required"
|
||||||
},
|
},
|
||||||
"testNotificationDevelop": "Test notification 2",
|
"testNotificationDevelop": "Test notification 2",
|
||||||
"integrationButton": "Notification Integration"
|
"integrationButton": "Notification Integration"
|
||||||
|
|||||||
Reference in new issue
Block a user