grafana/public/app/features/explore/Wrapper.tsx
Andrej Ocenas 5bed54170e
Chore: Split Explore redux code into multiple sections (#28819)
* Split main reducer from item reducer

* Move query related redux to separate file

* Split more parts and tests

* Fix import

* Remove unused code

* Update public/app/features/explore/state/datasource.ts

Co-authored-by: Zoltán Bedi <zoltan.bedi@gmail.com>

* Add section comments

* Rename ExploreItem to ExplorePane

* Fix imports

Co-authored-by: Zoltán Bedi <zoltan.bedi@gmail.com>
2020-11-09 14:48:24 +01:00

54 lines
1.4 KiB
TypeScript

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';
import { CustomScrollbar, ErrorBoundaryAlert } from '@grafana/ui';
import { resetExploreAction } from './state/main';
import Explore from './Explore';
interface WrapperProps {
split: boolean;
resetExploreAction: typeof resetExploreAction;
}
export class Wrapper extends Component<WrapperProps> {
componentWillUnmount() {
this.props.resetExploreAction({});
}
render() {
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>
);
}
}
const mapStateToProps = (state: StoreState) => {
const { split } = state.explore;
return { split };
};
const mapDispatchToProps = {
resetExploreAction,
};
export default hot(module)(connect(mapStateToProps, mapDispatchToProps)(Wrapper));