import React from 'react'; import { useHistory } from 'react-router'; 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 ClusterContext from 'components/contexts/ClusterContext'; import PageLoader from 'components/common/PageLoader/PageLoader'; import Pagination from 'components/common/Pagination/Pagination'; import { GetTopicsRequest, TopicColumnsToSort } from 'generated-sources'; import SortableColumnHeader from 'components/common/table/SortableCulumnHeader/SortableColumnHeader'; import Search from 'components/common/Search/Search'; import { PER_PAGE } from 'lib/constants'; import ListItem from './ListItem'; export interface TopicsListProps { areTopicsFetching: boolean; topics: TopicWithDetailedInfo[]; totalPages: number; fetchTopicsList(props: GetTopicsRequest): void; deleteTopic(topicName: TopicName, clusterName: ClusterName): void; clearTopicMessages( topicName: TopicName, clusterName: ClusterName, partitions?: number[] ): void; search: string; orderBy: TopicColumnsToSort | null; setTopicsSearch(search: string): void; setTopicsOrderBy(orderBy: TopicColumnsToSort | null): void; } const List: React.FC = ({ areTopicsFetching, topics, totalPages, fetchTopicsList, deleteTopic, clearTopicMessages, search, orderBy, setTopicsSearch, setTopicsOrderBy, }) => { const { isReadOnly } = React.useContext(ClusterContext); const { clusterName } = useParams<{ clusterName: ClusterName }>(); const { page, perPage, pathname } = usePagination(); const [showInternal, setShowInternal] = React.useState(true); const history = useHistory(); React.useEffect(() => { fetchTopicsList({ clusterName, page, perPage, orderBy: orderBy || undefined, search, showInternal, }); }, [ fetchTopicsList, clusterName, page, perPage, orderBy, search, showInternal, ]); const handleSwitch = React.useCallback(() => { setShowInternal(!showInternal); history.push(`${pathname}?page=1&perPage=${perPage || PER_PAGE}`); }, [showInternal]); return (
{showInternal ? `All Topics` : `External Topics`}
{!isReadOnly && ( Add a Topic )}
{areTopicsFetching ? ( ) : (
{topics.map((topic) => ( ))} {topics.length === 0 && ( )}
Replication Factor Number of messages Size Type Clean Up Policy
No topics found
)}
); }; export default List;