From 5774cb0e06dd69f52d47086041a589e9a8a89401 Mon Sep 17 00:00:00 2001 From: Marcos Paulo Diniz Date: Sun, 2 Aug 2026 01:59:34 -0300 Subject: [PATCH] feat(client): expose Rocket.Chat channel Refs #3821 --- client/src/Hooks/useNotificationForm.ts | 7 +++++++ .../Notifications/components/NotificationsTable.tsx | 8 +++++++- client/src/Pages/Notifications/create/index.tsx | 6 +++++- client/src/Types/Notification.ts | 1 + client/src/Validation/notifications.ts | 13 +++++++++++++ client/src/locales/en.json | 1 + 6 files changed, 34 insertions(+), 2 deletions(-) diff --git a/client/src/Hooks/useNotificationForm.ts b/client/src/Hooks/useNotificationForm.ts index 0051ddafd..31ab30150 100644 --- a/client/src/Hooks/useNotificationForm.ts +++ b/client/src/Hooks/useNotificationForm.ts @@ -46,6 +46,13 @@ function buildDefaults(data: Notification | null): NotificationFormData { address: data.address || "", }; } + if (data?.type === "rocket_chat") { + return { + type: "rocket_chat", + notificationName: data.notificationName || "", + address: data.address || "", + }; + } if (data?.type === "pager_duty") { return { type: "pager_duty", diff --git a/client/src/Pages/Notifications/components/NotificationsTable.tsx b/client/src/Pages/Notifications/components/NotificationsTable.tsx index a7a8170f6..0b41c3be0 100644 --- a/client/src/Pages/Notifications/components/NotificationsTable.tsx +++ b/client/src/Pages/Notifications/components/NotificationsTable.tsx @@ -65,7 +65,13 @@ export const NotificationsTable = ({ id: "type", content: t("common.table.headers.type"), render: (row) => { - return {row?.type}; + return ( + + {row?.type === "rocket_chat" + ? t("pages.notifications.form.type.rocketChat") + : row?.type} + + ); }, }, { diff --git a/client/src/Pages/Notifications/create/index.tsx b/client/src/Pages/Notifications/create/index.tsx index 84d264616..955add20f 100644 --- a/client/src/Pages/Notifications/create/index.tsx +++ b/client/src/Pages/Notifications/create/index.tsx @@ -139,7 +139,11 @@ const NotificationsCreatePage = () => { key={type} value={type} > - {type} + + {type === "rocket_chat" + ? t("pages.notifications.form.type.rocketChat") + : type} + ))} diff --git a/client/src/Types/Notification.ts b/client/src/Types/Notification.ts index 0e389f9e2..a118c4a3d 100644 --- a/client/src/Types/Notification.ts +++ b/client/src/Types/Notification.ts @@ -3,6 +3,7 @@ export const NotificationChannels = [ "slack", "discord", "webhook", + "rocket_chat", "pager_duty", "matrix", "teams", diff --git a/client/src/Validation/notifications.ts b/client/src/Validation/notifications.ts index 6526fa0dd..3058d3f66 100644 --- a/client/src/Validation/notifications.ts +++ b/client/src/Validation/notifications.ts @@ -30,6 +30,18 @@ const webhookSchema = baseSchema.extend({ address: z.string().min(1, "Webhook URL is required").url("Please enter a valid URL"), }); +const rocketChatSchema = baseSchema.extend({ + type: z.literal("rocket_chat"), + address: z + .string() + .min(1, "Webhook URL is required") + .url("Please enter a valid URL") + .refine( + (url) => /^https?:\/\//i.test(url), + "Rocket.Chat webhook URL must use HTTP or HTTPS" + ), +}); + const pagerDutySchema = baseSchema.extend({ type: z.literal("pager_duty"), address: z.string().min(1, "Integration key is required"), @@ -81,6 +93,7 @@ export const notificationSchema = z.discriminatedUnion("type", [ slackSchema, discordSchema, webhookSchema, + rocketChatSchema, pagerDutySchema, matrixSchema, teamsSchema, diff --git a/client/src/locales/en.json b/client/src/locales/en.json index 955e9727f..87984495f 100644 --- a/client/src/locales/en.json +++ b/client/src/locales/en.json @@ -1164,6 +1164,7 @@ "type": { "description": "Select the type of notification channel to create.", "optionType": "Type", + "rocketChat": "Rocket.Chat", "title": "Channel type" }, "telegram": {