DetailsContainer.ts 919 B

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