@@ -10,7 +10,7 @@ import { deepFlattenObject, deepGet, deepSet, mergeDeep } from "../../MergeDeep"
1010import { DeepObject } from "../../types/utils" ;
1111import { Parameter , ParameterArray , ParameterObject , Parameters , ParsedParameters , Config } from "../../types/config" ;
1212import { Ref } from "../../Refs" ;
13- import { CATALOG_LAYOUT_SX } from "../../Constants" ;
13+ import { ASSIGNED_SECRET_PLACEHOLDER , CATALOG_LAYOUT_SX , UNASSIGNED_SECRET_PLACEHOLDER } from "../../Constants" ;
1414import JsonSchemaLibrary from "json-schema-library" ;
1515import ConfigEditor from "./ConfigEditor" ;
1616
@@ -57,8 +57,6 @@ interface ConfigurationModalProps {
5757 onSecretChange : ( secret : { name : string , value : string } ) => Promise < void > ;
5858}
5959
60- const ASSIGNED_SECRET_PLACEHOLDER = '********' ;
61- const UNASSIGNED_SECRET_PLACEHOLDER = '' ;
6260
6361const ConfigurationModal = ( {
6462 open,
@@ -71,7 +69,7 @@ const ConfigurationModal = ({
7169} : ConfigurationModalProps ) => {
7270
7371 const { startPull, registryItems, secrets } = useCatalogContext ( ) ;
74- const { config, configLoading, saveConfig } = useConfigContext ( ) ;
72+ const { config, configLoading } = useConfigContext ( ) ;
7573 const [ localSecrets , setLocalSecrets ] = useState < { [ key : string ] : string | undefined } > ( { } ) ;
7674 const [ localConfig , setLocalConfig ] = useState < { [ key : string ] : any } > ( { } ) ;
7775 const [ configTemplate , setConfigTemplate ] = useState < Record < string , any > > ( { } ) ;
@@ -190,7 +188,7 @@ const ConfigurationModal = ({
190188 const loadedSecrets = Secrets . getAssignedSecrets ( catalogItem , secrets ) ;
191189 setAssignedSecrets ( loadedSecrets ) ;
192190 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 : '' ;
194192 return acc ;
195193 } , { } as { [ key : string ] : string | undefined } ) ) ;
196194 } , [ catalogItem , secrets ] ) ;
@@ -257,65 +255,6 @@ const ConfigurationModal = ({
257255 return '' ;
258256 } ;
259257
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-
319258 // Determine if we should show the secrets tab and config tab
320259 const hasSecrets = assignedSecrets . length > 0 ;
321260 const hasConfig = catalogItem . config && catalogItem . config . length > 0 ;
@@ -408,14 +347,15 @@ const ConfigurationModal = ({
408347 < ConfigEditor catalogItem = { catalogItem } />
409348 < Typography variant = "h6" sx = { { mb : 1 } } > Secrets</ Typography >
410349 { 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 ] !== '' ;
412351 return (
413352 < Stack key = { secret . name } direction = "row" spacing = { 2 } alignItems = "center" >
414353 < TextField key = { secret . name } label = { secret . name } value = { localSecrets [ secret . name ] } fullWidth onChange = { ( e ) => {
415354 setLocalSecrets ( { ...localSecrets , [ secret . name ] : e . target . value } ) ;
416355 } } type = 'password' />
417- { ! secretEdited && < IconButton size = "small" color = "error" onClick = { ( ) => {
356+ { secret . assigned && ! secretEdited && < IconButton size = "small" color = "error" onClick = { ( ) => {
418357 setLocalSecrets ( { ...localSecrets , [ secret . name ] : UNASSIGNED_SECRET_PLACEHOLDER } ) ;
358+ onSecretChange ( { name : secret . name , value : UNASSIGNED_SECRET_PLACEHOLDER } ) ;
419359 } } >
420360 < DeleteOutlined />
421361 </ IconButton > }
@@ -426,7 +366,7 @@ const ConfigurationModal = ({
426366 < CheckOutlined sx = { { color : 'success.main' } } />
427367 </ IconButton >
428368 < 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 : '' } ) ;
430370 } } >
431371 < CloseOutlined sx = { { color : 'error.main' } } />
432372 </ IconButton >
0 commit comments