@@ -10,7 +10,7 @@ import { deepFlattenObject, deepGet, deepSet, mergeDeep } from "../../MergeDeep"
10
10
import { DeepObject } from "../../types/utils" ;
11
11
import { Parameter , ParameterArray , ParameterObject , Parameters , ParsedParameters , Config } from "../../types/config" ;
12
12
import { Ref } from "../../Refs" ;
13
- import { CATALOG_LAYOUT_SX } from "../../Constants" ;
13
+ import { ASSIGNED_SECRET_PLACEHOLDER , CATALOG_LAYOUT_SX , UNASSIGNED_SECRET_PLACEHOLDER } from "../../Constants" ;
14
14
import JsonSchemaLibrary from "json-schema-library" ;
15
15
import ConfigEditor from "./ConfigEditor" ;
16
16
@@ -57,8 +57,6 @@ interface ConfigurationModalProps {
57
57
onSecretChange : ( secret : { name : string , value : string } ) => Promise < void > ;
58
58
}
59
59
60
- const ASSIGNED_SECRET_PLACEHOLDER = '********' ;
61
- const UNASSIGNED_SECRET_PLACEHOLDER = '' ;
62
60
63
61
const ConfigurationModal = ( {
64
62
open,
@@ -71,7 +69,7 @@ const ConfigurationModal = ({
71
69
} : ConfigurationModalProps ) => {
72
70
73
71
const { startPull, registryItems, secrets } = useCatalogContext ( ) ;
74
- const { config, configLoading, saveConfig } = useConfigContext ( ) ;
72
+ const { config, configLoading } = useConfigContext ( ) ;
75
73
const [ localSecrets , setLocalSecrets ] = useState < { [ key : string ] : string | undefined } > ( { } ) ;
76
74
const [ localConfig , setLocalConfig ] = useState < { [ key : string ] : any } > ( { } ) ;
77
75
const [ configTemplate , setConfigTemplate ] = useState < Record < string , any > > ( { } ) ;
@@ -190,7 +188,7 @@ const ConfigurationModal = ({
190
188
const loadedSecrets = Secrets . getAssignedSecrets ( catalogItem , secrets ) ;
191
189
setAssignedSecrets ( loadedSecrets ) ;
192
190
setLocalSecrets ( loadedSecrets . reduce ( ( acc , secret ) => {
193
- acc [ secret . name ] = secret . assigned ? ASSIGNED_SECRET_PLACEHOLDER : UNASSIGNED_SECRET_PLACEHOLDER ;
191
+ acc [ secret . name ] = secret . assigned ? ASSIGNED_SECRET_PLACEHOLDER : '' ;
194
192
return acc ;
195
193
} , { } as { [ key : string ] : string | undefined } ) ) ;
196
194
} , [ catalogItem , secrets ] ) ;
@@ -257,65 +255,6 @@ const ConfigurationModal = ({
257
255
return '' ;
258
256
} ;
259
257
260
- // Validate the entire configuration against schema conditions
261
- const validateFullSchema = ( config : { [ key : string ] : any } , schema : any ) : { [ key : string ] : string } => {
262
- const errors : { [ key : string ] : string } = { } ;
263
-
264
- // Check basic parameter validations
265
- if ( schema && schema . parameters ) {
266
- Object . entries ( schema . parameters ) . forEach ( ( [ key , paramSchema ] : [ string , any ] ) => {
267
- if ( config [ key ] ) {
268
- if ( paramSchema . type === 'object' && paramSchema . properties ) {
269
- Object . entries ( paramSchema . properties ) . forEach ( ( [ propKey , propSchema ] : [ string , any ] ) => {
270
- const propPath = `${ key } .${ propKey } ` ;
271
- const propValue = deepGet ( config , propPath ) ;
272
-
273
- if ( propValue !== undefined ) {
274
- const error = validateConfigValue ( propKey , propValue , propSchema ) ;
275
- if ( error ) {
276
- errors [ propPath ] = error ;
277
- }
278
- }
279
- } ) ;
280
- } else {
281
- const error = validateConfigValue ( key , config [ key ] , paramSchema ) ;
282
- if ( error ) {
283
- errors [ key ] = error ;
284
- }
285
- }
286
- }
287
- } ) ;
288
- }
289
-
290
- // Check anyOf condition validations
291
- if ( schema && schema . anyOf ) {
292
- let anyConditionMet = false ;
293
-
294
- schema . anyOf . forEach ( ( condition : any ) => {
295
- if ( condition . required ) {
296
- const allRequiredPresent = condition . required . every ( ( requiredField : string ) =>
297
- config [ requiredField ] && Object . keys ( config [ requiredField ] ) . length > 0
298
- ) ;
299
-
300
- if ( allRequiredPresent ) {
301
- anyConditionMet = true ;
302
- }
303
- }
304
- } ) ;
305
-
306
- if ( ! anyConditionMet ) {
307
- const requiredOptions = schema . anyOf
308
- . map ( ( condition : any ) => condition . required ?. join ( ' or ' ) )
309
- . filter ( Boolean )
310
- . join ( ' or ' ) ;
311
-
312
- errors [ '_schema' ] = `At least one of the following must be configured: ${ requiredOptions } ` ;
313
- }
314
- }
315
-
316
- return errors ;
317
- } ;
318
-
319
258
// Determine if we should show the secrets tab and config tab
320
259
const hasSecrets = assignedSecrets . length > 0 ;
321
260
const hasConfig = catalogItem . config && catalogItem . config . length > 0 ;
@@ -408,14 +347,15 @@ const ConfigurationModal = ({
408
347
< ConfigEditor catalogItem = { catalogItem } />
409
348
< Typography variant = "h6" sx = { { mb : 1 } } > Secrets</ Typography >
410
349
{ assignedSecrets ?. map ( secret => {
411
- const secretEdited = secret . assigned ? localSecrets [ secret . name ] !== ASSIGNED_SECRET_PLACEHOLDER : localSecrets [ secret . name ] !== UNASSIGNED_SECRET_PLACEHOLDER ;
350
+ const secretEdited = secret . assigned ? localSecrets [ secret . name ] !== ASSIGNED_SECRET_PLACEHOLDER : localSecrets [ secret . name ] !== '' ;
412
351
return (
413
352
< Stack key = { secret . name } direction = "row" spacing = { 2 } alignItems = "center" >
414
353
< TextField key = { secret . name } label = { secret . name } value = { localSecrets [ secret . name ] } fullWidth onChange = { ( e ) => {
415
354
setLocalSecrets ( { ...localSecrets , [ secret . name ] : e . target . value } ) ;
416
355
} } type = 'password' />
417
- { ! secretEdited && < IconButton size = "small" color = "error" onClick = { ( ) => {
356
+ { secret . assigned && ! secretEdited && < IconButton size = "small" color = "error" onClick = { ( ) => {
418
357
setLocalSecrets ( { ...localSecrets , [ secret . name ] : UNASSIGNED_SECRET_PLACEHOLDER } ) ;
358
+ onSecretChange ( { name : secret . name , value : UNASSIGNED_SECRET_PLACEHOLDER } ) ;
419
359
} } >
420
360
< DeleteOutlined />
421
361
</ IconButton > }
@@ -426,7 +366,7 @@ const ConfigurationModal = ({
426
366
< CheckOutlined sx = { { color : 'success.main' } } />
427
367
</ IconButton >
428
368
< IconButton onClick = { async ( ) => {
429
- setLocalSecrets ( { ...localSecrets , [ secret . name ] : secret . assigned ? UNASSIGNED_SECRET_PLACEHOLDER : ASSIGNED_SECRET_PLACEHOLDER } ) ;
369
+ setLocalSecrets ( { ...localSecrets , [ secret . name ] : secret . assigned ? ASSIGNED_SECRET_PLACEHOLDER : '' } ) ;
430
370
} } >
431
371
< CloseOutlined sx = { { color : 'error.main' } } />
432
372
</ IconButton >
0 commit comments