DetailsContainer.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { connect } from 'react-redux';
  2. import { ClusterName, RootState, TopicName } from 'redux/interfaces';
  3. import { withRouter, RouteComponentProps } from 'react-router-dom';
  4. import { deleteTopic, recreateTopic } from 'redux/reducers/topics/topicsSlice';
  5. import { clearTopicMessages } from 'redux/reducers/topicMessages/topicMessagesSlice';
  6. import {
  7. getIsTopicDeleted,
  8. getIsTopicDeletePolicy,
  9. getIsTopicInternal,
  10. } from 'redux/reducers/topics/selectors';
  11. import Details from './Details';
  12. interface RouteProps {
  13. clusterName: ClusterName;
  14. topicName: TopicName;
  15. }
  16. type OwnProps = RouteComponentProps<RouteProps>;
  17. const mapStateToProps = (
  18. state: RootState,
  19. {
  20. match: {
  21. params: { topicName, clusterName },
  22. },
  23. }: OwnProps
  24. ) => ({
  25. clusterName,
  26. topicName,
  27. isInternal: getIsTopicInternal(state, topicName),
  28. isDeleted: getIsTopicDeleted(state),
  29. isDeletePolicy: getIsTopicDeletePolicy(state, topicName),
  30. });
  31. const mapDispatchToProps = {
  32. recreateTopic,
  33. deleteTopic,
  34. clearTopicMessages,
  35. };
  36. export default withRouter(
  37. connect(mapStateToProps, mapDispatchToProps)(Details)
  38. );