import React from 'react'; import { CompatibilityLevelCompatibilityEnum, SchemaSubject, } from 'generated-sources'; import { useParams } from 'react-router-dom'; import { clusterSchemaNewPath } from 'lib/paths'; import { ClusterName } from 'redux/interfaces'; import PageLoader from 'components/common/PageLoader/PageLoader'; import ClusterContext from 'components/contexts/ClusterContext'; import { Table } from 'components/common/table/Table/Table.styled'; import TableHeaderCell from 'components/common/table/TableHeaderCell/TableHeaderCell'; import { Button } from 'components/common/Button/Button'; import PageHeading from 'components/common/PageHeading/PageHeading'; import ListItem from './ListItem'; import GlobalSchemaSelector from './GlobalSchemaSelector/GlobalSchemaSelector'; export interface ListProps { schemas: SchemaSubject[]; isFetching: boolean; isGlobalSchemaCompatibilityLevelFetched: boolean; globalSchemaCompatibilityLevel?: CompatibilityLevelCompatibilityEnum; fetchSchemasByClusterName: (clusterName: ClusterName) => void; fetchGlobalSchemaCompatibilityLevel: ( clusterName: ClusterName ) => Promise; updateGlobalSchemaCompatibilityLevel: ( clusterName: ClusterName, compatibilityLevel: CompatibilityLevelCompatibilityEnum ) => Promise; } const List: React.FC = ({ schemas, isFetching, globalSchemaCompatibilityLevel, isGlobalSchemaCompatibilityLevelFetched, fetchSchemasByClusterName, fetchGlobalSchemaCompatibilityLevel, updateGlobalSchemaCompatibilityLevel, }) => { const { isReadOnly } = React.useContext(ClusterContext); const { clusterName } = useParams<{ clusterName: string }>(); React.useEffect(() => { fetchSchemasByClusterName(clusterName); fetchGlobalSchemaCompatibilityLevel(clusterName); }, [fetchSchemasByClusterName, clusterName]); return (
{!isReadOnly && isGlobalSchemaCompatibilityLevelFetched && ( <> )} {isFetching ? ( ) : (
{schemas.length === 0 && ( )} {schemas.map((subject) => ( ))}
No schemas found
)}
); }; export default List;