Skip to content

Commit c55380f

Browse files
FIX: Default Notification Emails to Current User and Add Validation (#58)
* fix: default notification emails to current user and add validation - Pre-populate notification_emails field with current user's email - Add email validation to reject invalid email formats - Update tooltip text 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: use stricter email regex for validation Update email regex to require 2+ character TLD and restrict allowed characters to prevent invalid addresses from passing validation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * chore: fix eslint formatting 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * refactor: move email regex to constant outside component 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent de058f9 commit c55380f

1 file changed

Lines changed: 26 additions & 2 deletions

File tree

frontend/src/ide/scheduler/JobDeploy.jsx

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import {
3737
import { checkPermission } from "../../common/helpers";
3838
import { useNotificationService } from "../../service/notification-service";
3939
import { useProjectStore } from "../../store/project-store";
40+
import { useSessionStore } from "../../store/session-store";
4041
import { useJobService } from "./service";
4142
import { CronFields } from "./CronFields";
4243
import { IntervalFields } from "./IntervalFields";
@@ -51,6 +52,8 @@ const TASK_TYPES = {
5152

5253
const DEFAULT_CRON = "30 * * * *";
5354

55+
const EMAIL_REGEX = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
56+
5457
/* ─── cron values reducer (matches CronFields interface) ─── */
5558
const cronReducer = (state, action) => {
5659
switch (action.type) {
@@ -98,6 +101,8 @@ const JobDeploy = memo(function JobDeploy({
98101
const canWrite = checkPermission("JOB_DEPLOYMENT", "can_write");
99102
const { notify } = useNotificationService();
100103
const { projectId } = useProjectStore();
104+
const { sessionDetails } = useSessionStore();
105+
const userEmail = sessionDetails?.email || "";
101106
const {
102107
createTask,
103108
updateTask,
@@ -410,7 +415,7 @@ const JobDeploy = memo(function JobDeploy({
410415
max_retries: 0,
411416
notify_on_failure: false,
412417
notify_on_success: false,
413-
notification_emails: [],
418+
notification_emails: userEmail ? [userEmail] : [],
414419
trigger_on_complete: null,
415420
}}
416421
>
@@ -669,7 +674,26 @@ const JobDeploy = memo(function JobDeploy({
669674
<Form.Item
670675
label="Notification Emails"
671676
name="notification_emails"
672-
tooltip="Comma-separated email addresses"
677+
tooltip="Enter email addresses"
678+
rules={[
679+
{
680+
validator: (_, value) => {
681+
if (!value || value.length === 0)
682+
return Promise.resolve();
683+
const invalid = value.filter(
684+
(e) => !EMAIL_REGEX.test(e)
685+
);
686+
if (invalid.length > 0) {
687+
return Promise.reject(
688+
new Error(
689+
`Invalid email(s): ${invalid.join(", ")}`
690+
)
691+
);
692+
}
693+
return Promise.resolve();
694+
},
695+
},
696+
]}
673697
>
674698
<Select
675699
mode="tags"

0 commit comments

Comments
 (0)