-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): Display pretty cron schedule (#5088)
Signed-off-by: Alex Collins <alex_collins@intuit.com>
- Loading branch information
Showing
15 changed files
with
102 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React = require('react'); | ||
|
||
const x = require('cronstrue'); | ||
|
||
/* | ||
https://github.com/bradymholt/cRonstrue | ||
vs | ||
https://github.com/robfig/cron | ||
I think we must assume that these libraries (or any two libraries) will never be exactly the same and accept that | ||
sometime it'll not work as expected. Therefore, we must let the user know about this. | ||
*/ | ||
|
||
export const PrettySchedule = ({schedule}: {schedule: string}) => { | ||
try { | ||
const pretty = x.toString(schedule); | ||
return <span title={pretty}>{pretty}</span>; | ||
} catch (e) { | ||
return <>{e.toString()}</>; | ||
} | ||
}; |
20 changes: 20 additions & 0 deletions
20
ui/src/app/cron-workflows/components/schedule-validator.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React = require('react'); | ||
import {SuccessIcon, WarningIcon} from '../../shared/components/fa-icons'; | ||
|
||
const x = require('cronstrue'); | ||
|
||
export const ScheduleValidator = ({schedule}: {schedule: string}) => { | ||
try { | ||
return ( | ||
<span> | ||
<SuccessIcon /> {x.toString(schedule)} | ||
</span> | ||
); | ||
} catch (e) { | ||
return ( | ||
<span> | ||
<WarningIcon /> Schedule maybe invalid: {e.toString()} | ||
</span> | ||
); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import * as React from 'react'; | ||
|
||
export const InfoIcon = () => <i className='fa fa-info-circle' />; | ||
export const SuccessIcon = () => <i className='fa fa-check-circle status-icon--success' />; | ||
export const WarningIcon = () => <i className='fa fa-exclamation-triangle status-icon--pending' />; | ||
export const ErrorIcon = () => <i className='fa fa-exclamation-circle status-icon--error' />; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters