-
Notifications
You must be signed in to change notification settings - Fork 256
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): Template variables can now select their source database #5367
Conversation
86214ee
to
d9c3610
Compare
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.
Nice work man! Some style suggestions but kudos to you for entering the abyss which is 1.x.
selectedSource, | ||
} = this.state | ||
|
||
nextTemplate.sourceID = '0' |
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'm assuming '0' is a source ID that can never exist? Perhaps document this ID's purpose with a variable?
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.
'0' is the default / dynamic database - so this clearly needs a comment since your assumption is WRONG 😆
// When we change the source database here and below, we want to reset the template complete | ||
private handleSelectDynamicSource = () => { | ||
this.setState({ | ||
isDynamicSourceSelected: true, |
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.
Why not a type
here instead of a boolean?
Something like type SelectedSourceType = 'static' | 'dynamic'
Then, this.setState({sourceType: 'dynamic'})
etc. Just a style suggestion. Functionally it will be the same. Don't particularly care for booleans. Limits us to only two cases.
And then the code would read so nice like:
if (sourceType === 'dynamic') {
... do dynamic stuff here
}
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.
We talked about this offline a little bit - I'm going to hold off on doing this right now.
I agree with the assessment 100% The issue is that this pattern is used elsewhere and even though it's a little wonky, I think having consistent wonk for a short while is less confusing than having some wonk and some Done Right™ implementations.
We're planning on having a follow up 1.8.1 release, this might be worth thinking about for that.
go.mod
Outdated
@@ -29,6 +29,7 @@ require ( | |||
github.com/influxdata/usage-client v0.0.0-20160829180054-6d3895376368 | |||
github.com/jessevdk/go-flags v1.4.0 | |||
github.com/jonboulle/clockwork v0.1.0 // indirect | |||
github.com/kevinburke/go-bindata v3.16.0+incompatible // indirect |
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.
we probably should just leave this in, as they get injected every time we run make
, but it's not used by chronograf outside the makefile. to avoid churn, remove these go.*
changes either manually or with a go mod tidy
.
Values: vals, | ||
Type: t.Type, | ||
Label: t.Label, | ||
SourceID: int64(t.SourceID), |
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.
for uniformity, set this to int(t.SourceID)
d9c3610
to
6afdc59
Compare
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.
nice!
also, in the future force push overwriting commits once all the reviews are complete so as to keep the review process simple.
6afdc59
to
089de7b
Compare
needs docs. @noramullen1 |
Closes #5254
Template variables can now select and use a source database other than the default dynamic one