-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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(ui): Adding templating to code snippets #15671
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.
Feels like there is enough logic in this component to have tests for it. What do you think?
Edit: forgot to add: this is super clean!
template={executeQueryCodeSnippet} | ||
label="Java Code" | ||
defaults={{ | ||
bucket: 'my_bucket', |
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.
should this be bucketID
and orgID
for consistency?
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 was going to start standardizing those, but at the same time have a plan to connect them all to redux state in a little bit to give them MORE consistency. like site wide, frontend <=> backend consistency. so.... yes, but meh?
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.
so.... yes, but meh
pretty much perfectly sums up software engineering, circa 2019.
👍
@ErrorHandling | ||
class TemplatedCodeSnippet extends PureComponent<Props> { | ||
// NOTE: this is just a simplified form of the resig classic: | ||
// https://johnresig.com/blog/javascript-micro-templating/ |
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.
🤙 dig this comment
yeah, you're probably right. at least the templating function + object.assigns. ON IT |
Merge branch 'master' of github.com:influxdata/influxdb into alex_templated_snippets
Merge branch 'master' of github.com:influxdata/influxdb into alex_templated_snippets
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.
hot diggity daffodil, good stuff!
template={executeQueryCodeSnippet} | ||
label="Java Code" | ||
defaults={{ | ||
bucket: 'my_bucket', |
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.
so.... yes, but meh
pretty much perfectly sums up software engineering, circa 2019.
👍
}) | ||
|
||
const template = 'this is only a <%= word %>' | ||
const response = 'this is only a sentance' |
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.
defanately keep this in.
This is a prereq for #14924 and wanted to make sure that it was applied separately, as it is its own chunk of functionality.
Basically it wraps a
CodeSnippet
with a small templating language based on a crowd favorite: https://johnresig.com/blog/javascript-micro-templating/so anytime you submit a string of
Hello <%= planet %>
, it will go off and look up the propertyplanet
from thevalue
prop passed into the component. if that's not defined, it'll look up the property in thedefaults
prop. if THAT is not defined, it just writesundefined
.^--- opens a CodeSnippet element with the text
Hello Mars