OverviewContainer.ts 981 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { connect } from 'react-redux';
  2. import { fetchTopicDetails } from 'redux/actions';
  3. import { RootState, TopicName, ClusterName } from 'redux/interfaces';
  4. import {
  5. getTopicByName,
  6. getIsTopicDetailsFetched,
  7. } from 'redux/reducers/topics/selectors';
  8. import { withRouter, RouteComponentProps } from 'react-router-dom';
  9. import Overview from './Overview';
  10. interface RouteProps {
  11. clusterName: ClusterName;
  12. topicName: TopicName;
  13. }
  14. type OwnProps = RouteComponentProps<RouteProps>;
  15. const mapStateToProps = (
  16. state: RootState,
  17. {
  18. match: {
  19. params: { topicName, clusterName },
  20. },
  21. }: OwnProps
  22. ) => ({
  23. clusterName,
  24. topicName,
  25. isFetched: getIsTopicDetailsFetched(state),
  26. ...getTopicByName(state, topicName),
  27. });
  28. const mapDispatchToProps = {
  29. fetchTopicDetails: (clusterName: ClusterName, topicName: TopicName) =>
  30. fetchTopicDetails(clusterName, topicName),
  31. };
  32. export default withRouter(
  33. connect(mapStateToProps, mapDispatchToProps)(Overview)
  34. );