@@ -42,7 +42,7 @@ import { listACLs } from 'protogen/redpanda/api/dataplane/v1/acl-ACLService_conn
4242import { Scope } from 'protogen/redpanda/api/dataplane/v1/secret_pb' ;
4343import { listUsers } from 'protogen/redpanda/api/dataplane/v1/user-UserService_connectquery' ;
4444import { forwardRef , useCallback , useEffect , useImperativeHandle , useMemo , useRef , useState } from 'react' ;
45- import { useForm , useWatch } from 'react-hook-form' ;
45+ import { type Control , useForm , useWatch } from 'react-hook-form' ;
4646import { useCreateSecretMutation } from 'react-query/api/secret' ;
4747import { useListUsersQuery } from 'react-query/api/user' ;
4848import { LONG_LIVED_CACHE_STALE_TIME } from 'react-query/react-query.utils' ;
@@ -66,12 +66,14 @@ import {
6666 checkUserHasConsumerGroupPermissions ,
6767 checkUserHasTopicReadWritePermissions ,
6868 getACLOperationName ,
69+ SASL_MECHANISM_OPTIONS ,
70+ SASLMechanism ,
6971 useCreateUserWithSecretsMutation ,
7072} from '../utils/user' ;
7173
7274type AddUserStepProps = {
7375 defaultUsername ?: string ;
74- defaultSaslMechanism ?: ( typeof SASL_MECHANISMS ) [ number ] ;
76+ defaultSaslMechanism ?: SASLMechanism ;
7577 hideInternal ?: boolean ;
7678 topicName ?: string ;
7779 defaultConsumerGroup ?: string ;
@@ -131,14 +133,16 @@ export const AddUserStep = forwardRef<UserStepRef, AddUserStepProps & MotionProp
131133 defaultValues : {
132134 username : defaultUsername || '' ,
133135 password : generatePassword ( 30 , false ) ,
134- saslMechanism : defaultSaslMechanism || 'SCRAM-SHA-256' ,
136+ saslMechanism : defaultSaslMechanism ?? SASLMechanism . SASL_MECHANISM_SCRAM_SHA_256 ,
135137 grantTopicPermissions : true ,
136138 specialCharactersEnabled : false ,
137139 passwordLength : 30 ,
138140 consumerGroup : defaultConsumerGroup || '' ,
139141 } ,
140142 } ) ;
141143
144+ const control = form . control as Control < AddUserFormData > ;
145+
142146 const watchedUsername = useWatch ( {
143147 control : form . control ,
144148 name : 'username' ,
@@ -470,7 +474,7 @@ export const AddUserStep = forwardRef<UserStepRef, AddUserStepProps & MotionProp
470474
471475 < div className = "flex gap-2" >
472476 < FormField
473- control = { form . control }
477+ control = { control }
474478 name = "username"
475479 render = { ( { field } ) => (
476480 < FormItem >
@@ -584,7 +588,7 @@ export const AddUserStep = forwardRef<UserStepRef, AddUserStepProps & MotionProp
584588 { userSelectionType === CreatableSelectionOptions . CREATE && (
585589 < >
586590 < FormField
587- control = { form . control }
591+ control = { control }
588592 disabled = { isPending || isReadOnly }
589593 name = "password"
590594 render = { ( { field } ) => (
@@ -612,7 +616,7 @@ export const AddUserStep = forwardRef<UserStepRef, AddUserStepProps & MotionProp
612616 < FormField
613617 disabled = { isReadOnly }
614618 { ...field }
615- control = { form . control }
619+ control = { control }
616620 name = "specialCharactersEnabled"
617621 render = { ( { field : specialCharsField } ) => (
618622 < div className = "flex flex-row items-center gap-2" >
@@ -635,7 +639,7 @@ export const AddUserStep = forwardRef<UserStepRef, AddUserStepProps & MotionProp
635639 ) }
636640 />
637641 < FormField
638- control = { form . control }
642+ control = { control }
639643 disabled = { isPending || isReadOnly }
640644 name = "saslMechanism"
641645 render = { ( { field } ) => (
@@ -665,7 +669,7 @@ export const AddUserStep = forwardRef<UserStepRef, AddUserStepProps & MotionProp
665669
666670 { Boolean ( topicName ) && (
667671 < FormField
668- control = { form . control }
672+ control = { control }
669673 disabled = { isPending || isReadOnly }
670674 name = "grantTopicPermissions"
671675 render = { ( { field } ) => (
@@ -727,7 +731,7 @@ export const AddUserStep = forwardRef<UserStepRef, AddUserStepProps & MotionProp
727731 < div className = "flex flex-col items-start gap-2" >
728732 < div className = "flex gap-2" >
729733 < FormField
730- control = { form . control }
734+ control = { control }
731735 name = "consumerGroup"
732736 render = { ( { field } ) => (
733737 < FormItem >
0 commit comments