@@ -66,6 +66,7 @@ interface CustomizeLaunchLinkFormProps {
6666 resetField : ReturnType <
6767 typeof useForm < EnvVariablesCustomizationForm >
6868 > [ "resetField" ] ;
69+ watch : ReturnType < typeof useForm < EnvVariablesCustomizationForm > > [ "watch" ] ;
6970}
7071
7172function CustomizeLaunchLinkForm ( {
@@ -75,6 +76,7 @@ function CustomizeLaunchLinkForm({
7576 handleSubmit,
7677 register,
7778 resetField,
79+ watch,
7880} : CustomizeLaunchLinkFormProps ) {
7981 const onSubmit = ( ) => { } ;
8082
@@ -98,6 +100,7 @@ function CustomizeLaunchLinkForm({
98100 control = { control }
99101 register = { register }
100102 resetField = { resetField }
103+ watch = { watch }
101104 />
102105 ) ) }
103106 </ Form >
@@ -174,21 +177,24 @@ function getLauncherDefaultValues(
174177 return { envVariables } ;
175178}
176179
177- interface EnvVariablesCustomizationFormContentProps {
178- control : CustomizeLaunchLinkFormProps [ "control" ] ;
179- errors : CustomizeLaunchLinkFormProps [ "errors" ] ;
180+ interface EnvVariablesCustomizationFormContentProps
181+ extends Pick <
182+ CustomizeLaunchLinkFormProps ,
183+ "control" | "errors" | "register" | "resetField" | "watch"
184+ > {
180185 index : number ;
181- register : CustomizeLaunchLinkFormProps [ "register" ] ;
182- resetField : CustomizeLaunchLinkFormProps [ "resetField" ] ;
183186}
184187
185188function EditEnvVariablesCustomizationFormContent ( {
186189 control,
187190 errors,
188191 index,
189192 resetField,
193+ watch,
190194} : EnvVariablesCustomizationFormContentProps ) {
191195 const error = errors . envVariables ? errors . envVariables [ index ] : undefined ;
196+ const isCustomized = watch ( `envVariables.${ index } .isCustomized` ) ;
197+ console . log ( { index, isCustomized } ) ;
192198 return (
193199 < div className = { cx ( "d-flex" , "align-items-baseline" , "gap-3" , "mb-3" ) } >
194200 < FormGroup check >
@@ -223,16 +229,19 @@ function EditEnvVariablesCustomizationFormContent({
223229 name = { `envVariables.${ index } .value` }
224230 render = { ( { field } ) => {
225231 const { ref, ...fieldProps } = field ;
226- return (
232+ return isCustomized ? (
227233 < Input
228234 bsSize = "sm"
229235 className = { cx ( error ?. value && "is-invalid" ) }
236+ disabled = { ! isCustomized }
230237 placeholder = "value"
231238 type = "text"
232239 data-cy = { `env-variables-input_${ index } -value` }
233240 { ...fieldProps }
234241 innerRef = { ref }
235242 />
243+ ) : (
244+ < Label > { fieldProps . value } </ Label >
236245 ) ;
237246 } }
238247 rules = { {
@@ -351,10 +360,10 @@ function SessionLaunchLink({
351360 ) ;
352361}
353362
354- interface SessionLaunchLinkCustomizationProps
355- extends Pick < CustomizeLaunchLinkFormProps , "fields" > {
356- watch : ReturnType < typeof useForm < EnvVariablesCustomizationForm > > [ "watch" ] ;
357- }
363+ type SessionLaunchLinkCustomizationProps = Pick <
364+ CustomizeLaunchLinkFormProps ,
365+ "fields" | "watch"
366+ > ;
358367function SessionLaunchLinkCustomization ( {
359368 fields,
360369 watch,
@@ -458,6 +467,7 @@ export default function SessionLaunchLinkModal({
458467 handleSubmit = { handleSubmit }
459468 register = { register }
460469 resetField = { resetField }
470+ watch = { watch }
461471 />
462472 </ ModalFooter >
463473 </ Modal >
0 commit comments