From deda6c936b23d1ee794edbe4d23b5de4cc89eadc Mon Sep 17 00:00:00 2001 From: Alirie Gray Date: Mon, 10 Sep 2018 11:46:43 -0700 Subject: [PATCH] Add function to set service when flux toggled on dynamic source --- .../dashboards/components/CellEditorOverlay.tsx | 3 ++- .../shared/components/TimeMachine/TimeMachine.tsx | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ui/src/dashboards/components/CellEditorOverlay.tsx b/ui/src/dashboards/components/CellEditorOverlay.tsx index b03edd70c..9000a9b96 100644 --- a/ui/src/dashboards/components/CellEditorOverlay.tsx +++ b/ui/src/dashboards/components/CellEditorOverlay.tsx @@ -125,7 +125,7 @@ class CellEditorOverlay extends Component { queryStatus, } = this.props - const {isStaticLegend} = this.state + const {isStaticLegend, currentService} = this.state return (
{ onResetFocus={this.handleResetFocus} isInCEO={true} sources={sources} + service={currentService} services={services} updateQueryDrafts={updateQueryDrafts} onToggleStaticLegend={this.handleToggleStaticLegend} diff --git a/ui/src/shared/components/TimeMachine/TimeMachine.tsx b/ui/src/shared/components/TimeMachine/TimeMachine.tsx index c6ccf4889..79ce0521a 100644 --- a/ui/src/shared/components/TimeMachine/TimeMachine.tsx +++ b/ui/src/shared/components/TimeMachine/TimeMachine.tsx @@ -1022,7 +1022,20 @@ class TimeMachine extends PureComponent { } private toggleFlux = (): void => { - console.log('toggling!') + const {services, updateService} = this.props + + if (this.isFluxSource) { + this.setState({selectedService: null}) + updateService(null) + } else { + const foundFluxForSource = services.find(service => { + return service.sourceID === this.source.id + }) + + if (foundFluxForSource) { + updateService(foundFluxForSource) + } + } } }