email env priority

This commit is contained in:
Alex Holliday committed 2025-11-20 19:27:22 +00:00
1 parent 3faff5dc54
commit 60153a88e2
7 files changed
+189 -23

No files matched your search

+11 -7
View File
@@ -9,14 +9,18 @@ export const useInitForm = ({
}) => {
return useMemo(() => {
const defaults: z.infer<typeof systemSettingsSchema> = {
systemEmailHost: initialData?.systemEmailHost || "",
systemEmailPort: initialData?.systemEmailPort ?? undefined,
systemEmailAddress: initialData?.systemEmailAddress || "",
systemEmailPassword: initialData?.systemEmailPassword || "",
systemEmailUser: initialData?.systemEmailUser || "",
systemEmailHost: initialData?.systemEmailHost ?? "",
systemEmailPort:
initialData?.systemEmailPort !== undefined &&
initialData?.systemEmailPort !== null
? String(initialData.systemEmailPort)
: "",
systemEmailAddress: initialData?.systemEmailAddress ?? "",
systemEmailPassword: initialData?.systemEmailPassword ?? "",
systemEmailUser: initialData?.systemEmailUser ?? "",
systemEmailConnectionHost:
initialData?.systemEmailConnectionHost || "localhost",
systemEmailTLSServername: initialData?.systemEmailTLSServername || "",
initialData?.systemEmailConnectionHost ?? "localhost",
systemEmailTLSServername: initialData?.systemEmailTLSServername ?? "",
systemEmailSecure: initialData?.systemEmailSecure ?? false,
systemEmailPool: initialData?.systemEmailPool ?? false,
systemEmailIgnoreTLS: initialData?.systemEmailIgnoreTLS ?? false,
@@ -64,6 +64,7 @@ export const NotificationChannelsForm = ({
const isValid = await trigger();
if (isValid) {
const res = await post("/notification-channels/test", getValues());
if (res) {
toastSuccess("Success");
}
@@ -130,12 +131,12 @@ export const NotificationChannelsForm = ({
type === "email"
? "Configure the email address where notifications will be sent"
: type === "webhook"
? "Configure the webhook URL endpoint where notifications will be sent"
: type === "slack"
? "Configure your Slack webhook URL. Create one in Slack: Settings & administration → Manage apps → Custom Integrations → Incoming Webhooks"
: type === "discord"
? "Configure your Discord webhook URL. Create one in Discord: Server Settings → Integrations → Webhooks → New Webhook"
: "Configure notification channel settings"
? "Configure the webhook URL endpoint where notifications will be sent"
: type === "slack"
? "Configure your Slack webhook URL. Create one in Slack: Settings & administration → Manage apps → Custom Integrations → Incoming Webhooks"
: type === "discord"
? "Configure your Discord webhook URL. Create one in Discord: Server Settings → Integrations → Webhooks → New Webhook"
: "Configure notification channel settings"
}
rightContent={
type === "email" ? (
+1 -2
View File
@@ -40,8 +40,7 @@ const SettingsPage = () => {
const initialSettings = useMemo(() => settings, [settings]);
const onSubmit = async (data: Partial<FormValues>) => {
const res = await patch("/settings", data);
console.log(res?.data);
const res = await patch("/settings/email", data);
};
const onTest = async (data: Partial<FormValues>) => {
+4 -2
View File
@@ -202,7 +202,9 @@ export const UptimeForm = ({
<TextInput
{...field}
type="number"
fieldLabel={t("createMonitorPage.incidentConfigStatusCheckNumber")}
fieldLabel={t(
"createMonitorPage.incidentConfigStatusCheckNumber"
)}
fullWidth
error={!!errors.n}
helperText={errors.n ? errors.n.message : ""}
@@ -227,7 +229,7 @@ export const UptimeForm = ({
render={({ field }) => (
<AutoComplete
multiple
fieldLabel={`You have ${notificationOptions.length} available notification ${notificationOptions.length === 1 ? 'channel' : 'channels'}`}
fieldLabel={`You have ${notificationOptions.length} available notification ${notificationOptions.length === 1 ? "channel" : "channels"}`}
options={notificationOptions}
getOptionLabel={(option) => option.name}
value={notificationOptions.filter((o: any) =>
+2 -1
View File
@@ -83,7 +83,8 @@ const durationSchemaInfra = z
const optionalString = <T extends z.ZodTypeAny>(schema: T) =>
z.preprocess(
(val) => (val === "" || val === null ? undefined : val),
(val) =>
val === "" || val === null || val === undefined ? undefined : val,
schema.optional()
);