@@ -104,6 +104,9 @@ export default function NewChartModal({
104104 const [ revision , setRevision ] = useState ( '' )
105105 const [ allowTeams , setAllowTeams ] = useState ( true )
106106
107+ // Determines whether the GitHub URL is valid (i.e. a non-empty string that ends with "chart.yaml")
108+ const isValidGithubChartUrl = githubUrl . trim ( ) !== '' && githubUrl . toLowerCase ( ) . endsWith ( 'chart.yaml' )
109+
107110 const getChart = async ( ) => {
108111 if ( ! githubUrl ) {
109112 console . error ( 'No URL provided' )
@@ -164,6 +167,16 @@ export default function NewChartModal({
164167 }
165168 }
166169
170+ // Common sx style to grey out disabled inputs.
171+ const disabledSx = {
172+ '& .MuiInputBase-root.Mui-disabled' : {
173+ backgroundColor : '#58585833' ,
174+ } ,
175+ '& .MuiFormLabel-root.MuiInputLabel-root.Mui-disabled' : {
176+ color : '#6b6b6b !important' ,
177+ } ,
178+ }
179+
167180 return (
168181 < Modal open = { open } onClose = { handleClose } >
169182 < ModalBox >
@@ -177,6 +190,10 @@ export default function NewChartModal({
177190 ) }
178191 < ModalContent >
179192 < Box sx = { { display : 'flex' , flexDirection : 'column' , gap : 2 } } >
193+ { /* Helper text */ }
194+ < Typography variant = 'body2' color = 'textSecondary' >
195+ Please provide a valid GitHub URL pointing to a Chart.yaml file. The URL must end with chart.yaml.
196+ </ Typography >
180197 { /* Display the chart icon as a non-interactive image.
181198 If chartIcon is not set, show a default placeholder image. */ }
182199 < Box sx = { { display : 'flex' , justifyContent : 'center' } } >
@@ -202,12 +219,39 @@ export default function NewChartModal({
202219 Test connection
203220 </ Button >
204221 </ Box >
205-
206- { /* Editable fields for the fetched chart data */ }
207- < TextField label = 'Chart Name' value = { chartName } onChange = { ( e ) => setChartName ( e . target . value ) } fullWidth />
208- < TextField label = 'Icon URL' value = { chartIcon } onChange = { ( e ) => setChartIcon ( e . target . value ) } fullWidth />
209- < TextField label = 'Chart Path' value = { chartPath } onChange = { ( e ) => setChartPath ( e . target . value ) } fullWidth />
210- < TextField label = 'Revision' value = { revision } onChange = { ( e ) => setRevision ( e . target . value ) } fullWidth />
222+ { /* Editable fields for the fetched chart data. They remain disabled until a valid URL is provided. */ }
223+ < TextField
224+ label = 'Chart Name'
225+ value = { chartName }
226+ onChange = { ( e ) => setChartName ( e . target . value ) }
227+ fullWidth
228+ disabled = { ! isValidGithubChartUrl }
229+ sx = { disabledSx }
230+ />
231+ < TextField
232+ label = 'Icon URL'
233+ value = { chartIcon }
234+ onChange = { ( e ) => setChartIcon ( e . target . value ) }
235+ fullWidth
236+ disabled = { ! isValidGithubChartUrl }
237+ sx = { disabledSx }
238+ />
239+ < TextField
240+ label = 'Chart Path'
241+ value = { chartPath }
242+ onChange = { ( e ) => setChartPath ( e . target . value ) }
243+ fullWidth
244+ disabled = { ! isValidGithubChartUrl }
245+ sx = { disabledSx }
246+ />
247+ < TextField
248+ label = 'Revision'
249+ value = { revision }
250+ onChange = { ( e ) => setRevision ( e . target . value ) }
251+ fullWidth
252+ disabled = { ! isValidGithubChartUrl }
253+ sx = { disabledSx }
254+ />
211255 { /* New checkbox: Allow teams to use this chart */ }
212256 < FormControlLabel
213257 control = {
0 commit comments