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