Wrapper.tsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import React, { Component } from 'react';
  2. import { hot } from 'react-hot-loader';
  3. import { connect } from 'react-redux';
  4. import { StoreState } from 'app/types';
  5. import { ExploreId } from 'app/types/explore';
  6. import Explore from './Explore';
  7. import { CustomScrollbar, ErrorBoundaryAlert } from '@grafana/ui';
  8. import { resetExploreAction } from './state/actionTypes';
  9. interface WrapperProps {
  10. split: boolean;
  11. resetExploreAction: typeof resetExploreAction;
  12. }
  13. export class Wrapper extends Component<WrapperProps> {
  14. componentWillUnmount() {
  15. this.props.resetExploreAction({});
  16. }
  17. render() {
  18. const { split } = this.props;
  19. return (
  20. <div className="page-scrollbar-wrapper">
  21. <CustomScrollbar autoHeightMin={'100%'} autoHeightMax={''} className="custom-scrollbar--page">
  22. <div className="explore-wrapper">
  23. <ErrorBoundaryAlert style="page">
  24. <Explore exploreId={ExploreId.left} />
  25. </ErrorBoundaryAlert>
  26. {split && (
  27. <ErrorBoundaryAlert style="page">
  28. <Explore exploreId={ExploreId.right} />
  29. </ErrorBoundaryAlert>
  30. )}
  31. </div>
  32. </CustomScrollbar>
  33. </div>
  34. );
  35. }
  36. }
  37. const mapStateToProps = (state: StoreState) => {
  38. const { split } = state.explore;
  39. return { split };
  40. };
  41. const mapDispatchToProps = {
  42. resetExploreAction,
  43. };
  44. export default hot(module)(
  45. connect(
  46. mapStateToProps,
  47. mapDispatchToProps
  48. )(Wrapper)
  49. );