import React from 'react'; import { ClusterName, TopicName } from 'redux/interfaces'; import { NavLink, Route, Routes, useNavigate } from 'react-router-dom'; import { RouteParamsClusterTopic, clusterTopicMessagesRelativePath, clusterTopicSettingsRelativePath, clusterTopicConsumerGroupsRelativePath, clusterTopicEditRelativePath, clusterTopicSendMessageRelativePath, } from 'lib/paths'; import ClusterContext from 'components/contexts/ClusterContext'; import ConfirmationModal from 'components/common/ConfirmationModal/ConfirmationModal'; import PageHeading from 'components/common/PageHeading/PageHeading'; import { Button } from 'components/common/Button/Button'; import Dropdown from 'components/common/Dropdown/Dropdown'; import VerticalElipsisIcon from 'components/common/Icons/VerticalElipsisIcon'; import DropdownItem from 'components/common/Dropdown/DropdownItem'; import styled from 'styled-components'; import Navbar from 'components/common/Navigation/Navbar.styled'; import * as S from 'components/Topics/Topic/Details/Details.styled'; import { useAppDispatch, useAppSelector } from 'lib/hooks/redux'; import { getIsTopicDeletePolicy, getIsTopicInternal, } from 'redux/reducers/topics/selectors'; import useAppParams from 'lib/hooks/useAppParams'; import OverviewContainer from './Overview/OverviewContainer'; import TopicConsumerGroupsContainer from './ConsumerGroups/TopicConsumerGroupsContainer'; import SettingsContainer from './Settings/SettingsContainer'; import Messages from './Messages/Messages'; interface Props { isDeleted: boolean; deleteTopic: (payload: { clusterName: ClusterName; topicName: TopicName; }) => void; recreateTopic: (payload: { clusterName: ClusterName; topicName: TopicName; }) => void; clearTopicMessages(params: { clusterName: ClusterName; topicName: TopicName; }): void; } const HeaderControlsWrapper = styled.div` display: flex; justify-content: flex-end; align-self: center; gap: 26px; `; const Details: React.FC = ({ isDeleted, deleteTopic, recreateTopic, clearTopicMessages, }) => { const { clusterName, topicName } = useAppParams(); const isInternal = useAppSelector((state) => getIsTopicInternal(state, topicName) ); const isDeletePolicy = useAppSelector((state) => getIsTopicDeletePolicy(state, topicName) ); const navigate = useNavigate(); const dispatch = useAppDispatch(); const { isReadOnly, isTopicDeletionAllowed } = React.useContext(ClusterContext); const [isDeleteTopicConfirmationVisible, setDeleteTopicConfirmationVisible] = React.useState(false); const [isClearTopicConfirmationVisible, setClearTopicConfirmationVisible] = React.useState(false); const [ isRecreateTopicConfirmationVisible, setRecreateTopicConfirmationVisible, ] = React.useState(false); const deleteTopicHandler = () => deleteTopic({ clusterName, topicName }); React.useEffect(() => { if (isDeleted) { navigate('../..'); } }, [isDeleted, clusterName, dispatch, navigate]); const clearTopicMessagesHandler = () => { clearTopicMessages({ clusterName, topicName }); setClearTopicConfirmationVisible(false); }; const recreateTopicHandler = () => { recreateTopic({ clusterName, topicName }); setRecreateTopicConfirmationVisible(false); }; return (
Produce Message } /> {!isReadOnly && !isInternal && ( } right> navigate(clusterTopicEditRelativePath)} > Edit settings Pay attention! This operation has
especially important consequences.
{isDeletePolicy && ( setClearTopicConfirmationVisible(true)} danger > Clear messages )} setRecreateTopicConfirmationVisible(true)} danger > Recreate Topic {isTopicDeletionAllowed && ( setDeleteTopicConfirmationVisible(true)} danger > Remove topic )} } />
)}
setDeleteTopicConfirmationVisible(false)} onConfirm={deleteTopicHandler} > Are you sure want to remove {topicName} topic? setClearTopicConfirmationVisible(false)} onConfirm={clearTopicMessagesHandler} > Are you sure want to clear topic messages? setRecreateTopicConfirmationVisible(false)} onConfirm={recreateTopicHandler} > Are you sure want to recreate {topicName} topic? (isActive ? 'is-active' : '')} end > Overview (isActive ? 'is-active' : '')} > Messages (isActive ? 'is-active' : '')} > Consumers (isActive ? 'is-active' : '')} > Settings } /> } /> } /> } />
); }; export default Details;