DangerZoneContainer.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { connect } from 'react-redux';
  2. import { RootState, ClusterName, TopicName } from 'redux/interfaces';
  3. import { withRouter, RouteComponentProps } from 'react-router-dom';
  4. import {
  5. updateTopicPartitionsCount,
  6. updateTopicReplicationFactor,
  7. } from 'redux/actions';
  8. import {
  9. getTopicPartitionsCountIncreased,
  10. getTopicReplicationFactorUpdated,
  11. } from 'redux/reducers/topics/selectors';
  12. import DangerZone from './DangerZone';
  13. interface RouteProps {
  14. clusterName: ClusterName;
  15. topicName: TopicName;
  16. }
  17. type OwnProps = {
  18. defaultPartitions: number;
  19. defaultReplicationFactor: number;
  20. };
  21. const mapStateToProps = (
  22. state: RootState,
  23. {
  24. match: {
  25. params: { topicName, clusterName },
  26. },
  27. defaultPartitions,
  28. defaultReplicationFactor,
  29. }: OwnProps & RouteComponentProps<RouteProps>
  30. ) => ({
  31. clusterName,
  32. topicName,
  33. defaultPartitions,
  34. defaultReplicationFactor,
  35. partitionsCountIncreased: getTopicPartitionsCountIncreased(state),
  36. replicationFactorUpdated: getTopicReplicationFactorUpdated(state),
  37. });
  38. const mapDispatchToProps = {
  39. updateTopicPartitionsCount,
  40. updateTopicReplicationFactor,
  41. };
  42. export default withRouter(
  43. connect(mapStateToProps, mapDispatchToProps)(DangerZone)
  44. );