-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Improve Cron schedule support #1395
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! It really looks more easy and clean.
One issue when I tried:
When it is in the weekly
, monthly
and yearly
tab, it can't be switched to the cron
tab. Got below exception
cron.ts:97 Uncaught TypeError: Cannot read properties of undefined (reading 'join')
at recurrenceToCron (cron.ts:97:41)
}) => { | ||
const description = useMemo(() => { | ||
try { | ||
if (cron) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: when it is (!cron), it will also raise exception. can just leave it to the try/catch to handle
import cronstrue from 'cronstrue'; | ||
import React, { useMemo } from 'react'; | ||
|
||
export const DescribeCron: React.FunctionComponent<{ cron?: string }> = ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't feel necessary to have this as a separate component. could be just a useMemo inside the RecurrenceEditor
component.
<> | ||
<input | ||
{...field} | ||
className="editor-input" | ||
placeholder="* * * * *" | ||
/> | ||
<div className="editor-text mt12"> | ||
<DescribeCron cron={recurrence.cron} /> | ||
</div> | ||
</> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this could be a separate component to me instead of DescribeCron
/** | ||
* Determines whether a cron string is supported by the recurrence editor. | ||
* | ||
* @param cron Cron string to validate | ||
* @returns true if cron string is supported by recurrence editor, false otherwise | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can also use cron-parser for validation, which is mentioned by package cronstrue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The backend has cron validation that prevents saving invalid crons, so I don't think we would need this here. This function is only used to determine if the RecurrenceEditor should use cron
mode or one of the simple modes.
Previously, you had to fill out the required fields in the |
Improved support for task scheduling via cron expression by integrating it directly into the RecurrenceEditor.
Aside from simplifying the code and UI, there are a number of functional benefits: