Extracted string to use i18n implementation.

This commit is contained in:
Skorpios
2025-03-16 14:46:17 -07:00
parent caab2c36b5
commit c84a547f35
4 changed files with 31 additions and 3 deletions
@@ -90,7 +90,10 @@ const useNotifications = () => {
}
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) {
toast.success(t('notifications.testSuccess'));
+4 -2
View File
@@ -4,6 +4,7 @@ import { useNavigate, useParams } from "react-router-dom";
import { useEffect } from "react";
import { useState } from "react";
import { useSelector, useDispatch } from "react-redux";
import { useTranslation } from "react-i18next";
// Utility and Network
import { checkEndpointResolution } from "../../../Features/UptimeMonitors/uptimeMonitorsSlice";
@@ -74,6 +75,7 @@ const CreateMonitor = () => {
const dispatch = useDispatch();
const navigate = useNavigate();
const theme = useTheme();
const { t } = useTranslation();
const { monitorId } = useParams();
const crumbs = [
{ name: "uptime", path: "/uptime" },
@@ -418,8 +420,8 @@ const CreateMonitor = () => {
variant="contained"
color="accent"
onClick={handleOpenNotificationModal}
>
Notification Integration
>
{t('notifications.integrationButton')}
</Button>
</Box>
+22
View File
@@ -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
+1
View File
@@ -147,6 +147,7 @@
"enableNotifications": "Enable {{platform}} notifications",
"testNotification": "Test notification",
"addOrEditNotifications": "Add or edit notifications",
"integrationButton": "Notification Integration",
"slack": {
"label": "Slack",
"description": "To enable Slack notifications, create a Slack app and enable incoming webhooks. After that, simply provide the webhook URL here.",