import ConfirmationModal from 'components/common/ConfirmationModal/ConfirmationModal'; import PageLoader from 'components/common/PageLoader/PageLoader'; import { CompatibilityLevelCompatibilityEnum } from 'generated-sources'; import React from 'react'; import { useForm } from 'react-hook-form'; import { useParams } from 'react-router-dom'; import { ClusterName } from 'redux/interfaces'; export interface GlobalSchemaSelectorProps { globalSchemaCompatibilityLevel?: CompatibilityLevelCompatibilityEnum; updateGlobalSchemaCompatibilityLevel: ( clusterName: ClusterName, compatibilityLevel: CompatibilityLevelCompatibilityEnum ) => Promise; } const GlobalSchemaSelector: React.FC = ({ globalSchemaCompatibilityLevel, updateGlobalSchemaCompatibilityLevel, }) => { const { clusterName } = useParams<{ clusterName: string }>(); const { register, handleSubmit, formState: { isSubmitting }, } = useForm(); const [ isUpdateCompatibilityConfirmationVisible, setUpdateCompatibilityConfirmationVisible, ] = React.useState(false); const onCompatibilityLevelUpdate = async ({ compatibilityLevel, }: { compatibilityLevel: CompatibilityLevelCompatibilityEnum; }) => { await updateGlobalSchemaCompatibilityLevel(clusterName, compatibilityLevel); setUpdateCompatibilityConfirmationVisible(false); }; return (
Global Compatibility Level:
setUpdateCompatibilityConfirmationVisible(false)} onConfirm={handleSubmit(onCompatibilityLevelUpdate)} > {isSubmitting ? ( ) : ( `Are you sure you want to update the global compatibility level? This may affect the compatibility levels of the schemas.` )}
); }; export default GlobalSchemaSelector;