grafana/public/app/features/explore/Wrapper.tsx

69 lines
1.8 KiB
TypeScript
Raw Normal View History

2018-09-28 10:38:50 -05:00
import React, { Component } from 'react';
import { hot } from 'react-hot-loader';
import { connect } from 'react-redux';
import { updateLocation } from 'app/core/actions';
2019-01-11 11:26:56 -06:00
// import { serializeStateToUrlParam, parseUrlState } from 'app/core/utils/explore';
import { StoreState } from 'app/types';
2019-01-11 11:26:56 -06:00
import { ExploreId } from 'app/types/explore';
import ErrorBoundary from './ErrorBoundary';
2018-10-01 05:56:26 -05:00
import Explore from './Explore';
interface WrapperProps {
backendSrv?: any;
datasourceSrv?: any;
split: boolean;
2019-01-11 11:26:56 -06:00
updateLocation: typeof updateLocation;
// urlStates: { [key: string]: string };
}
2019-01-11 11:26:56 -06:00
export class Wrapper extends Component<WrapperProps> {
// urlStates: { [key: string]: string };
constructor(props: WrapperProps) {
super(props);
2019-01-11 11:26:56 -06:00
// this.urlStates = props.urlStates;
}
2019-01-11 11:26:56 -06:00
// onSaveState = (key: string, state: ExploreState) => {
// const urlState = serializeStateToUrlParam(state, true);
// this.urlStates[key] = urlState;
// this.props.updateLocation({
// query: this.urlStates,
// });
// };
render() {
2019-01-11 11:26:56 -06:00
const { split } = this.props;
// State overrides for props from first Explore
2019-01-11 11:26:56 -06:00
// const urlStateLeft = parseUrlState(this.urlStates[STATE_KEY_LEFT]);
// const urlStateRight = parseUrlState(this.urlStates[STATE_KEY_RIGHT]);
return (
<div className="explore-wrapper">
<ErrorBoundary>
2019-01-11 11:26:56 -06:00
<Explore exploreId={ExploreId.left} />
</ErrorBoundary>
{split && (
<ErrorBoundary>
2019-01-11 11:26:56 -06:00
<Explore exploreId={ExploreId.right} />
</ErrorBoundary>
)}
</div>
);
}
}
2019-01-11 11:26:56 -06:00
const mapStateToProps = (state: StoreState) => {
// urlStates: state.location.query,
const { split } = state.explore;
return { split };
};
const mapDispatchToProps = {
updateLocation,
};
export default hot(module)(connect(mapStateToProps, mapDispatchToProps)(Wrapper));