@@ -22,6 +22,9 @@ import Metrics from 'widgets/ClusterConfigForm/Sections/Metrics';
2222import CustomAuthentication from 'widgets/ClusterConfigForm/Sections/CustomAuthentication' ;
2323import Authentication from 'widgets/ClusterConfigForm/Sections/Authentication/Authentication' ;
2424import KSQL from 'widgets/ClusterConfigForm/Sections/KSQL' ;
25+ import { useConfirm } from 'lib/hooks/useConfirm' ;
26+
27+ import { useDeleteCluster } from './hooks/useDeleteCluster' ;
2528
2629interface ClusterConfigFormProps {
2730 hasCustomConfig ?: boolean ;
@@ -52,12 +55,23 @@ const ClusterConfigForm: React.FC<ClusterConfigFormProps> = ({
5255
5356 const validate = useValidateAppConfig ( ) ;
5457 const update = useUpdateAppConfig ( { initialName : initialValues . name } ) ;
58+ const [ deleteCluster , isDeleting ] = useDeleteCluster ( ) ;
59+ const confirm = useConfirm ( true ) ;
60+
5561 const {
5662 value : isFormDisabled ,
5763 setTrue : disableForm ,
5864 setFalse : enableForm ,
5965 } = useBoolean ( ) ;
6066
67+ const confirmClusterDelete = ( ) =>
68+ confirm ( 'Are you sure want to delete this cluster?' , async ( ) => {
69+ if ( initialValues . name ) {
70+ await deleteCluster . mutateAsync ( initialValues . name ) ;
71+ navigate ( '/' ) ;
72+ }
73+ } ) ;
74+
6175 const onSubmit = async ( data : ClusterConfigFormValues ) => {
6276 const config = transformFormDataToPayload ( data ) ;
6377 try {
@@ -146,6 +160,17 @@ const ClusterConfigForm: React.FC<ClusterConfigFormProps> = ({
146160 >
147161 Submit
148162 </ Button >
163+ { initialValues . name && (
164+ < Button
165+ type = "button"
166+ buttonSize = "L"
167+ buttonType = "danger"
168+ inProgress = { isDeleting }
169+ onClick = { confirmClusterDelete }
170+ >
171+ Delete
172+ </ Button >
173+ ) }
149174 </ S . ButtonWrapper >
150175 </ FlexFieldset >
151176 </ StyledForm >
0 commit comments