Skip to content
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

Merged
merged 1 commit into from
Feb 6, 2020

Conversation

hoorayimhelping
Copy link
Contributor

@hoorayimhelping hoorayimhelping commented Feb 5, 2020

Closes #5254

Template variables can now select and use a source database other than the default dynamic one

Screen Shot 2020-02-05 at 10 02 27 AM

Screen Shot 2020-02-05 at 10 02 47 AM

  • CHANGELOG.md updated with a link to the PR (not the Issue)
  • Rebased/mergeable
  • Tests pass

@hoorayimhelping hoorayimhelping force-pushed the bs_source_databases branch 2 times, most recently from 86214ee to d9c3610 Compare February 6, 2020 00:08
@hoorayimhelping hoorayimhelping requested review from goller, desa, glinton and 121watts and removed request for goller February 6, 2020 00:27
Copy link
Contributor

@121watts 121watts left a 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'
Copy link
Contributor

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?

Copy link
Contributor Author

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,
Copy link
Contributor

@121watts 121watts Feb 6, 2020

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
}

Copy link
Contributor Author

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
Copy link
Contributor

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),
Copy link
Contributor

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)

Copy link
Contributor

@glinton glinton left a 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.

@hoorayimhelping hoorayimhelping merged commit fff7836 into master Feb 6, 2020
@hoorayimhelping hoorayimhelping deleted the bs_source_databases branch February 6, 2020 21:10
@timhallinflux
Copy link
Contributor

needs docs. @noramullen1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Template variables need a source database
4 participants