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