Wrapper.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. x
  34. </CustomScrollbar>
  35. </div>
  36. );
  37. }
  38. }
  39. const mapStateToProps = (state: StoreState) => {
  40. const { split } = state.explore;
  41. return { split };
  42. };
  43. const mapDispatchToProps = {
  44. resetExploreAction,
  45. };
  46. export default hot(module)(
  47. connect(
  48. mapStateToProps,
  49. mapDispatchToProps
  50. )(Wrapper)
  51. );