kafka-ui/kafka-ui-react-app/src/components/Topics/Topic/Details/DetailsContainer.ts
Alexander Krivonosov 5302c3e47f
Fix the redirect after topic deletion (#820)
* Move redirect to a hook
2021-08-27 11:29:51 +03:00

40 lines
946 B
TypeScript

import { connect } from 'react-redux';
import { ClusterName, RootState, TopicName } from 'redux/interfaces';
import { withRouter, RouteComponentProps } from 'react-router-dom';
import { deleteTopic, clearTopicMessages } from 'redux/actions';
import {
getIsTopicInternal,
getTopicList,
} from 'redux/reducers/topics/selectors';
import Details from './Details';
interface RouteProps {
clusterName: ClusterName;
topicName: TopicName;
}
type OwnProps = RouteComponentProps<RouteProps>;
const mapStateToProps = (
state: RootState,
{
match: {
params: { topicName, clusterName },
},
}: OwnProps
) => ({
clusterName,
topicName,
isInternal: getIsTopicInternal(state, topicName),
isDeleted: !getTopicList(state).find((topic) => topic.name === topicName),
});
const mapDispatchToProps = {
deleteTopic,
clearTopicMessages,
};
export default withRouter(
connect(mapStateToProps, mapDispatchToProps)(Details)
);