diff --git a/ui/src/components/LegacyCms/Actions/LoadUploadFile.tsx b/ui/src/components/LegacyCms/Actions/LoadUploadFile.tsx index f191dd5b0..6008eba64 100644 --- a/ui/src/components/LegacyCms/Actions/LoadUploadFile.tsx +++ b/ui/src/components/LegacyCms/Actions/LoadUploadFile.tsx @@ -57,11 +57,11 @@ const FileComponent = ( { fileDetails, fileFormatId }: Props ) =>
{ isSQL ? ( // ✅ SQL format (from legacyCms.json allowed_file_formats): show MySQL details - fileDetails?.mySQLDetails && ( + fileDetails?.mysql && (
-

Host: { fileDetails?.mySQLDetails?.host }

-

Database: { fileDetails?.mySQLDetails?.database }

-

User: { fileDetails?.mySQLDetails?.user }

+

Host: { fileDetails?.mysql?.host }

+

Database: { fileDetails?.mysql?.database }

+

User: { fileDetails?.mysql?.user }

) ) : fileDetails?.isLocalPath ? ( @@ -176,11 +176,11 @@ const LoadUploadFile = ( props: LoadUploadFileProps ) => bucketName: responseFileDetails?.awsData?.bucketName, bucketKey: responseFileDetails?.awsData?.bucketKey }, - mySQLDetails: { - host: responseFileDetails?.mySQLDetails?.host, - user: responseFileDetails?.mySQLDetails?.user, - database: responseFileDetails?.mySQLDetails?.database, - port: responseFileDetails?.mySQLDetails?.port + mysql: { + host: responseFileDetails?.mysql?.host, + user: responseFileDetails?.mysql?.user, + database: responseFileDetails?.mysql?.database, + port: responseFileDetails?.mysql?.port }, assetsConfig: { base_url: responseFileDetails?.assetsConfig?.base_url, @@ -206,7 +206,7 @@ const LoadUploadFile = ( props: LoadUploadFileProps ) => // Update the ref immediately before dispatching to avoid stale data in subsequent operations newMigrationDataRef.current = newMigrationDataObj; - dispatch( updateNewMigrationData( newMigrationDataObj ) ); + // Derive SQL check from selectedFileFormat (data-driven via legacyCms.json) const currentFormatId = newMigrationDataObj?.legacy_cms?.selectedFileFormat?.fileformat_id?.toLowerCase(); @@ -295,6 +295,7 @@ const LoadUploadFile = ( props: LoadUploadFileProps ) => setProcessing( 'Processing...100%' ); await new Promise( ( resolve ) => setTimeout( resolve, 1000 ) ); + dispatch( updateNewMigrationData( newMigrationDataObj ) ); setTimeout( () => { @@ -437,24 +438,11 @@ const LoadUploadFile = ( props: LoadUploadFileProps ) => } }; - // Update fileDetails whenever Redux state changes - useEffect( () => - { - const latestFileDetails = newMigrationData?.legacy_cms?.uploadedFile?.file_details; - - // Always update fileDetails from Redux, even if it's empty (to clear stale data) - setFileDetails( latestFileDetails ); - - }, [ newMigrationData?.legacy_cms?.uploadedFile?.file_details ] ); useEffect( () => { getConfigDetails(); - }, [ - // Re-run when selectedFileFormat or file_details change (e.g., after LoadSelectCms or fetchProjectData dispatches) - newMigrationData?.legacy_cms?.selectedFileFormat?.fileformat_id, - newMigrationData?.legacy_cms?.uploadedFile?.file_details?.localPath - ] ); + }, [] ); useEffect( () => { diff --git a/ui/src/context/app/app.interface.ts b/ui/src/context/app/app.interface.ts index 543b6e771..80ef579fd 100644 --- a/ui/src/context/app/app.interface.ts +++ b/ui/src/context/app/app.interface.ts @@ -56,7 +56,7 @@ export interface FileDetails { bucketName?: string; bucketKey?: string; }; - mySQLDetails?: { + mysql?: { host?: string; user?: string; database?: string; diff --git a/ui/src/pages/Migration/index.tsx b/ui/src/pages/Migration/index.tsx index 4c430aab8..9c019071b 100644 --- a/ui/src/pages/Migration/index.tsx +++ b/ui/src/pages/Migration/index.tsx @@ -275,6 +275,16 @@ const Migration = () => { awsRegion: data?.awsData?.awsRegion, bucketName: data?.awsData?.bucketName, bucketKey: data?.awsData?.bucketKey + }, + mysql: { + host: data?.mysql?.host, + user: data?.mysql?.user, + database: data?.mysql?.database, + port: data?.mysql?.port + }, + assetsConfig: { + base_url: data?.assetsConfig?.base_url, + public_path: data?.assetsConfig?.public_path } }, cmsType: data?.cmsType @@ -382,7 +392,17 @@ const Migration = () => { bucketName: projectData?.legacy_cms?.awsDetails?.bucketName, bucketKey: projectData?.legacy_cms?.awsDetails?.bucketKey }, - isLocalPath: projectData?.legacy_cms?.is_localPath + isLocalPath: projectData?.legacy_cms?.is_localPath, + mysql: { + host: projectData?.legacy_cms?.myql?.host, + user: projectData?.legacy_cms?.mysql?.user, + database: projectData?.legacy_cms?.mysql?.database, + port: projectData?.legacy_cms?.mysql?.port + }, + assetsConfig: { + base_url: projectData?.legacy_cms?.assetsConfig?.base_url, + public_path: projectData?.legacy_cms?.assetsConfig?.public_path + } }, isValidated: projectData?.legacy_cms?.is_fileValid, reValidate: newMigrationData?.legacy_cms?.uploadedFile?.reValidate, @@ -400,7 +420,17 @@ const Migration = () => { awsRegion: uploadObj?.file_details?.awsData?.awsRegion || newMigrationDataRef?.current?.legacy_cms?.uploadedFile?.file_details?.awsData?.awsRegion, bucketName: uploadObj?.file_details?.awsData?.bucketName || newMigrationDataRef?.current?.legacy_cms?.uploadedFile?.file_details?.awsData?.bucketName, bucketKey: uploadObj?.file_details?.awsData?.bucketKey || newMigrationDataRef?.current?.legacy_cms?.uploadedFile?.file_details?.awsData?.bucketKey, - } + }, + mysql: { + host: uploadObj?.file_details?.mysql?.host || newMigrationDataRef?.current?.legacy_cms?.uploadedFile?.file_details?.mysql?.host, + user: uploadObj?.file_details?.mysql?.user || newMigrationDataRef?.current?.legacy_cms?.uploadedFile?.file_details?.mysql?.user, + database: uploadObj?.file_details?.mysql?.database || newMigrationDataRef?.current?.legacy_cms?.uploadedFile?.file_details?.mysql?.database, + port: uploadObj?.file_details?.mysql?.port || newMigrationDataRef?.current?.legacy_cms?.uploadedFile?.file_details?.mysql?.port, + }, + assetsConfig: { + base_url: uploadObj?.file_details?.assetsConfig?.base_url || newMigrationDataRef?.current?.legacy_cms?.uploadedFile?.file_details?.assetsConfig?.base_url, + public_path: uploadObj?.file_details?.assetsConfig?.public_path || newMigrationDataRef?.current?.legacy_cms?.uploadedFile?.file_details?.assetsConfig?.public_path, + } } }, isFileFormatCheckboxChecked: true,