Wrapper.tsx 1.4 KB

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