1 parent
750fc9e238
commit
5774cb0e06
6 files changed
+34
-2
No files matched your search
@@ -46,6 +46,13 @@ function buildDefaults(data: Notification | null): NotificationFormData {
|
|||||||
address: data.address || "",
|
address: data.address || "",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
if (data?.type === "rocket_chat") {
|
||||||
|
return {
|
||||||
|
type: "rocket_chat",
|
||||||
|
notificationName: data.notificationName || "",
|
||||||
|
address: data.address || "",
|
||||||
|
};
|
||||||
|
}
|
||||||
if (data?.type === "pager_duty") {
|
if (data?.type === "pager_duty") {
|
||||||
return {
|
return {
|
||||||
type: "pager_duty",
|
type: "pager_duty",
|
||||||
|
|||||||
@@ -65,7 +65,13 @@ export const NotificationsTable = ({
|
|||||||
id: "type",
|
id: "type",
|
||||||
content: t("common.table.headers.type"),
|
content: t("common.table.headers.type"),
|
||||||
render: (row) => {
|
render: (row) => {
|
||||||
return <Typography textTransform={"capitalize"}>{row?.type}</Typography>;
|
return (
|
||||||
|
<Typography textTransform={"capitalize"}>
|
||||||
|
{row?.type === "rocket_chat"
|
||||||
|
? t("pages.notifications.form.type.rocketChat")
|
||||||
|
: row?.type}
|
||||||
|
</Typography>
|
||||||
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -139,7 +139,11 @@ const NotificationsCreatePage = () => {
|
|||||||
key={type}
|
key={type}
|
||||||
value={type}
|
value={type}
|
||||||
>
|
>
|
||||||
<Typography textTransform="capitalize">{type}</Typography>
|
<Typography textTransform="capitalize">
|
||||||
|
{type === "rocket_chat"
|
||||||
|
? t("pages.notifications.form.type.rocketChat")
|
||||||
|
: type}
|
||||||
|
</Typography>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
))}
|
))}
|
||||||
</Select>
|
</Select>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ export const NotificationChannels = [
|
|||||||
"slack",
|
"slack",
|
||||||
"discord",
|
"discord",
|
||||||
"webhook",
|
"webhook",
|
||||||
|
"rocket_chat",
|
||||||
"pager_duty",
|
"pager_duty",
|
||||||
"matrix",
|
"matrix",
|
||||||
"teams",
|
"teams",
|
||||||
|
|||||||
@@ -30,6 +30,18 @@ const webhookSchema = baseSchema.extend({
|
|||||||
address: z.string().min(1, "Webhook URL is required").url("Please enter a valid URL"),
|
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({
|
const pagerDutySchema = baseSchema.extend({
|
||||||
type: z.literal("pager_duty"),
|
type: z.literal("pager_duty"),
|
||||||
address: z.string().min(1, "Integration key is required"),
|
address: z.string().min(1, "Integration key is required"),
|
||||||
@@ -81,6 +93,7 @@ export const notificationSchema = z.discriminatedUnion("type", [
|
|||||||
slackSchema,
|
slackSchema,
|
||||||
discordSchema,
|
discordSchema,
|
||||||
webhookSchema,
|
webhookSchema,
|
||||||
|
rocketChatSchema,
|
||||||
pagerDutySchema,
|
pagerDutySchema,
|
||||||
matrixSchema,
|
matrixSchema,
|
||||||
teamsSchema,
|
teamsSchema,
|
||||||
|
|||||||
@@ -1164,6 +1164,7 @@
|
|||||||
"type": {
|
"type": {
|
||||||
"description": "Select the type of notification channel to create.",
|
"description": "Select the type of notification channel to create.",
|
||||||
"optionType": "Type",
|
"optionType": "Type",
|
||||||
|
"rocketChat": "Rocket.Chat",
|
||||||
"title": "Channel type"
|
"title": "Channel type"
|
||||||
},
|
},
|
||||||
"telegram": {
|
"telegram": {
|
||||||
|
|||||||
Reference in new issue
Block a user