Parcourir la source

Merge pull request #15117 from grafana/explore-time-range-fix

Fixed issue with explore changeTime redux action not being hooked up
Torkel Ödegaard il y a 7 ans
Parent
commit
f28d38ceef
1 fichiers modifiés avec 10 ajouts et 5 suppressions
  1. 10 5
      public/app/features/explore/GraphContainer.tsx

+ 10 - 5
public/app/features/explore/GraphContainer.tsx

@@ -1,17 +1,16 @@
 import React, { PureComponent } from 'react';
 import React, { PureComponent } from 'react';
 import { hot } from 'react-hot-loader';
 import { hot } from 'react-hot-loader';
 import { connect } from 'react-redux';
 import { connect } from 'react-redux';
-import { RawTimeRange, TimeRange } from '@grafana/ui';
+import { TimeRange, RawTimeRange } from '@grafana/ui';
 
 
 import { ExploreId, ExploreItemState } from 'app/types/explore';
 import { ExploreId, ExploreItemState } from 'app/types/explore';
 import { StoreState } from 'app/types';
 import { StoreState } from 'app/types';
 
 
-import { toggleGraph } from './state/actions';
+import { toggleGraph, changeTime } from './state/actions';
 import Graph from './Graph';
 import Graph from './Graph';
 import Panel from './Panel';
 import Panel from './Panel';
 
 
 interface GraphContainerProps {
 interface GraphContainerProps {
-  onChangeTime: (range: TimeRange) => void;
   exploreId: ExploreId;
   exploreId: ExploreId;
   graphResult?: any[];
   graphResult?: any[];
   loading: boolean;
   loading: boolean;
@@ -20,6 +19,7 @@ interface GraphContainerProps {
   showingTable: boolean;
   showingTable: boolean;
   split: boolean;
   split: boolean;
   toggleGraph: typeof toggleGraph;
   toggleGraph: typeof toggleGraph;
+  changeTime: typeof changeTime;
 }
 }
 
 
 export class GraphContainer extends PureComponent<GraphContainerProps> {
 export class GraphContainer extends PureComponent<GraphContainerProps> {
@@ -27,8 +27,12 @@ export class GraphContainer extends PureComponent<GraphContainerProps> {
     this.props.toggleGraph(this.props.exploreId);
     this.props.toggleGraph(this.props.exploreId);
   };
   };
 
 
+  onChangeTime = (timeRange: TimeRange) => {
+    this.props.changeTime(this.props.exploreId, timeRange);
+  };
+
   render() {
   render() {
-    const { exploreId, graphResult, loading, onChangeTime, showingGraph, showingTable, range, split } = this.props;
+    const { exploreId, graphResult, loading, showingGraph, showingTable, range, split } = this.props;
     const graphHeight = showingGraph && showingTable ? '200px' : '400px';
     const graphHeight = showingGraph && showingTable ? '200px' : '400px';
 
 
     if (!graphResult) {
     if (!graphResult) {
@@ -41,7 +45,7 @@ export class GraphContainer extends PureComponent<GraphContainerProps> {
           data={graphResult}
           data={graphResult}
           height={graphHeight}
           height={graphHeight}
           id={`explore-graph-${exploreId}`}
           id={`explore-graph-${exploreId}`}
-          onChangeTime={onChangeTime}
+          onChangeTime={this.onChangeTime}
           range={range}
           range={range}
           split={split}
           split={split}
         />
         />
@@ -61,6 +65,7 @@ function mapStateToProps(state: StoreState, { exploreId }) {
 
 
 const mapDispatchToProps = {
 const mapDispatchToProps = {
   toggleGraph,
   toggleGraph,
+  changeTime,
 };
 };
 
 
 export default hot(module)(connect(mapStateToProps, mapDispatchToProps)(GraphContainer));
 export default hot(module)(connect(mapStateToProps, mapDispatchToProps)(GraphContainer));