diff --git a/api/src/services/migration.service.ts b/api/src/services/migration.service.ts index 84c182f39..9c74fbf25 100644 --- a/api/src/services/migration.service.ts +++ b/api/src/services/migration.service.ts @@ -66,7 +66,7 @@ const createTestStack = async (req: Request): Promise => { .get("projects") .findIndex({ id: projectId }) .value(); - console.log(index); + if (index > -1) { ProjectModelLowdb.update((data: any) => { data.projects[index].current_test_stack_id = res.data.stack.uid; @@ -143,7 +143,7 @@ const deleteTestStack = async (req: Request): Promise => { .get("projects") .findIndex({ id: projectId }) .value(); - console.log(index); + if (index > -1) { ProjectModelLowdb.update((data: any) => { data.projects[index].current_test_stack_id = ""; diff --git a/api/src/services/projects.service.ts b/api/src/services/projects.service.ts index d4ce46625..d80ce40df 100644 --- a/api/src/services/projects.service.ts +++ b/api/src/services/projects.service.ts @@ -240,16 +240,16 @@ const updateLegacyCMS = async (req: Request) => { throw new BadRequestError(HTTP_TEXTS.CANNOT_UPDATE_LEGACY_CMS); } - if (project.current_step > STEPPER_STEPS.LEGACY_CMS) { - contentMapperService.removeMapping(projectId); - logger.info( - getLogMessage( - srcFunc, - `Content Mapping for project [Id : ${projectId}] has been successfully removed.`, - token_payload - ) - ); - } + // if (project.current_step > STEPPER_STEPS.LEGACY_CMS) { + // await contentMapperService.removeMapping(projectId); + // logger.info( + // getLogMessage( + // srcFunc, + // `Content Mapping for project [Id : ${projectId}] has been successfully removed.`, + // token_payload + // ) + // ); + // } try { ProjectModelLowdb.update((data: any) => { @@ -383,16 +383,16 @@ const updateFileFormat = async (req: Request) => { throw new BadRequestError(HTTP_TEXTS.CANNOT_UPDATE_FILE_FORMAT); } - if (project.current_step > STEPPER_STEPS.LEGACY_CMS) { - contentMapperService.removeMapping(projectId); - logger.info( - getLogMessage( - srcFunc, - `Content Mapping for project [Id : ${projectId}] has been successfully removed.`, - token_payload - ) - ); - } + // if (project.current_step > STEPPER_STEPS.LEGACY_CMS) { + // await contentMapperService.removeMapping(projectId); + // logger.info( + // getLogMessage( + // srcFunc, + // `Content Mapping for project [Id : ${projectId}] has been successfully removed.`, + // token_payload + // ) + // ); + // } try { ProjectModelLowdb.update((data: any) => { @@ -507,16 +507,16 @@ const updateDestinationStack = async (req: Request) => { ); throw new BadRequestError(HTTP_TEXTS.CANNOT_UPDATE_DESTINATION_STACK); } - if (project.current_step > STEPPER_STEPS.DESTINATION_STACK) { - await contentMapperService.resetAllContentTypesMapping(projectId); - logger.info( - getLogMessage( - srcFunc, - `Content Mapping for project [Id : ${projectId}] has been successfully reset.`, - token_payload - ) - ); - } + // if (project.current_step > STEPPER_STEPS.DESTINATION_STACK) { + // await contentMapperService.resetAllContentTypesMapping(projectId); + // logger.info( + // getLogMessage( + // srcFunc, + // `Content Mapping for project [Id : ${projectId}] has been successfully reset.`, + // token_payload + // ) + // ); + // } try { const [err, res] = await safePromise( https({ @@ -760,7 +760,7 @@ const deleteProject = async (req: Request) => { }; const revertProject = async (req: Request) => { - const { orgId, projectId } = req?.params; + const { orgId, projectId } = req.params; const decodedToken = req.body.token_payload; const { user_id = "", region = "" } = decodedToken; const srcFunc = "revertProject"; diff --git a/ui/src/components/LegacyCms/Actions/LoadPrefix.tsx b/ui/src/components/LegacyCms/Actions/LoadPrefix.tsx index 156c00b2e..af7c68a3a 100644 --- a/ui/src/components/LegacyCms/Actions/LoadPrefix.tsx +++ b/ui/src/components/LegacyCms/Actions/LoadPrefix.tsx @@ -98,7 +98,7 @@ const LoadPreFix = (props: LoadSelectCmsProps) => { } else if (!isValidPrefix(value)) { setIsRestrictedKey(false); setIsError(true); - setErrorMessage('Affix should not contain more than 5 characters or fewer than 2.'); + setErrorMessage('Affix should be 2 to 5 alphabetic characters'); } else { setPrefix(value); setIsError(false); diff --git a/ui/src/components/LegacyCms/Actions/LoadUploadFile.tsx b/ui/src/components/LegacyCms/Actions/LoadUploadFile.tsx index 79d2362fe..c9ec7b9ad 100644 --- a/ui/src/components/LegacyCms/Actions/LoadUploadFile.tsx +++ b/ui/src/components/LegacyCms/Actions/LoadUploadFile.tsx @@ -21,7 +21,7 @@ interface Props { fileDetails: FileDetails; } -const FileComponent = ({fileDetails}:Props ) => { +const FileComponent = ({fileDetails}:Props ) => { return (
@@ -120,7 +120,7 @@ const LoadUploadFile = (props: LoadUploadFileProps) => { setIsValidated(true); setValidationMessage('Validation is successful'); - if(! isEmptyString(newMigrationData?.legacy_cms?.affix) || ! isEmptyString(newMigrationData?.legacy_cms?.selectedCms?.cms_id) || ! isEmptyString(newMigrationData?.legacy_cms?.selectedFileFormat?.fileformat_id)){ + if(! isEmptyString(newMigrationData?.legacy_cms?.affix) && ! isEmptyString(newMigrationData?.legacy_cms?.selectedCms?.cms_id) && ! isEmptyString(newMigrationData?.legacy_cms?.selectedFileFormat?.fileformat_id)){ props.handleStepChange(props?.currentStep, true); } @@ -346,7 +346,7 @@ const LoadUploadFile = (props: LoadUploadFileProps) => { const validationClassName = isValidated ? 'success' : 'error'; const containerClassName = `validation-container ${isValidationAttempted && !isValidated ? 'error-container pb-2' : ''}`; - + return (
diff --git a/ui/src/components/LegacyCms/index.tsx b/ui/src/components/LegacyCms/index.tsx index 6be6040bb..f40ece6c5 100644 --- a/ui/src/components/LegacyCms/index.tsx +++ b/ui/src/components/LegacyCms/index.tsx @@ -228,10 +228,8 @@ const LegacyCMSComponent = forwardRef(({ legacyCMSData, projectData, isCompleted if (!isEmptyString(newMigrationData?.legacy_cms?.selectedCms?.cms_id) && !isEmptyString(newMigrationData?.legacy_cms?.affix)) { setInternalActiveStepIndex(1); } - if(!isEmptyString(newMigrationData?.legacy_cms?.selectedCms?.cms_id) && !isEmptyString(newMigrationData?.legacy_cms?.affix) && ! isEmptyString(newMigrationData?.legacy_cms?.selectedFileFormat?.fileformat_id)){ - setInternalActiveStepIndex(2); - } - if(!isEmptyString(newMigrationData?.legacy_cms?.selectedCms?.cms_id) && !isEmptyString(newMigrationData?.legacy_cms?.affix) && ! isEmptyString(newMigrationData?.legacy_cms?.selectedFileFormat?.fileformat_id) && newMigrationData?.legacy_cms?.uploadedFile?.isValidated){ + + if(!isEmptyString(newMigrationData?.legacy_cms?.selectedCms?.cms_id) && !isEmptyString(newMigrationData?.legacy_cms?.affix) && newMigrationData?.legacy_cms?.uploadedFile?.isValidated){ setInternalActiveStepIndex(3); } diff --git a/ui/src/pages/Migration/index.tsx b/ui/src/pages/Migration/index.tsx index e88129129..b1198609b 100644 --- a/ui/src/pages/Migration/index.tsx +++ b/ui/src/pages/Migration/index.tsx @@ -201,8 +201,7 @@ const Migration = () => { setIsLoading(false); if (legacyCMSRef.current) { - const currentIndex = legacyCMSRef.current.getInternalActiveStepIndex() + 1; - + const currentIndex = legacyCMSRef.current.getInternalActiveStepIndex() + 1; let result; switch (currentIndex ) { case 0: @@ -212,19 +211,15 @@ const Migration = () => { result = 'Enter Affix'; break; case 2: - result = 'File Format'; - break; - case 3: result = 'Imported File'; break; - default: - result = 'all'; - break; } - Notification({ - notificationContent: { text: `Please complete ${result} step` }, - type: 'warning' - }); + if (currentIndex !== 3) { + Notification({ + notificationContent: { text: `Please complete ${result} step` }, + type: 'warning' + }); + } } } diff --git a/uplaode-api/.env b/uplaode-api/.env index 5f3a84b6c..2c50b6496 100644 --- a/uplaode-api/.env +++ b/uplaode-api/.env @@ -1,2 +1,2 @@ PORT=4002 -NODE_BACKEND_API =http://localhost:5000 \ No newline at end of file +NODE_BACKEND_API =http://localhost:5001 \ No newline at end of file diff --git a/uplaode-api/src/routes/index.ts b/uplaode-api/src/routes/index.ts index b66241dbb..dadc2e18f 100644 --- a/uplaode-api/src/routes/index.ts +++ b/uplaode-api/src/routes/index.ts @@ -133,7 +133,7 @@ router.get('/validator', express.json(), fileOperationLimiter, async function (r throw new Error('No data collected from the stream.'); } const data = await handleFileProcessing(fileExt, zipBuffer, cmsType); - res.json(data); + res.status(data?.status || 200).json(data); if (data?.status === 200) { const filePath = path.join(__dirname, '../../extracted_files', name); createSitecoreMapper(filePath, projectId, app_token) diff --git a/uplaode-api/src/services/fileProcessing.ts b/uplaode-api/src/services/fileProcessing.ts index 93ca524e8..4a92b700b 100644 --- a/uplaode-api/src/services/fileProcessing.ts +++ b/uplaode-api/src/services/fileProcessing.ts @@ -10,7 +10,7 @@ const handleFileProcessing = async (fileExt: string, zipBuffer: any, cmsType: st if (fileExt === 'zip') { const zip = new JSZip(); await zip.loadAsync(zipBuffer); - if (validator({ data: zip, type: cmsType, extension: fileExt })) { + if (await validator({ data: zip, type: cmsType, extension: fileExt })) { const isSaved = await saveZip(zip); if (isSaved) { logger.info('Validation success:', { @@ -38,7 +38,7 @@ const handleFileProcessing = async (fileExt: string, zipBuffer: any, cmsType: st // if file is not zip // Convert the buffer to a string assuming it's UTF-8 encoded const jsonString = Buffer?.from?.(zipBuffer)?.toString?.('utf8'); - if (validator({ data: jsonString, type: cmsType, extension: fileExt })) { + if (await validator({ data: jsonString, type: cmsType, extension: fileExt })) { logger.info('Validation success:', { status: HTTP_CODES?.OK, message: HTTP_TEXTS?.VALIDATION_SUCCESSFULL, diff --git a/uplaode-api/src/validators/sitecore/index.ts b/uplaode-api/src/validators/sitecore/index.ts index 870e868d8..551c50e6f 100644 --- a/uplaode-api/src/validators/sitecore/index.ts +++ b/uplaode-api/src/validators/sitecore/index.ts @@ -16,29 +16,30 @@ async function sitecoreValidator({ data }: props) { const configuration: any[] = []; let blob: any[] = []; let mediaLibrary: any[] = []; - Object.keys(data?.files).forEach(async function (filename: any) { - if (await filename?.includes?.('/templates')) { - templates?.push(await filename); + for (const filename of Object.keys(data?.files)) { + if (filename.includes('/templates') && !filename.includes('properties/items/master/sitecore/templates')) { + templates?.push(filename); } - if (await filename?.includes?.('/content')) { - content?.push(await filename); + if (filename.includes('/content')) { + content?.push(filename); } - //optional - if (await filename?.includes?.('/Configuration')) { - configuration?.push(await filename); + // optional + if (filename.includes('/Configuration')) { + configuration.push(filename); } - if (await filename?.includes?.('/Blob')) { - blob?.push(await filename); + if (filename?.includes('/blob')) { + blob?.push(filename); } - if (await filename?.includes?.('/media library')) { - mediaLibrary?.push(await filename); + if (filename?.includes('/media library')) { + mediaLibrary?.push(filename); } - }); + } templates = await Promise.all(templates); content = await Promise.all(content); blob = await Promise.all(blob); mediaLibrary = await Promise.all(mediaLibrary); - if (templates?.length > 0 && content?.length > 0 && blob?.length > 0 && mediaLibrary?.length > 0) { + + if (templates?.length > 0 && content?.length > 0 && blob?.length > 0 && mediaLibrary?.length > 0) { return true; } return false;