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