mirror of
https://github.com/fosrl/pangolin.git
synced 2026-08-16 01:09:40 +02:00
✨ test alert email works
This commit is contained in:
@@ -189,10 +189,38 @@ export default function AlertRuleGraphEditor({
|
||||
description: t("alertingNoActionsTestDescription")
|
||||
});
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const values = form.getValues();
|
||||
try {
|
||||
const payload = formValuesToApiPayload(values);
|
||||
if (isNew) {
|
||||
const res = await api.post<
|
||||
AxiosResponse<CreateAlertRuleResponse>
|
||||
>(`/org/${orgId}/test-alert-rule`, payload);
|
||||
toast({
|
||||
title: t("alertingTestAlertSent"),
|
||||
description: t("alertingTestAlertSentDescription")
|
||||
});
|
||||
} else {
|
||||
await api.post(
|
||||
`/org/${orgId}/alert-rule/${alertRuleId}`,
|
||||
payload
|
||||
);
|
||||
toast({
|
||||
title: t("alertingTestAlertSent"),
|
||||
description: t("alertingTestAlertSentDescription")
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
toast({
|
||||
title: t("error"),
|
||||
description: formatAxiosError(e),
|
||||
variant: "destructive"
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const [, formAction, isSaving] = useActionState(saveAlert, null);
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
export function getRandomItemInArray<T>(array: T[]) {
|
||||
// Source - https://stackoverflow.com/a/4550514
|
||||
const randomElement = array[Math.floor(Math.random() * array.length)];
|
||||
return randomElement;
|
||||
}
|
||||
Reference in New Issue
Block a user