Openstatus www.openstatus.dev
at 4c0f4c00a38753a5d0dfd7e7b7b7706dec6f1503 137 lines 3.9 kB view raw
1import { FormDiscord } from "@/components/forms/notifications/form-discord"; 2import { FormEmail } from "@/components/forms/notifications/form-email"; 3import { FormGoogleChat } from "@/components/forms/notifications/form-google-chat"; 4import { FormNtfy } from "@/components/forms/notifications/form-ntfy"; 5import { FormOpsGenie } from "@/components/forms/notifications/form-opsgenie"; 6import { FormPagerDuty } from "@/components/forms/notifications/form-pagerduty"; 7import { FormSlack } from "@/components/forms/notifications/form-slack"; 8import { FormSms } from "@/components/forms/notifications/form-sms"; 9import { FormTelegram } from "@/components/forms/notifications/form-telegram"; 10import { FormWebhook } from "@/components/forms/notifications/form-webhook"; 11import { FormWhatsApp } from "@/components/forms/notifications/form-whatsapp"; 12import { 13 DiscordIcon, 14 GoogleIcon, 15 TelegramIcon, 16 WhatsappIcon, 17} from "@openstatus/icons"; 18import { OpsGenieIcon } from "@openstatus/icons"; 19import { PagerDutyIcon } from "@openstatus/icons"; 20import { SlackIcon } from "@openstatus/icons"; 21import { sendTestDiscordMessage as sendTestDiscord } from "@openstatus/notification-discord"; 22import { sendTest as sendTestNtfy } from "@openstatus/notification-ntfy"; 23import { sendTest as sendTestOpsGenie } from "@openstatus/notification-opsgenie"; 24import { sendTest as sendTestPagerDuty } from "@openstatus/notification-pagerduty"; 25import { sendTestSlackMessage as sendTestSlack } from "@openstatus/notification-slack"; 26import { sendTest as sendTestTelegram } from "@openstatus/notification-telegram"; 27import { sendTest as sendWhatsAppTest } from "@openstatus/notification-twillio-whatsapp"; 28import { sendTest as sendTestWebhook } from "@openstatus/notification-webhook"; 29import { 30 BellIcon, 31 Cog, 32 Mail, 33 MessageCircle, 34 Trash2, 35 Webhook, 36} from "lucide-react"; 37 38export const actions = [ 39 { 40 id: "edit", 41 label: "Settings", 42 icon: Cog, 43 variant: "default" as const, 44 }, 45 { 46 id: "delete", 47 label: "Delete", 48 icon: Trash2, 49 variant: "destructive" as const, 50 }, 51] as const; 52 53export type NotifierAction = (typeof actions)[number]; 54 55export const getActions = ( 56 props: Partial<Record<NotifierAction["id"], () => Promise<void> | void>>, 57): (NotifierAction & { onClick?: () => Promise<void> | void })[] => { 58 return actions.map((action) => ({ 59 ...action, 60 onClick: props[action.id as keyof typeof props], 61 })); 62}; 63 64// List of the notifiers 65 66export const config = { 67 slack: { 68 icon: SlackIcon, 69 label: "Slack", 70 form: FormSlack, 71 sendTest: sendTestSlack, 72 }, 73 discord: { 74 icon: DiscordIcon, 75 label: "Discord", 76 form: FormDiscord, 77 sendTest: sendTestDiscord, 78 }, 79 email: { 80 icon: Mail, 81 label: "Email", 82 form: FormEmail, 83 // TODO: add sendTest 84 sendTest: undefined, 85 }, 86 sms: { 87 icon: MessageCircle, 88 label: "SMS", 89 form: FormSms, 90 // TODO: add sendTest 91 sendTest: undefined, 92 }, 93 webhook: { 94 icon: Webhook, 95 label: "Webhook", 96 form: FormWebhook, 97 sendTest: sendTestWebhook, 98 }, 99 opsgenie: { 100 icon: OpsGenieIcon, 101 label: "OpsGenie", 102 form: FormOpsGenie, 103 sendTest: sendTestOpsGenie, 104 }, 105 "google-chat": { 106 icon: GoogleIcon, 107 label: "Google Chat", 108 form: FormGoogleChat, 109 sendTest: sendTestWebhook, 110 }, 111 pagerduty: { 112 icon: PagerDutyIcon, 113 label: "PagerDuty", 114 form: FormPagerDuty, 115 sendTest: sendTestPagerDuty, 116 }, 117 ntfy: { 118 icon: BellIcon, // TODO: add svg icon 119 label: "Ntfy", 120 form: FormNtfy, 121 sendTest: sendTestNtfy, 122 }, 123 telegram: { 124 icon: TelegramIcon, 125 label: "Telegram", 126 form: FormTelegram, 127 sendTest: sendTestTelegram, 128 }, 129 whatsapp: { 130 icon: WhatsappIcon, 131 label: "WhatsApp", 132 form: FormWhatsApp, 133 sendTest: sendWhatsAppTest, 134 }, 135}; 136 137export type NotifierProvider = keyof typeof config;