@@ -2,7 +2,7 @@ import { DYNAMIC_ENV_TYPES } from '@data/dynamicEnvTypes';
22import { SelectItem } from '@heroui/select' ;
33import StyledInput from '@shared/StyledInput' ;
44import StyledSelect from '@shared/StyledSelect' ;
5- import { Controller , useFieldArray , useFormContext } from 'react-hook-form' ;
5+ import { Controller , useFieldArray , useFormContext , useWatch } from 'react-hook-form' ;
66import { RiAddLine } from 'react-icons/ri' ;
77import VariableSectionIndex from './VariableSectionIndex' ;
88import VariableSectionRemove from './VariableSectionRemove' ;
@@ -112,9 +112,17 @@ export default function DynamicEnvSection({ baseName = 'deployment' }: { baseNam
112112 // Check for specific error on this value input
113113 const specificValueError = entryError ?. values ?. [ k ] ?. value ;
114114
115+ // Watch the type value to conditionally disable input
116+ const typeValue = useWatch ( {
117+ control,
118+ name : `${ baseName } .dynamicEnvVars.${ index } .values.${ k } .type` ,
119+ } ) ;
120+
121+ const isHostIP = typeValue === 'host_ip' ;
122+
115123 return (
116124 < StyledInput
117- placeholder = " None"
125+ placeholder = { isHostIP ? 'Auto-filled by system' : ' None' }
118126 value = { field . value ?? '' }
119127 onChange = { async ( e ) => {
120128 const value = e . target . value ;
@@ -127,6 +135,7 @@ export default function DynamicEnvSection({ baseName = 'deployment' }: { baseNam
127135 errorMessage = {
128136 fieldState . error ?. message || specificValueError ?. message
129137 }
138+ isDisabled = { isHostIP }
130139 />
131140 ) ;
132141 } }
0 commit comments