import React from 'react'; import { useParams } from 'react-router-dom'; import { Connect, FullConnectorInfo } from 'generated-sources'; import { ClusterName, ConnectorSearch } from 'redux/interfaces'; import { clusterConnectorNewPath } from 'lib/paths'; import ClusterContext from 'components/contexts/ClusterContext'; import PageLoader from 'components/common/PageLoader/PageLoader'; import Search from 'components/common/Search/Search'; import * as Metrics from 'components/common/Metrics'; import PageHeading from 'components/common/PageHeading/PageHeading'; import { Button } from 'components/common/Button/Button'; import { ControlPanelWrapper } from 'components/common/ControlPanel/ControlPanel.styled'; import { Table } from 'components/common/table/Table/Table.styled'; import TableHeaderCell from 'components/common/table/TableHeaderCell/TableHeaderCell'; import ListItem from './ListItem'; export interface ListProps { areConnectsFetching: boolean; areConnectorsFetching: boolean; connectors: FullConnectorInfo[]; connects: Connect[]; fetchConnects(clusterName: ClusterName): void; fetchConnectors({ clusterName }: { clusterName: ClusterName }): void; search: string; setConnectorSearch(value: ConnectorSearch): void; } const List: React.FC = ({ connectors, areConnectsFetching, areConnectorsFetching, fetchConnects, fetchConnectors, search, setConnectorSearch, }) => { const { isReadOnly } = React.useContext(ClusterContext); const { clusterName } = useParams<{ clusterName: string }>(); React.useEffect(() => { fetchConnects(clusterName); fetchConnectors({ clusterName }); }, [fetchConnects, fetchConnectors, clusterName]); const handleSearch = (value: string) => setConnectorSearch({ clusterName, search: value, }); return ( <> {!isReadOnly && ( )} {connectors.length} {areConnectorsFetching ? ( ) : (
{connectors.length === 0 && ( )} {connectors.map((connector) => ( ))}
No connectors found
)} ); }; export default List;