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

59 lines
1.5 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 { StoreState } from 'app/types';
import { ExploreId } from 'app/types/explore';
2018-10-01 05:56:26 -05:00
import Explore from './Explore';
import { CustomScrollbar, ErrorBoundaryAlert } from '@grafana/ui';
import { resetExploreAction } from './state/actionTypes';
interface WrapperProps {
split: boolean;
resetExploreAction: typeof resetExploreAction;
}
2019-01-11 11:26:56 -06:00
export class Wrapper extends Component<WrapperProps> {
componentWillUnmount() {
this.props.resetExploreAction();
}
render() {
2019-01-11 11:26:56 -06:00
const { split } = this.props;
return (
<div className="page-scrollbar-wrapper">
<CustomScrollbar autoHeightMin={'100%'} autoHeightMax={''} className="custom-scrollbar--page">
<div className="explore-wrapper">
<ErrorBoundaryAlert style="page">
<Explore exploreId={ExploreId.left} />
</ErrorBoundaryAlert>
{split && (
<ErrorBoundaryAlert style="page">
<Explore exploreId={ExploreId.right} />
</ErrorBoundaryAlert>
)}
</div>
</CustomScrollbar>
</div>
);
}
}
2019-01-11 11:26:56 -06:00
const mapStateToProps = (state: StoreState) => {
const { split } = state.explore;
return { split };
2019-01-11 11:26:56 -06:00
};
const mapDispatchToProps = {
resetExploreAction,
};
export default hot(module)(
connect(
mapStateToProps,
mapDispatchToProps
)(Wrapper)
);