@@ -881,38 +881,44 @@ export function CreateTopicModal({ isOpen, onClose }: { isOpen: boolean; onClose
881881
882882 const currentState = stateRef . current ;
883883
884- if ( ! currentState . topicName ) {
885- throw new Error ( '"Topic Name" must be set' ) ;
886- }
887- if ( ! currentState . cleanupPolicy ) {
888- throw new Error ( '"Cleanup Policy" must be set' ) ;
889- }
884+ setIsLoading ( true ) ;
885+ try {
886+ if ( ! currentState . topicName ) {
887+ throw new Error ( '"Topic Name" must be set' ) ;
888+ }
889+ if ( ! currentState . cleanupPolicy ) {
890+ throw new Error ( '"Cleanup Policy" must be set' ) ;
891+ }
890892
891- const config : { name : string ; value : string } [ ] = [ ] ;
892- const setVal = ( name : string , value : string | number | undefined ) => {
893- if ( value === undefined ) return ;
894- config . removeAll ( ( x ) => x . name === name ) ;
895- config . push ( { name, value : String ( value ) } ) ;
896- } ;
893+ const config : { name : string ; value : string } [ ] = [ ] ;
894+ const setVal = ( name : string , value : string | number | undefined ) => {
895+ if ( value === undefined ) return ;
896+ config . removeAll ( ( x ) => x . name === name ) ;
897+ config . push ( { name, value : String ( value ) } ) ;
898+ } ;
897899
898- for ( const x of currentState . additionalConfig ) {
899- setVal ( x . name , x . value ) ;
900- }
900+ for ( const x of currentState . additionalConfig ) {
901+ setVal ( x . name , x . value ) ;
902+ }
901903
902- if ( currentState . retentionTimeUnit !== 'default' ) {
903- setVal ( 'retention.ms' , getRetentionTimeFinalValue ( currentState . retentionTimeMs , currentState . retentionTimeUnit ) ) ;
904- }
905- if ( currentState . retentionSizeUnit !== 'default' ) {
906- setVal ( 'retention.bytes' , getRetentionSizeFinalValue ( currentState . retentionSize , currentState . retentionSizeUnit ) ) ;
907- }
908- if ( currentState . minInSyncReplicas !== undefined ) {
909- setVal ( 'min.insync.replicas' , currentState . minInSyncReplicas ) ;
910- }
904+ if ( currentState . retentionTimeUnit !== 'default' ) {
905+ setVal (
906+ 'retention.ms' ,
907+ getRetentionTimeFinalValue ( currentState . retentionTimeMs , currentState . retentionTimeUnit )
908+ ) ;
909+ }
910+ if ( currentState . retentionSizeUnit !== 'default' ) {
911+ setVal (
912+ 'retention.bytes' ,
913+ getRetentionSizeFinalValue ( currentState . retentionSize , currentState . retentionSizeUnit )
914+ ) ;
915+ }
916+ if ( currentState . minInSyncReplicas !== undefined ) {
917+ setVal ( 'min.insync.replicas' , currentState . minInSyncReplicas ) ;
918+ }
911919
912- setVal ( 'cleanup.policy' , currentState . cleanupPolicy ) ;
920+ setVal ( 'cleanup.policy' , currentState . cleanupPolicy ) ;
913921
914- setIsLoading ( true ) ;
915- try {
916922 const apiResult = await createTopic ( {
917923 topic : {
918924 name : currentState . topicName ,
0 commit comments