From b0ac49be2cbe7ee18c3ac4274a25ea7b6a9a2884 Mon Sep 17 00:00:00 2001 From: AishDani Date: Wed, 10 Jul 2024 15:49:19 +0530 Subject: [PATCH 1/2] refactor:resolved duplicate mapper fields --- ui/src/components/LegacyCms/Actions/LoadSelectCms.tsx | 8 ++++---- ui/src/components/LegacyCms/Actions/LoadUploadFile.tsx | 9 +++++++-- ui/src/components/LegacyCms/index.tsx | 5 +++-- ui/src/components/LegacyCms/legacyCms.scss | 8 ++++++++ uplaode-api/migration-sitecore/libs/contenttypes.js | 8 ++++---- 5 files changed, 26 insertions(+), 12 deletions(-) diff --git a/ui/src/components/LegacyCms/Actions/LoadSelectCms.tsx b/ui/src/components/LegacyCms/Actions/LoadSelectCms.tsx index 85d886927..ee1cb2602 100644 --- a/ui/src/components/LegacyCms/Actions/LoadSelectCms.tsx +++ b/ui/src/components/LegacyCms/Actions/LoadSelectCms.tsx @@ -56,7 +56,7 @@ const LoadSelectCms = (props: LoadSelectCmsProps) => { const [isLoading, setIsLoading] = useState(false); const { projectId = '' } = useParams(); - + /**** ALL METHODS HERE ****/ //Handle Legacy cms selection @@ -214,9 +214,9 @@ const LoadSelectCms = (props: LoadSelectCmsProps) => { : isLoading ? ( - <> - - +
+ +
) : (cmsData && validateArray(cmsData) && (
diff --git a/ui/src/components/LegacyCms/Actions/LoadUploadFile.tsx b/ui/src/components/LegacyCms/Actions/LoadUploadFile.tsx index dbe8f5799..d6a9fe2ab 100644 --- a/ui/src/components/LegacyCms/Actions/LoadUploadFile.tsx +++ b/ui/src/components/LegacyCms/Actions/LoadUploadFile.tsx @@ -84,12 +84,14 @@ const LoadUploadFile = (props: LoadUploadFileProps) => { //Handle further action on file is uploaded to server const handleOnFileUploadCompletion = async () => { + setValidationMessage(''); setIsLoading(true); setProgressPercentage(30); setShowProgress(true); setProcessing('Processing..30%') const res: any = await fileValidation(projectId); + setIsLoading(false); const newMigrationDataObj: INewMigration = { ...newMigrationData, @@ -161,7 +163,6 @@ const LoadUploadFile = (props: LoadUploadFileProps) => { }, projectId); setShowMessage(true); - setIsLoading(false); setProgressPercentage(100); setTimeout(() => { setProcessing('Processing ...100%') @@ -294,6 +295,7 @@ const LoadUploadFile = (props: LoadUploadFileProps) => { setProcessing(savedState.processing); } if (savedState && savedState.isLoading) { + handleOnFileUploadCompletion(); } },[]); @@ -372,7 +374,10 @@ const LoadUploadFile = (props: LoadUploadFileProps) => { ) : - } +
+ +
+ } {showMessage && ( <> diff --git a/ui/src/components/LegacyCms/index.tsx b/ui/src/components/LegacyCms/index.tsx index b2d7096e4..83f40928e 100644 --- a/ui/src/components/LegacyCms/index.tsx +++ b/ui/src/components/LegacyCms/index.tsx @@ -141,7 +141,7 @@ const LegacyCMSComponent = forwardRef(({ legacyCMSData, projectData, isCompleted //Update New Migration data; const selectedCmsData: ICMSType = validateArray(data.all_cms) - ? data.all_cms?.some((cms: ICMSType) => { + ? data.all_cms?.find((cms: ICMSType) => { return cms?.cms_id === legacyCMSData?.cms}) : DEFAULT_CMS_TYPE; @@ -174,7 +174,6 @@ const LegacyCMSComponent = forwardRef(({ legacyCMSData, projectData, isCompleted dispatch(updateNewMigrationData({ ...newMigrationData, legacy_cms: { - ...newMigrationData?.legacy_cms, currentStep: internalActiveStepIndex, selectedCms: selectedCmsData, selectedFileFormat: selectedFileFormatData || newMigrationData?.legacy_cms?.selectedFileFormat , @@ -191,6 +190,8 @@ const LegacyCMSComponent = forwardRef(({ legacyCMSData, projectData, isCompleted } })) setIsLoading(false); + console.log(selectedCmsData); + //Check for migration Status and lock. // Status where Migration is to be Locked: diff --git a/ui/src/components/LegacyCms/legacyCms.scss b/ui/src/components/LegacyCms/legacyCms.scss index 275bbf6d8..9ff37216d 100644 --- a/ui/src/components/LegacyCms/legacyCms.scss +++ b/ui/src/components/LegacyCms/legacyCms.scss @@ -136,3 +136,11 @@ flex-direction: row; gap: 30px; } +.loader{ + margin-left: 20px; + .CircularLoader--size-small{ + width: 2rem !important; + height: 2rem !important; + } + +} diff --git a/uplaode-api/migration-sitecore/libs/contenttypes.js b/uplaode-api/migration-sitecore/libs/contenttypes.js index 944bc48b0..570384ecc 100644 --- a/uplaode-api/migration-sitecore/libs/contenttypes.js +++ b/uplaode-api/migration-sitecore/libs/contenttypes.js @@ -37,7 +37,7 @@ const templatesComponents = ({ path, basePath }) => { const allFields = []; const allPaths = read(path?.[i]?.pth) for (let j = 0; j < allPaths?.length; j++) { - if (allPaths?.[j]?.includes("/data.json") || allPaths?.[j]?.includes("/data.json.json")) { + if (allPaths?.[j]?.endsWith("/data.json")) { const innerField = []; const components = helper.readFile( `${path?.[i]?.pth}/${allPaths?.[j]}` @@ -415,7 +415,7 @@ const contentTypeMapper = ({ components, standardValues, content_type, basePath, const optionsPath = read(`${sitecore_folder}/master/sitecore/content/Common/${isDataSourcePresent}`) const refName = []; optionsPath?.forEach((newPath) => { - if (newPath?.includes("data.json.json") | newPath?.includes("data.json")) { + if (newPath?.endsWith("data.json.json")) { const data = helper.readFile(`${sitecore_folder}/master/sitecore/content/Common/${isDataSourcePresent}/${newPath}`) if (data?.item?.$?.template) { refName.push(data?.item?.$?.template) @@ -520,7 +520,7 @@ function singleContentTypeCreate({ templatePaths, globalPath, sitecore_folder }) let templatesStandaedValuePath = {}; let templatesMetaDataPath = {}; for (let i = 0; i < newPath?.length; i++) { - if (newPath?.[i]?.includes("data.json") || newPath?.[i]?.includes("/data.json.json")) { + if (newPath?.[i]?.endsWith("data.json")) { const data = helper?.readFile(`${templatePaths}/${newPath?.[i]}`); if (data?.item?.$?.template === "template section") { templatesComponentsPath?.push( @@ -562,7 +562,7 @@ function ExtractContentTypes(sitecore_folder) { const folder = read(sitecore_folder); const templatePaths = []; for (let i = 0; i < folder?.length; i++) { - if (folder?.[i]?.includes("templates") && (folder?.[i]?.includes("/data.json") || folder?.[i]?.includes("/data.json.json"))) { + if (folder?.[i]?.includes("templates") && folder?.[i]?.endsWith("/data.json")) { const data = helper?.readFile(`${sitecore_folder}/${folder?.[i]}`) if (data?.item?.$?.template === "template") { templatePaths?.push(`${sitecore_folder}/${folder?.[i]}`?.split("/{")?.[0]) From 2e3782bdbb11e7f173a486a8f9577af11a2eeb0c Mon Sep 17 00:00:00 2001 From: AishDani Date: Wed, 10 Jul 2024 15:52:23 +0530 Subject: [PATCH 2/2] refactor:removed console --- ui/src/components/LegacyCms/index.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/ui/src/components/LegacyCms/index.tsx b/ui/src/components/LegacyCms/index.tsx index 83f40928e..f04b06e89 100644 --- a/ui/src/components/LegacyCms/index.tsx +++ b/ui/src/components/LegacyCms/index.tsx @@ -190,8 +190,6 @@ const LegacyCMSComponent = forwardRef(({ legacyCMSData, projectData, isCompleted } })) setIsLoading(false); - console.log(selectedCmsData); - //Check for migration Status and lock. // Status where Migration is to be Locked: