@@ -348,22 +348,34 @@ const ConfigurationLayout = (): React.JSX.Element => {
348348 // Fetch the target version's config to check use_bda flag
349349 const targetConfig = await fetchVersion ( versionName ) ;
350350
351- // Parse configs if they're JSON strings
351+ // Parse configs if they're JSON strings (same logic as handleCompareVersions)
352+ let schemaObj = targetConfig . schema ;
352353 let targetDefaultConfig = targetConfig . default ;
353354 let targetCustomConfig = targetConfig . custom ;
354355
356+ // Parse schema if it's a string
357+ if ( typeof targetConfig . schema === 'string' ) {
358+ schemaObj = parseConfigurationData ( targetConfig . schema ) ;
359+ }
360+
361+ // Unwrap nested Schema object if present
362+ if ( schemaObj && ( schemaObj as Record < string , unknown > ) . Schema ) {
363+ schemaObj = ( schemaObj as Record < string , unknown > ) . Schema ;
364+ }
365+
355366 if ( typeof targetDefaultConfig === 'string' ) {
356367 targetDefaultConfig = JSON . parse ( targetDefaultConfig ) ;
357368 }
358369 if ( typeof targetCustomConfig === 'string' ) {
359370 targetCustomConfig = JSON . parse ( targetCustomConfig ) ;
360371 }
361372
362- // Merge default and custom configs (custom overrides default)
363- const targetMergedConfig : Record < string , unknown > =
364- targetDefaultConfig && targetCustomConfig
365- ? { ...targetDefaultConfig , ...targetCustomConfig }
366- : ( ( targetCustomConfig || targetDefaultConfig || { } ) as Record < string , unknown > ) ;
373+ // Normalize boolean values (same as handleCompareVersions)
374+ const normalizedDefaultObj = normalizeBooleans ( targetDefaultConfig as Record < string , unknown > , schemaObj as ConfigSchema ) ;
375+ const normalizedCustomObj = normalizeBooleans ( targetCustomConfig as Record < string , unknown > , schemaObj as ConfigSchema ) ;
376+
377+ // Merge default and custom configs using deepMerge (same as handleCompareVersions)
378+ const targetMergedConfig : Record < string , unknown > = deepMerge ( normalizedDefaultObj ?? { } , normalizedCustomObj ?? { } ) ;
367379
368380 targetHasBda = ( targetMergedConfig . use_bda as boolean ) === true ;
369381 } catch ( err ) {
@@ -410,16 +422,29 @@ const ConfigurationLayout = (): React.JSX.Element => {
410422 }
411423
412424 try {
413- // First sync to BDA
414- await handleSyncBdaIdp ( 'idp_to_bda' ) ;
425+ // Check if the target version already has a BDA project
426+ const targetVersionData = versions . find ( ( v ) => v . versionName === versionName ) ;
427+ const hadBdaProject = targetVersionData ?. bdaProjectArn ;
428+
429+ // Show creating status if this is a new BDA project
430+ if ( ! hadBdaProject ) {
431+ setBdaProjectCreating ( true ) ;
432+ }
433+
434+ // First sync to BDA - pass the target version being activated, not the currently selected one
435+ await handleSyncBdaIdp ( 'idp_to_bda' , undefined , 'replace' , versionName ) ;
415436 logger . debug ( `Synced to BDA before activating version ${ versionName } ` ) ;
416437
417438 // Then activate the version (but don't sync again since we just did)
418439 await setActiveVersion ( versionName ) ;
419440 await new Promise ( ( resolve ) => setTimeout ( resolve , 500 ) ) ;
420441 setSelectedVersion ( versionName ) ;
442+
443+ // Clear creating status
444+ setBdaProjectCreating ( false ) ;
421445 } catch ( err ) {
422446 console . error ( 'Failed to sync and activate version:' , err ) ;
447+ setBdaProjectCreating ( false ) ;
423448 }
424449 } ;
425450
@@ -522,6 +547,7 @@ const ConfigurationLayout = (): React.JSX.Element => {
522547 const [ syncSuccess , setSyncSuccess ] = useState ( false ) ;
523548 const [ syncSuccessMessage , setSyncSuccessMessage ] = useState ( '' ) ;
524549 const [ syncError , setSyncError ] = useState < string | null > ( null ) ;
550+ const [ bdaProjectCreating , setBdaProjectCreating ] = useState ( false ) ; // Track if BDA project is being created
525551 const [ showSyncToBdaConfirmModal , setShowSyncToBdaConfirmModal ] = useState ( false ) ;
526552 const [ showActivateVersionConfirmModal , setShowActivateVersionConfirmModal ] = useState ( false ) ;
527553 const [ activateVersionTarget , setActivateVersionTarget ] = useState < string | null > ( null ) ; // Track which version to activate
@@ -1575,7 +1601,12 @@ const ConfigurationLayout = (): React.JSX.Element => {
15751601 } ;
15761602
15771603 // Handler for BDA/IDP sync with direction support and optional BDA project ARN
1578- const handleSyncBdaIdp = async ( direction = 'bidirectional' , bdaProjectArn ?: string , syncMode = 'replace' ) : Promise < void > => {
1604+ const handleSyncBdaIdp = async (
1605+ direction = 'bidirectional' ,
1606+ bdaProjectArn ?: string ,
1607+ syncMode = 'replace' ,
1608+ versionName ?: string ,
1609+ ) : Promise < void > => {
15791610 setSyncingDirection ( direction ) ;
15801611 setSyncSuccess ( false ) ;
15811612 setSyncSuccessMessage ( '' ) ;
@@ -1584,9 +1615,18 @@ const ConfigurationLayout = (): React.JSX.Element => {
15841615 try {
15851616 logger . debug ( `Starting BDA/IDP sync with direction: ${ direction } , mode: ${ syncMode } , bdaProjectArn: ${ bdaProjectArn || 'auto' } ...` ) ;
15861617
1618+ // Check if BDA project ARN exists before syncing (for new projects)
1619+ const hadBdaProject = currentVersion ?. bdaProjectArn ;
1620+
1621+ // If syncing to BDA and no project existed, show creating status BEFORE the sync call
1622+ // This provides user feedback while waiting for backend to create and save ARN
1623+ if ( direction === 'idp_to_bda' && ! hadBdaProject ) {
1624+ setBdaProjectCreating ( true ) ;
1625+ }
1626+
15871627 // Build variables - always pass saveArn: true to persist the project ARN
15881628 const variables : Record < string , unknown > = {
1589- versionName : currentVersionName ,
1629+ versionName : versionName || currentVersionName ,
15901630 direction,
15911631 syncMode,
15921632 saveArn : true ,
@@ -1626,11 +1666,18 @@ const ConfigurationLayout = (): React.JSX.Element => {
16261666 }
16271667
16281668 // Refresh configuration to show any new classes
1629- await fetchConfiguration ( currentVersionName ) ;
1669+ await fetchConfiguration ( versionName || currentVersionName ) ;
16301670
16311671 // Refresh versions list to update BDA project ARN metadata
16321672 await fetchVersions ( ) ;
16331673
1674+ // If we showed creating status, keep it visible for a moment then clear
1675+ if ( direction === 'idp_to_bda' && ! hadBdaProject ) {
1676+ // Small delay to ensure state updates complete and user sees the status
1677+ await new Promise ( ( resolve ) => setTimeout ( resolve , 1000 ) ) ;
1678+ setBdaProjectCreating ( false ) ;
1679+ }
1680+
16341681 // Only auto-dismiss if there are no warnings in the message
16351682 // Warnings indicate BDA limitations that users should read
16361683 const hasWarnings = response . message ?. includes ( 'WARNING' ) ;
@@ -1644,11 +1691,13 @@ const ConfigurationLayout = (): React.JSX.Element => {
16441691 } else {
16451692 const errorMsg = String ( response ?. error ?. message || response ?. message || 'Sync operation failed' ) ;
16461693 setSyncError ( errorMsg ) ;
1694+ setBdaProjectCreating ( false ) ; // Clear creating status on error
16471695 logger . error ( 'Sync failed:' , errorMsg ) ;
16481696 }
16491697 } catch ( err ) {
16501698 logger . error ( 'Sync error:' , err ) ;
16511699 setSyncError ( `Sync failed: ${ ( err as Error ) . message } ` ) ;
1700+ setBdaProjectCreating ( false ) ; // Clear creating status on error
16521701 } finally {
16531702 setSyncingDirection ( null ) ;
16541703 }
@@ -2437,7 +2486,14 @@ const ConfigurationLayout = (): React.JSX.Element => {
24372486 { /* BDA Project Status Banner */ }
24382487 { Boolean ( isPattern1 || mergedConfig ?. use_bda || formValues ?. use_bda ) && currentVersion && (
24392488 < >
2440- { currentVersion . bdaProjectArn ? (
2489+ { bdaProjectCreating ? (
2490+ < Alert type = "info" header = "BDA Project Creation In Progress" >
2491+ < Box variant = "p" >
2492+ < Spinner size = "normal" /> Creating BDA project and syncing blueprints... This may take a few moments. The project ARN
2493+ will appear once creation is complete.
2494+ </ Box >
2495+ </ Alert >
2496+ ) : currentVersion . bdaProjectArn ? (
24412497 < Alert
24422498 type = { currentVersion . bdaSyncStatus === 'needs-sync' ? 'warning' : 'info' }
24432499 header = { currentVersion . bdaSyncStatus === 'needs-sync' ? 'BDA Project Linked — Sync Required' : 'BDA Project Linked' }
0 commit comments