-
Notifications
You must be signed in to change notification settings - Fork 1
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
262 show template errors #271
Merged
Merged
Changes from 16 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
6f6760b
tera-web webasm package for tera templates
jmbrunskill a2664bc
POC rendering in frontend code
jmbrunskill 3b7c14f
initial body template validation
lache-melvin 00561b6
Better error handling for Tera Bindgen
jmbrunskill 8dd4620
Use try catch with error for template rendering test
jmbrunskill 2a076f8
Merge branch 'tera_playground' into 262-show-template-errors
lache-melvin f6f5431
only worry about template errors
lache-melvin 0f332c7
abstract out validateTemplate
lache-melvin b98e54a
prevent saving of enabled configs w invalid templates
lache-melvin cf3b1cc
validate subject template as well
lache-melvin f7fb75d
remove dist index.html from git
lache-melvin 709ecca
remove width prop
lache-melvin 1fb7b70
make template fields full width
lache-melvin 5c329b8
install published tera-web
lache-melvin 0290962
remove tera-web source code
lache-melvin a90be50
remove status check in `isInvalid`
lache-melvin 05fefe6
set isSaved to true initially
lache-melvin 1ff3432
templates must not be empty string to be valid
lache-melvin 5480d52
show body template as required
lache-melvin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
25 changes: 25 additions & 0 deletions
25
frontend/packages/system/src/Notifications/Pages/Scheduled/tera.ts
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,25 @@ | ||
import { renderOneOff } from '@openmsupply/tera-web'; | ||
|
||
const isTemplateError = (err: string) => { | ||
return err.startsWith('Template'); | ||
}; | ||
const isParamsError = (err: string) => { | ||
return err.startsWith('Parameter'); | ||
}; | ||
|
||
export const validateTemplate = (template: string) => { | ||
try { | ||
renderOneOff(template, JSON.stringify({})); | ||
} catch (e) { | ||
if (typeof e === 'string') { | ||
if (isTemplateError(e)) { | ||
throw e; | ||
} | ||
if (isParamsError(e)) { | ||
// Missing params are not an error when validating the template | ||
return; | ||
} | ||
} | ||
throw 'Unknown error :' + e; | ||
} | ||
}; |
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 |
---|---|---|
|
@@ -2664,6 +2664,11 @@ | |
dependencies: | ||
"@octokit/openapi-types" "^11.2.0" | ||
|
||
"@openmsupply/tera-web@^0.1.0": | ||
version "0.1.0" | ||
resolved "https://registry.yarnpkg.com/@openmsupply/tera-web/-/tera-web-0.1.0.tgz#95b71a5380feee8ab260adb7a407f2b0f1d1821e" | ||
integrity sha512-7SwRnVuBiKz6qiISAlPRna69mqPRMOcDMrym0lS6Of33lwBFo+VRwlwjGDfivI57WeFqODDJcfwufnp2Dx/1bQ== | ||
|
||
"@parcel/[email protected]": | ||
version "2.2.0" | ||
resolved "https://registry.yarnpkg.com/@parcel/watcher-android-arm64/-/watcher-android-arm64-2.2.0.tgz#3d1a71f251ba829ab884dfe119cc4f4c49c7222b" | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Would we ever send a notification with a subject but no body? Or a blank subject and just a body? i.e. do both subject and body need to exist, as well as being valid, or just that they need to be valid if they do exist?
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.
I think we should always have a body.
Telegram only renders the body, subject is just for email in current design.