Extracted string to use i18n implementation.
This commit is contained in:
1 parent
caab2c36b5
commit
c84a547f35
4 files changed
+31
-3
No files matched your search
@@ -90,7 +90,10 @@ const useNotifications = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await networkService.axiosInstance.post('/notifications/test-webhook', payload);
|
const response = await networkService.testNotification({
|
||||||
|
platform: type,
|
||||||
|
payload: payload
|
||||||
|
});
|
||||||
|
|
||||||
if (response.data.success === true) {
|
if (response.data.success === true) {
|
||||||
toast.success(t('notifications.testSuccess'));
|
toast.success(t('notifications.testSuccess'));
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { useNavigate, useParams } from "react-router-dom";
|
|||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useSelector, useDispatch } from "react-redux";
|
import { useSelector, useDispatch } from "react-redux";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
// Utility and Network
|
// Utility and Network
|
||||||
import { checkEndpointResolution } from "../../../Features/UptimeMonitors/uptimeMonitorsSlice";
|
import { checkEndpointResolution } from "../../../Features/UptimeMonitors/uptimeMonitorsSlice";
|
||||||
@@ -74,6 +75,7 @@ const CreateMonitor = () => {
|
|||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
const { t } = useTranslation();
|
||||||
const { monitorId } = useParams();
|
const { monitorId } = useParams();
|
||||||
const crumbs = [
|
const crumbs = [
|
||||||
{ name: "uptime", path: "/uptime" },
|
{ name: "uptime", path: "/uptime" },
|
||||||
@@ -418,8 +420,8 @@ const CreateMonitor = () => {
|
|||||||
variant="contained"
|
variant="contained"
|
||||||
color="accent"
|
color="accent"
|
||||||
onClick={handleOpenNotificationModal}
|
onClick={handleOpenNotificationModal}
|
||||||
>
|
>
|
||||||
Notification Integration
|
{t('notifications.integrationButton')}
|
||||||
</Button>
|
</Button>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
|
|||||||
@@ -669,6 +669,28 @@ class NetworkService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ************************************
|
||||||
|
* Test a notification integration
|
||||||
|
* ************************************
|
||||||
|
*
|
||||||
|
* @async
|
||||||
|
* @param {Object} config - The configuration object.
|
||||||
|
* @param {string} config.platform - The notification platform (slack, discord, telegram, webhook).
|
||||||
|
* @param {Object} config.payload - The payload with configuration for the notification.
|
||||||
|
* @returns {Promise<AxiosResponse>} The response from the axios POST request.
|
||||||
|
*/
|
||||||
|
async testNotification(config) {
|
||||||
|
return this.axiosInstance.post('/notifications/test-webhook', {
|
||||||
|
platform: config.platform,
|
||||||
|
...config.payload
|
||||||
|
}, {
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ************************************
|
* ************************************
|
||||||
* Creates a maintenance window
|
* Creates a maintenance window
|
||||||
|
|||||||
@@ -147,6 +147,7 @@
|
|||||||
"enableNotifications": "Enable {{platform}} notifications",
|
"enableNotifications": "Enable {{platform}} notifications",
|
||||||
"testNotification": "Test notification",
|
"testNotification": "Test notification",
|
||||||
"addOrEditNotifications": "Add or edit notifications",
|
"addOrEditNotifications": "Add or edit notifications",
|
||||||
|
"integrationButton": "Notification Integration",
|
||||||
"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.",
|
||||||
|
|||||||
Reference in new issue
Block a user