@@ -484,64 +484,38 @@ export function createProjectHeader(projectTitle, products, isCollapsable = fals
484484 return projectHeader ;
485485}
486486
487- const CREDENTIAL_FIELD_META = {
488- APIKey : { dataField : 'apiKey' , showCopy : true } ,
489- AllowedOrigins : { dataField : 'allowedOrigins' , showCopy : true } ,
490- OrganizationName : { dataField : 'organization' , showCopy : false } ,
491- ClientId : { dataField : 'clientId' , showCopy : true } ,
492- Scopes : { dataField : 'scopes' , showCopy : true } ,
493- ClientSecret : { dataField : 'clientSecret' , showCopy : false } ,
494- ImsOrgID : { dataField : 'imsOrgId' , showCopy : true } ,
495- } ;
496-
497487export function createCredentialSection ( config ) {
498488 const credentialSection = createTag ( 'div' , { class : 'credential-section' } ) ;
499489 const credentialTitle = createTag ( 'h3' , { class : 'spectrum-Heading spectrum-Heading--sizeS' } ) ;
500490 credentialTitle . textContent = config . heading ;
501491 credentialSection . appendChild ( credentialTitle ) ;
502492
503- const components = config . components || { } ;
504- const orderBy = config . orderBy ? config . orderBy . split ( ',' ) . map ( s => s . trim ( ) ) : null ;
505- const keysToRender = orderBy && orderBy . length > 0
506- ? orderBy . filter ( k => components [ k ] )
507- : Object . keys ( components ) ;
508-
509- keysToRender . forEach ( ( key ) => {
510- const comp = components [ key ] ;
511- if ( ! comp ?. heading ) return ;
512- const meta = CREDENTIAL_FIELD_META [ key ] || { dataField : key , showCopy : true } ;
513-
514- if ( comp . buttonLabel ) {
515- const secretField = createTag ( 'div' , { class : 'credential-detail-field credential-detail-field--action' } ) ;
516- const secretLabel = createTag ( 'label' , { class : 'credential-detail-label spectrum-Body spectrum-Body--sizeS' } ) ;
517- secretLabel . textContent = comp . heading ;
518- secretField . appendChild ( secretLabel ) ;
519- const secretBtn = createTag ( 'button' , { type : 'button' , class : 'spectrum-Button spectrum-Button--outline spectrum-Button--secondary spectrum-Button--sizeM retrieve-secret-button' , 'data-field' : meta . dataField } ) ;
520- secretBtn . textContent = comp . buttonLabel ;
521- secretField . appendChild ( secretBtn ) ;
522- credentialSection . appendChild ( secretField ) ;
523- return ;
524- }
493+ const components = config . components ;
494+ if ( components ?. APIKey ) {
495+ credentialSection . appendChild ( createCredentialDetailField (
496+ components . APIKey . heading ,
497+ components . APIKey . value || '' ,
498+ true ,
499+ 'apiKey' // Add fieldName for dynamic updates
500+ ) ) ;
501+ }
525502
526- const value = comp . value ?? ( comp . scope || '' ) ;
503+ if ( components ?. AllowedOrigins ) {
527504 credentialSection . appendChild ( createCredentialDetailField (
528- comp . heading ,
529- value ,
530- meta . showCopy ,
531- meta . dataField
505+ components . AllowedOrigins . heading ,
506+ components . AllowedOrigins . value || '' ,
507+ true ,
508+ 'allowedOrigins' // Add fieldName for dynamic updates
532509 ) ) ;
533- } ) ;
510+ }
534511
535- if ( keysToRender . length === 0 ) {
536- if ( components . APIKey ) {
537- credentialSection . appendChild ( createCredentialDetailField ( components . APIKey . heading , components . APIKey . value || '' , true , 'apiKey' ) ) ;
538- }
539- if ( components . AllowedOrigins ) {
540- credentialSection . appendChild ( createCredentialDetailField ( components . AllowedOrigins . heading , components . AllowedOrigins . value || '' , true , 'allowedOrigins' ) ) ;
541- }
542- if ( components . OrganizationName ) {
543- credentialSection . appendChild ( createCredentialDetailField ( components . OrganizationName . heading , components . OrganizationName . value || '' , false , 'organization' ) ) ;
544- }
512+ if ( components ?. OrganizationName ) {
513+ credentialSection . appendChild ( createCredentialDetailField (
514+ components . OrganizationName . heading ,
515+ components . OrganizationName . value || '' ,
516+ false ,
517+ 'organization' // Add fieldName for dynamic updates
518+ ) ) ;
545519 }
546520
547521 return credentialSection ;
0 commit comments