FIX: Default Notification Emails to Current User and Add Validation#58
Conversation
- 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>
|
| Filename | Overview |
|---|---|
| frontend/src/ide/scheduler/JobDeploy.jsx | Added session-based email pre-population and tag-input email validation; edit-mode flow is unaffected (setFieldsValue overrides initialValues); one minor UX gap around untrimmed whitespace in comma-pasted tag values. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[JobDeploy opens] --> B{isEditMode?}
B -- Yes --> C[setLoading true\nfetch job data]
C --> D[form.setFieldsValue\nnotification_emails: job.notification_emails]
B -- No --> E[Form renders with initialValues\nnotification_emails: userEmail or empty]
D --> F[Form ready for edit]
E --> F2[Form ready for create]
F --> G[User submits]
F2 --> G
G --> H[Validator runs on notification_emails]
H --> I{value empty?}
I -- Yes --> J[Promise.resolve — field is optional]
I -- No --> K[Filter emails against EMAIL_REGEX]
K --> L{Invalid found?}
L -- Yes --> M[Promise.reject with list of invalid addresses]
L -- No --> N[Promise.resolve — submit proceeds]
Prompt To Fix All With AI
This is a comment left during a code review.
Path: frontend/src/ide/scheduler/JobDeploy.jsx
Line: 683-685
Comment:
**Tag values are not trimmed before validation**
The Select has `tokenSeparators` set to comma, so when a user pastes a comma-separated address list the tokens may include leading whitespace. That whitespace causes the regex test to fail on what visually appears to be a valid address, producing a confusing error message. Trimming each entry before testing would fix this, and the submitted payload should also be normalised to avoid space-padded addresses reaching the backend.
```suggestion
const invalid = value.filter(
(e) => !EMAIL_REGEX.test(String(e).trim())
);
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (4): Last reviewed commit: "refactor: move email regex to constant o..." | Re-trigger Greptile
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>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
@tahierhussain
LGTM.
One minor nit: the email regex (/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/) is defined inline inside the validator and gets recreated on every validation call. Consider moving it outside the component as a constant — but not a blocker.
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
@wicky-zipstack Done. I have moved the variable outside the component. Thanks for the suggestion! |
What
Why
How
useSessionStoreto access the current user's session detailsuserEmailfromsessionDetails.emailnotification_emailsinitial value to[userEmail]when available (empty array otherwise)Form.Itemrules that:/^[^\s@]+@[^\s@]+\.[^\s@]+$/)Can this PR break any existing features. If yes, please list possible items. If no, please explain why. (PS: Admins do not merge the PR without this section filled)
sessionDetails.emailis already used throughout the codebase (WelcomeBanner.jsx, UserDropdown.jsx)Database Migrations
Env Config
Relevant Docs
Related Issues or PRs
Dependencies Versions
Notes on Testing
Screenshots
Pre-populated current user's email address by default

Added email address validation

Checklist
I have read and understood the Contribution Guidelines.