forked from provectus/kafka-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement updating registry compatibility level (provectus#391)
* Implement updating registry compatibility level
- Loading branch information
Showing
12 changed files
with
345 additions
and
5 deletions.
There are no files selected for viewing
78 changes: 78 additions & 0 deletions
78
kafka-ui-react-app/src/components/Schemas/List/GlobalSchemaSelector.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
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<void>; | ||
} | ||
|
||
const GlobalSchemaSelector: React.FC<GlobalSchemaSelectorProps> = ({ | ||
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 ( | ||
<div className="level-item"> | ||
<h5 className="is-5 mr-2">Global Compatibility Level: </h5> | ||
<div className="select mr-2"> | ||
<select | ||
name="compatibilityLevel" | ||
defaultValue={globalSchemaCompatibilityLevel} | ||
ref={register()} | ||
onChange={() => setUpdateCompatibilityConfirmationVisible(true)} | ||
> | ||
{Object.keys(CompatibilityLevelCompatibilityEnum).map( | ||
(level: string) => ( | ||
<option key={level} value={level}> | ||
{level} | ||
</option> | ||
) | ||
)} | ||
</select> | ||
</div> | ||
<ConfirmationModal | ||
isOpen={isUpdateCompatibilityConfirmationVisible} | ||
onCancel={() => setUpdateCompatibilityConfirmationVisible(false)} | ||
onConfirm={handleSubmit(onCompatibilityLevelUpdate)} | ||
> | ||
{isSubmitting ? ( | ||
<PageLoader /> | ||
) : ( | ||
`Are you sure you want to update the global compatibility level? | ||
This may affect the compatibility levels of the schemas.` | ||
)} | ||
</ConfirmationModal> | ||
</div> | ||
); | ||
}; | ||
|
||
export default GlobalSchemaSelector; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 13 additions & 1 deletion
14
kafka-ui-react-app/src/components/Schemas/List/ListContainer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,32 @@ | ||
import { connect } from 'react-redux'; | ||
import { RootState } from 'redux/interfaces'; | ||
import { fetchSchemasByClusterName } from 'redux/actions'; | ||
import { | ||
fetchSchemasByClusterName, | ||
fetchGlobalSchemaCompatibilityLevel, | ||
updateGlobalSchemaCompatibilityLevel, | ||
} from 'redux/actions'; | ||
import { | ||
getIsSchemaListFetching, | ||
getSchemaList, | ||
getGlobalSchemaCompatibilityLevel, | ||
getGlobalSchemaCompatibilityLevelFetched, | ||
} from 'redux/reducers/schemas/selectors'; | ||
|
||
import List from './List'; | ||
|
||
const mapStateToProps = (state: RootState) => ({ | ||
isFetching: getIsSchemaListFetching(state), | ||
schemas: getSchemaList(state), | ||
globalSchemaCompatibilityLevel: getGlobalSchemaCompatibilityLevel(state), | ||
isGlobalSchemaCompatibilityLevelFetched: getGlobalSchemaCompatibilityLevelFetched( | ||
state | ||
), | ||
}); | ||
|
||
const mapDispatchToProps = { | ||
fetchGlobalSchemaCompatibilityLevel, | ||
fetchSchemasByClusterName, | ||
updateGlobalSchemaCompatibilityLevel, | ||
}; | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(List); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.