parent
dcc2f2596a
commit
5302c3e47f
3 changed files with 14 additions and 2 deletions
|
@ -23,6 +23,7 @@ interface Props extends Topic, TopicDetails {
|
|||
clusterName: ClusterName;
|
||||
topicName: TopicName;
|
||||
isInternal: boolean;
|
||||
isDeleted: boolean;
|
||||
deleteTopic: (clusterName: ClusterName, topicName: TopicName) => void;
|
||||
clearTopicMessages(clusterName: ClusterName, topicName: TopicName): void;
|
||||
}
|
||||
|
@ -31,6 +32,7 @@ const Details: React.FC<Props> = ({
|
|||
clusterName,
|
||||
topicName,
|
||||
isInternal,
|
||||
isDeleted,
|
||||
deleteTopic,
|
||||
clearTopicMessages,
|
||||
}) => {
|
||||
|
@ -41,8 +43,12 @@ const Details: React.FC<Props> = ({
|
|||
React.useState(false);
|
||||
const deleteTopicHandler = React.useCallback(() => {
|
||||
deleteTopic(clusterName, topicName);
|
||||
history.push(clusterTopicsPath(clusterName));
|
||||
}, [clusterName, topicName]);
|
||||
React.useEffect(() => {
|
||||
if (isDeleted) {
|
||||
history.push(clusterTopicsPath(clusterName));
|
||||
}
|
||||
}, [isDeleted]);
|
||||
|
||||
const clearTopicMessagesHandler = React.useCallback(() => {
|
||||
clearTopicMessages(clusterName, topicName);
|
||||
|
|
|
@ -2,7 +2,10 @@ 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 } from 'redux/reducers/topics/selectors';
|
||||
import {
|
||||
getIsTopicInternal,
|
||||
getTopicList,
|
||||
} from 'redux/reducers/topics/selectors';
|
||||
|
||||
import Details from './Details';
|
||||
|
||||
|
@ -24,6 +27,7 @@ const mapStateToProps = (
|
|||
clusterName,
|
||||
topicName,
|
||||
isInternal: getIsTopicInternal(state, topicName),
|
||||
isDeleted: !getTopicList(state).find((topic) => topic.name === topicName),
|
||||
});
|
||||
|
||||
const mapDispatchToProps = {
|
||||
|
|
|
@ -39,6 +39,7 @@ describe('Details', () => {
|
|||
isInternal={mockInternalTopicPayload}
|
||||
deleteTopic={mockDelete}
|
||||
clearTopicMessages={mockClearTopicMessages}
|
||||
isDeleted={false}
|
||||
/>
|
||||
</ClusterContext.Provider>
|
||||
</StaticRouter>
|
||||
|
@ -69,6 +70,7 @@ describe('Details', () => {
|
|||
isInternal={mockExternalTopicPayload}
|
||||
deleteTopic={mockDelete}
|
||||
clearTopicMessages={mockClearTopicMessages}
|
||||
isDeleted={false}
|
||||
/>
|
||||
</ClusterContext.Provider>
|
||||
</StaticRouter>
|
||||
|
|
Loading…
Add table
Reference in a new issue