import React from 'react'; import { TopicWithDetailedInfo, ClusterName, TopicName, } from 'redux/interfaces'; import Breadcrumb from 'components/common/Breadcrumb/Breadcrumb'; import { Link, useParams } from 'react-router-dom'; import { clusterTopicNewPath } from 'lib/paths'; import usePagination from 'lib/hooks/usePagination'; import { FetchTopicsListParams } from 'redux/actions'; import ClusterContext from 'components/contexts/ClusterContext'; import PageLoader from 'components/common/PageLoader/PageLoader'; import Pagination from 'components/common/Pagination/Pagination'; import ListItem from './ListItem'; interface Props { areTopicsFetching: boolean; topics: TopicWithDetailedInfo[]; externalTopics: TopicWithDetailedInfo[]; totalPages: number; fetchTopicsList(props: FetchTopicsListParams): void; deleteTopic(topicName: TopicName, clusterName: ClusterName): void; clearTopicMessages( topicName: TopicName, clusterName: ClusterName, partitions?: number[] ): void; } const List: React.FC = ({ areTopicsFetching, topics, externalTopics, totalPages, fetchTopicsList, deleteTopic, clearTopicMessages, }) => { const { isReadOnly } = React.useContext(ClusterContext); const { clusterName } = useParams<{ clusterName: ClusterName }>(); const { page, perPage } = usePagination(); React.useEffect(() => { fetchTopicsList({ clusterName, page, perPage }); }, [fetchTopicsList, clusterName, page, perPage]); const [showInternal, setShowInternal] = React.useState(true); const handleSwitch = React.useCallback(() => { setShowInternal(!showInternal); }, [showInternal]); const items = showInternal ? topics : externalTopics; return (
{showInternal ? `All Topics` : `External Topics`}
{!isReadOnly && ( Add a Topic )}
{areTopicsFetching ? ( ) : (
{items.map((topic) => ( ))} {items.length === 0 && ( )}
Topic Name Total Partitions Out of sync replicas Type
No topics found
)}
); }; export default List;