diff --git a/frontend/src/ide/scheduler/JobDeploy.jsx b/frontend/src/ide/scheduler/JobDeploy.jsx index f16f1b2..5c28c07 100644 --- a/frontend/src/ide/scheduler/JobDeploy.jsx +++ b/frontend/src/ide/scheduler/JobDeploy.jsx @@ -37,6 +37,7 @@ import { import { checkPermission } from "../../common/helpers"; import { useNotificationService } from "../../service/notification-service"; import { useProjectStore } from "../../store/project-store"; +import { useSessionStore } from "../../store/session-store"; import { useJobService } from "./service"; import { CronFields } from "./CronFields"; import { IntervalFields } from "./IntervalFields"; @@ -51,6 +52,8 @@ const TASK_TYPES = { const DEFAULT_CRON = "30 * * * *"; +const EMAIL_REGEX = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/; + /* ─── cron values reducer (matches CronFields interface) ─── */ const cronReducer = (state, action) => { switch (action.type) { @@ -98,6 +101,8 @@ const JobDeploy = memo(function JobDeploy({ const canWrite = checkPermission("JOB_DEPLOYMENT", "can_write"); const { notify } = useNotificationService(); const { projectId } = useProjectStore(); + const { sessionDetails } = useSessionStore(); + const userEmail = sessionDetails?.email || ""; const { createTask, updateTask, @@ -410,7 +415,7 @@ const JobDeploy = memo(function JobDeploy({ max_retries: 0, notify_on_failure: false, notify_on_success: false, - notification_emails: [], + notification_emails: userEmail ? [userEmail] : [], trigger_on_complete: null, }} > @@ -669,7 +674,26 @@ const JobDeploy = memo(function JobDeploy({ { + if (!value || value.length === 0) + return Promise.resolve(); + const invalid = value.filter( + (e) => !EMAIL_REGEX.test(e) + ); + if (invalid.length > 0) { + return Promise.reject( + new Error( + `Invalid email(s): ${invalid.join(", ")}` + ) + ); + } + return Promise.resolve(); + }, + }, + ]} >