From 17e40fc49d289893c114cb898546dd312f55d3c2 Mon Sep 17 00:00:00 2001 From: Sayali Joshi Date: Thu, 4 Jul 2024 18:32:56 +0530 Subject: [PATCH 1/5] Uncaught error debug --- ui/src/components/ContentMapper/index.tsx | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/ui/src/components/ContentMapper/index.tsx b/ui/src/components/ContentMapper/index.tsx index 988b0f45..3c024d77 100644 --- a/ui/src/components/ContentMapper/index.tsx +++ b/ui/src/components/ContentMapper/index.tsx @@ -281,7 +281,12 @@ const ContentMapper = () => { // Method to get fieldmapping const fetchFields = async (contentTypeId: string, searchText: string) => { - const { data } = await getFieldMapping(contentTypeId, 0, 30, searchText || ''); + const { data } = await getFieldMapping(contentTypeId || '', 0, 30, searchText || ''); + + console.log('data', data); + + + try { const itemStatusMap: ItemStatusMapProp = {}; @@ -295,12 +300,15 @@ const ContentMapper = () => { setLoading(true); for (let index = 0; index <= 30; index++) { - itemStatusMap[index] = 'loaded'; + itemStatusMap[index] = 'loaded' ?? ''; } updateItemStatusMap({ ...itemStatusMap }); setLoading(false); - setTableData(data?.fieldMapping || []); + + const newTableData = data?.fieldMapping.filter((field: FieldMapType) => field !== null) + + setTableData(newTableData || []); setTotalCounts(data?.count); } catch (error) { console.error('fetchData -> error', error); @@ -325,7 +333,7 @@ const ContentMapper = () => { updateItemStatusMap({ ...itemStatusMapCopy }); setLoading(true); - const { data } = await getFieldMapping(contentTypeUid, skip, limit, searchText || ''); + const { data } = await getFieldMapping(contentTypeUid || '', skip, limit, searchText || ''); const updateditemStatusMapCopy: ItemStatusMapProp = { ...itemStatusMap }; @@ -1061,7 +1069,7 @@ const ContentMapper = () => { canSearch={true} data={tableData?.length ? [...tableData] : []} columns={columns} - uniqueKey={'id'} + uniqueKey={'id' || ''} isRowSelect // fullRowSelect itemStatusMap={itemStatusMap} From 01e2c65ad210cc33e7d236a3960b7e695b129186 Mon Sep 17 00:00:00 2001 From: AishDani Date: Fri, 5 Jul 2024 17:10:24 +0530 Subject: [PATCH 2/5] refactor:legacy cms --- api/src/services/migration.service.ts | 4 +- api/src/services/projects.service.ts | 43 ++++++++++--------- .../LegacyCms/Actions/LoadPrefix.tsx | 2 +- .../LegacyCms/Actions/LoadUploadFile.tsx | 6 +-- ui/src/components/LegacyCms/index.tsx | 6 +-- ui/src/pages/Migration/index.tsx | 19 +++----- uplaode-api/.env | 2 +- uplaode-api/src/routes/index.ts | 2 +- uplaode-api/src/services/fileProcessing.ts | 4 +- uplaode-api/src/validators/sitecore/index.ts | 29 +++++++------ 10 files changed, 56 insertions(+), 61 deletions(-) diff --git a/api/src/services/migration.service.ts b/api/src/services/migration.service.ts index 84c182f3..9c74fbf2 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 d4ce4662..cf950de5 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) => { @@ -508,6 +508,7 @@ const updateDestinationStack = async (req: Request) => { throw new BadRequestError(HTTP_TEXTS.CANNOT_UPDATE_DESTINATION_STACK); } if (project.current_step > STEPPER_STEPS.DESTINATION_STACK) { + console.info("in destination stack api =============> ") await contentMapperService.resetAllContentTypesMapping(projectId); logger.info( getLogMessage( @@ -760,7 +761,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 156c00b2..af7c68a3 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 79d2362f..c9ec7b9a 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 6be6040b..f40ece6c 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 e8812912..b1198609 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 5f3a84b6..2c50b649 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 b66241db..dadc2e18 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 93ca524e..4a92b700 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 870e868d..551c50e6 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; From 03588eda8dd6ad1bee5ddfb1d08a205def64929c Mon Sep 17 00:00:00 2001 From: AishDani Date: Fri, 5 Jul 2024 17:13:06 +0530 Subject: [PATCH 3/5] refactor:removed console --- api/src/services/projects.service.ts | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/api/src/services/projects.service.ts b/api/src/services/projects.service.ts index cf950de5..d80ce40d 100644 --- a/api/src/services/projects.service.ts +++ b/api/src/services/projects.service.ts @@ -507,17 +507,16 @@ const updateDestinationStack = async (req: Request) => { ); throw new BadRequestError(HTTP_TEXTS.CANNOT_UPDATE_DESTINATION_STACK); } - if (project.current_step > STEPPER_STEPS.DESTINATION_STACK) { - console.info("in destination stack api =============> ") - 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({ From 75d3c7c8809b4a0f7795ac465f3b8cf799c4303a Mon Sep 17 00:00:00 2001 From: AishDani Date: Mon, 8 Jul 2024 15:49:28 +0530 Subject: [PATCH 4/5] refactor:removed back arrow button and added functionality to cs icon --- .../LegacyCms/Actions/LoadFileFormat.tsx | 11 +--- .../LegacyCms/Actions/LoadUploadFile.tsx | 32 ++++------ ui/src/components/LegacyCms/index.tsx | 14 +++++ ui/src/components/MainHeader/index.tsx | 63 ++++++++++++++++--- .../components/MigrationFlowHeader/index.tsx | 6 +- .../VerticalStepper/AutoVerticalStepper.tsx | 2 +- ui/src/context/app/app.interface.ts | 4 +- 7 files changed, 88 insertions(+), 44 deletions(-) diff --git a/ui/src/components/LegacyCms/Actions/LoadFileFormat.tsx b/ui/src/components/LegacyCms/Actions/LoadFileFormat.tsx index c146be23..a3d54c6c 100644 --- a/ui/src/components/LegacyCms/Actions/LoadFileFormat.tsx +++ b/ui/src/components/LegacyCms/Actions/LoadFileFormat.tsx @@ -121,16 +121,7 @@ const LoadFileFormat = (props: LoadFileFormatProps) => { setFileIcon(fileFormat === 'zip' ? fileFormat?.charAt(0).toUpperCase() + fileFormat.slice(1) : fileFormat?.toUpperCase()); dispatch(updateNewMigrationData(newMigrationDataObj)); - await updateFileFormatData(selectedOrganisation?.value, projectId, { - file_format: fileFormat === 'zip' ? fileFormat?.charAt(0)?.toUpperCase() + fileFormat?.slice(1) : fileFormat?.toUpperCase(), - file_path: '', - is_fileValid: '', - awsDetails:{ - awsRegion: '', - bucketName: '', - buketKey: '' - } - }); + } /**** ALL USEEffects HERE ****/ diff --git a/ui/src/components/LegacyCms/Actions/LoadUploadFile.tsx b/ui/src/components/LegacyCms/Actions/LoadUploadFile.tsx index c9ec7b9a..5efe6bdb 100644 --- a/ui/src/components/LegacyCms/Actions/LoadUploadFile.tsx +++ b/ui/src/components/LegacyCms/Actions/LoadUploadFile.tsx @@ -4,9 +4,9 @@ import { FileDetails, INewMigration } from '../../../context/app/app.interface'; import { fileValidation, getConfig } from '../../../services/api/upload.service'; import { RootState } from '../../../store'; import { updateNewMigrationData } from '../../../store/slice/migrationDataSlice'; -import { AsyncLoader, Button, Icon, Paragraph, Tooltip } from '@contentstack/venus-components'; +import { Button, CircularLoader, Paragraph } from '@contentstack/venus-components'; import { isEmptyString } from '../../../utilities/functions'; -import { updateFileFormatData,removeContentMapper } from '../../../services/api/migration.service'; +import { removeContentMapper } from '../../../services/api/migration.service'; import { useParams } from 'react-router'; import { ICardType , defaultCardType} from '../../../components/Common/Card/card.interface'; @@ -210,19 +210,6 @@ const LoadUploadFile = (props: LoadUploadFileProps) => { }; dispatch(updateNewMigrationData(newMigrationDataObj)); - if(selectedCard?.fileformat_id && res?.data?.awsData ){ - await updateFileFormatData(selectedOrganisation?.value, projectId, { - file_format: selectedCard?.fileformat_id?.toString(), - file_path: '', - is_fileValid: newMigrationData?.legacy_cms?.uploadedFile?.isValidated, - awsDetails:{ - awsRegion: res?.data?.awsData?.awsRegion, - bucketName: res?.data?.awsData?.bucketName, - buketKey: res?.data?.awsData?.buketKey - } - }); - - } // if (res?.data?.localPath !== newMigrationData?.legacy_cms?.uploadedFile?.file_details?.localPath) { @@ -270,6 +257,9 @@ const LoadUploadFile = (props: LoadUploadFileProps) => { } dispatch(updateNewMigrationData(newMig)); } + saveStateToLocalStorage({ + isCancelLoading + }, projectId); setIsCancelLoading(false); } @@ -282,7 +272,6 @@ const LoadUploadFile = (props: LoadUploadFileProps) => { const savedState = getStateFromLocalStorage(projectId); if (savedState) { setIsLoading(savedState.isLoading); - //setIsDisabled(savedState.isDisabled); setIsConfigLoading(savedState.isConfigLoading); setCmsType(savedState.cmsType); setFileDetails(savedState.fileDetails); @@ -355,22 +344,23 @@ const LoadUploadFile = (props: LoadUploadFileProps) => { {!isConfigLoading && !isEmptyString(cmsType) ? (
- {(showMessage && !isCancelLoading) && + {/* {(showMessage && !isCancelLoading) && ( ) - } - { isCancelLoading && + } */} + {/* { isCancelLoading &&
- } + } */}
) : - } + + } {showMessage && ( <> diff --git a/ui/src/components/LegacyCms/index.tsx b/ui/src/components/LegacyCms/index.tsx index f40ece6c..59fd06de 100644 --- a/ui/src/components/LegacyCms/index.tsx +++ b/ui/src/components/LegacyCms/index.tsx @@ -174,6 +174,7 @@ const LegacyCMSComponent = forwardRef(({ legacyCMSData, projectData, isCompleted dispatch(updateNewMigrationData({ ...newMigrationData, legacy_cms: { + currentStep: internalActiveStepIndex, selectedCms: selectedCmsData, selectedFileFormat: selectedFileFormatData || defaultCardType, uploadedFile: { @@ -219,6 +220,19 @@ const LegacyCMSComponent = forwardRef(({ legacyCMSData, projectData, isCompleted } }, [internalActiveStepIndex]); + useEffect(()=>{ + dispatch(updateNewMigrationData( + { + ...newMigrationData, + legacy_cms: { + ...newMigrationData?.legacy_cms, + currentStep: internalActiveStepIndex || 0 + } + + })); + + },[internalActiveStepIndex]); + useEffect(()=>{ if (!isEmptyString(newMigrationData?.legacy_cms?.selectedCms?.cms_id)) { setInternalActiveStepIndex(0); diff --git a/ui/src/components/MainHeader/index.tsx b/ui/src/components/MainHeader/index.tsx index 568bdd8a..3b499c0c 100644 --- a/ui/src/components/MainHeader/index.tsx +++ b/ui/src/components/MainHeader/index.tsx @@ -1,7 +1,7 @@ // Libraries import { useEffect, useState } from 'react'; -import { useNavigate, useLocation, Link } from 'react-router-dom'; -import { Dropdown, Tooltip} from '@contentstack/venus-components'; +import { useNavigate, useLocation, Link, Params, useParams } from 'react-router-dom'; +import { cbModal, Dropdown, Tooltip} from '@contentstack/venus-components'; import { useDispatch, useSelector } from 'react-redux'; // Service @@ -16,29 +16,39 @@ import { CS_ENTRIES } from '../../utilities/constants'; import { clearLocalStorage, getDataFromLocalStorage, + isEmptyString, setDataInLocalStorage } from '../../utilities/functions'; // Interface import { MainHeaderType } from './mainheader.interface'; -import { IDropDown } from '../../context/app/app.interface'; +import { DEFAULT_NEW_MIGRATION, IDropDown } from '../../context/app/app.interface'; import ProfileCard from '../ProfileHeader'; // Styles import './index.scss'; +import NotificationModal from '../Common/NotificationModal'; +import { updateNewMigrationData } from '../../store/slice/migrationDataSlice'; +import { ModalObj } from '../Modal/modal.interface'; +import { getProject } from '../../services/api/project.service'; const MainHeader = () => { const user = useSelector((state:RootState)=>state?.authentication?.user); const organisationsList = useSelector((state:RootState)=>state?.authentication?.organisationsList); const selectedOrganisation = useSelector((state:RootState)=>state?.authentication?.selectedOrganisation); + const newMigrationData = useSelector((state:RootState)=> state?.migration?.newMigrationData); const [data, setData] = useState({}); const [orgsList, setOrgsList] = useState([]); + const [currentStep, setCurrentStep] = useState(0); + const [projectName, setProjectName] = useState(''); const location = useLocation(); const navigate = useNavigate(); const dispatch = useDispatch(); + const params = useParams(); + const { logo, organization_label: organizationLabel } = data; @@ -80,7 +90,7 @@ const MainHeader = () => { updateOrganisationListState(); }, [selectedOrganisation]); - const urlParams = new URLSearchParams(location.search); + const urlParams = new URLSearchParams(location.search); const newParam = urlParams.get('region'); // Function for Logout @@ -89,22 +99,59 @@ const MainHeader = () => { navigate('/', { replace: true }); } }; - + const handleOnDropDownChange = (data: IDropDown) => { if (data.value === selectedOrganisation.value) return; dispatch(setSelectedOrganisation(data)); setDataInLocalStorage('organization', data?.value); }; + + const handleonClick = async () => { + const currentIndex = newMigrationData?.legacy_cms?.currentStep + 1; + const pathSegments = location?.pathname.split('/'); + const lastPathSegment = pathSegments[pathSegments.length - 1]; + + const goback = () => { + dispatch(updateNewMigrationData(DEFAULT_NEW_MIGRATION)) + navigate(`/projects`, { replace: true }); + } + + if(-1 < currentIndex && currentIndex < 4 && ( !isEmptyString(newMigrationData?.legacy_cms?.selectedCms?.cms_id) || !isEmptyString(newMigrationData?.legacy_cms?.affix) || newMigrationData?.legacy_cms?.uploadedFile?.isValidated ) && lastPathSegment === '1') + { + + return cbModal({ + component: (props: ModalObj) => ( + + ), + modalProps: { + size: 'xsmall', + shouldCloseOnOverlayClick: false + } + }); + } + else{ + dispatch(updateNewMigrationData(DEFAULT_NEW_MIGRATION)) + navigate(`/projects`, { replace: true }); + + } + + + + }; + return (
-
+
{logo?.image?.url ? (
- + {/* */} Contentstack - + {/* */}
) : ( diff --git a/ui/src/components/MigrationFlowHeader/index.tsx b/ui/src/components/MigrationFlowHeader/index.tsx index 7bc9ba9b..4eb61d41 100644 --- a/ui/src/components/MigrationFlowHeader/index.tsx +++ b/ui/src/components/MigrationFlowHeader/index.tsx @@ -68,7 +68,7 @@ const MigrationFlowHeader = ({ handleOnClick, isLoading, isCompleted , legacyCMS if (legacyCMSRef.current) { const currentIndex = legacyCMSRef.current.getInternalActiveStepIndex() + 1 ; - + if(-1 < currentIndex && currentIndex < 4 && ( !isEmptyString(newMigrationData?.legacy_cms?.selectedCms?.cms_id) || !isEmptyString(newMigrationData?.legacy_cms?.affix) )&& currentStep === 1 ){ return cbModal({ @@ -93,7 +93,7 @@ const MigrationFlowHeader = ({ handleOnClick, isLoading, isCompleted , legacyCMS return (
-
diff --git a/ui/src/components/Stepper/VerticalStepper/AutoVerticalStepper.tsx b/ui/src/components/Stepper/VerticalStepper/AutoVerticalStepper.tsx index 96907ae3..aff6ca55 100644 --- a/ui/src/components/Stepper/VerticalStepper/AutoVerticalStepper.tsx +++ b/ui/src/components/Stepper/VerticalStepper/AutoVerticalStepper.tsx @@ -84,7 +84,7 @@ const AutoVerticalStepper = React.forwardRef<
- {isRequired && } + {isRequired && (required) } {data?.ifReadonly && (read only)}
diff --git a/ui/src/context/app/app.interface.ts b/ui/src/context/app/app.interface.ts index 12fec62d..52277bfe 100644 --- a/ui/src/context/app/app.interface.ts +++ b/ui/src/context/app/app.interface.ts @@ -149,6 +149,7 @@ export interface ILegacyCms { affix: string; isRestictedKeywordCheckboxChecked: boolean; isFileFormatCheckboxChecked: boolean; + currentStep:number } export interface IDestinationStack { selectedOrg: IDropDown; @@ -275,7 +276,8 @@ export const DEFAULT_LEGACY_CMS: ILegacyCms = { uploadedFile: DEFAULT_FILE, affix: '', isRestictedKeywordCheckboxChecked: false, - isFileFormatCheckboxChecked: false + isFileFormatCheckboxChecked: false, + currentStep:-1, }; export const DEFAULT_DESTINATION_STACK: IDestinationStack = { From d614291b130c881535b40920c25604223fd7ddb7 Mon Sep 17 00:00:00 2001 From: Sayali Joshi Date: Mon, 8 Jul 2024 19:06:35 +0530 Subject: [PATCH 5/5] Filter changes to old --- ui/src/components/ContentMapper/index.scss | 25 ++++++-- ui/src/components/ContentMapper/index.tsx | 67 ++++++++++------------ ui/src/utilities/constants.ts | 3 +- 3 files changed, 52 insertions(+), 43 deletions(-) diff --git a/ui/src/components/ContentMapper/index.scss b/ui/src/components/ContentMapper/index.scss index 11aaa894..475d4006 100644 --- a/ui/src/components/ContentMapper/index.scss +++ b/ui/src/components/ContentMapper/index.scss @@ -38,9 +38,9 @@ width: 100%!important; } } - svg { - margin-left: $px-12; - } + // svg { + // margin-left: $px-12; + // } .Button { padding: 0; &:hover { @@ -99,6 +99,11 @@ } } } +.mapped-icon { + circle { + fill: $color-brand-draft-base; + } +} .dropdown-align { .Dropdown__menu--primary { right: 0; @@ -236,17 +241,25 @@ div .table-row { top: $px-50; z-index: 1; li { + align-items: center; cursor: pointer; + display: flex; font-size: $size-font-medium; + justify-content: space-between; padding: $px-8 $px-12; &:hover { background-color: $color-base-white-10; color: $color-brand-primary-base; } + .filter-status { + margin-right: 20px; + } &.active-filter { - color: $color-brand-primary-base; - cursor: text; - font-weight: $font-weight-bold; + .filter-status { + color: $color-brand-primary-base; + cursor: text; + font-weight: $font-weight-bold; + } } } } diff --git a/ui/src/components/ContentMapper/index.tsx b/ui/src/components/ContentMapper/index.tsx index 3c024d77..46c1a7aa 100644 --- a/ui/src/components/ContentMapper/index.tsx +++ b/ui/src/components/ContentMapper/index.tsx @@ -283,11 +283,6 @@ const ContentMapper = () => { const fetchFields = async (contentTypeId: string, searchText: string) => { const { data } = await getFieldMapping(contentTypeId || '', 0, 30, searchText || ''); - console.log('data', data); - - - - try { const itemStatusMap: ItemStatusMapProp = {}; @@ -924,26 +919,23 @@ const ContentMapper = () => { } // Function to filter content types as per the status - const handleContentTypeFilter = (e: React.MouseEvent) => { - const li_list = document.querySelectorAll('li.status-wrapper'); + const handleContentTypeFilter = (value: string, e: React.MouseEvent) => { + const li_list = document.querySelectorAll('.filter-wrapper li'); if(li_list) { li_list.forEach((ele) => { - const selectedEle = document.querySelector(".active-filter"); - if (selectedEle && selectedEle !== e?.target) { - ele?.classList?.remove('active-filter'); - } + ele?.classList?.remove('active-filter'); }) } - (e?.target as HTMLElement)?.classList?.toggle('active-filter'); - - const filterVal = (e?.target as HTMLElement)?.innerText; - const filteredCT = contentTypes?.filter((ct) => CONTENT_MAPPING_STATUS[ct?.status] === filterVal); + + (e?.target as HTMLElement)?.closest('li')?.classList?.add('active-filter'); + const filteredCT = contentTypes?.filter((ct) => CONTENT_MAPPING_STATUS[ct?.status] === value); - if ((e?.target as HTMLElement)?.classList?.contains('active-filter')) { + if (value !== 'All') { setFilteredContentTypes(filteredCT) } else { setFilteredContentTypes(contentTypes) } + setShowFilter(false); } // Function to close filter panel on click outside @@ -964,19 +956,18 @@ const ContentMapper = () => { } const tableHeight = calcHeight(); - - return (
{/* Content Types List */}
-
+
{contentTypesHeading &&

{contentTypesHeading}

} + {contentTypes && validateArray(contentTypes) && contentTypes?.length }
-
+
{ debounceSearch={true} /> - {showFilter && (
    {Object.keys(CONTENT_MAPPING_STATUS).map((key, keyInd) => ( -
  • handleContentTypeFilter(e)}>{CONTENT_MAPPING_STATUS[key]}
  • + <> +
  • handleContentTypeFilter(CONTENT_MAPPING_STATUS[key], e)}> + {CONTENT_MAPPING_STATUS[key]} + {STATUS_ICON_Mapping[key] && } +
  • + ))}
)}
-
-
    - {Object.keys(CONTENT_MAPPING_STATUS).map((key, keyInd) => ( -
  • handleContentTypeFilter(e)}>{CONTENT_MAPPING_STATUS[key]}
  • - ))} -
- {contentTypes && validateArray(contentTypes) && contentTypes?.length } -
{filteredContentTypes && validateArray(filteredContentTypes) @@ -1030,13 +1018,20 @@ const ContentMapper = () => {
- - {icon && } + + {icon && ( + + + + )} + + + + + - - { className='dropdown-align' > - + */}
) diff --git a/ui/src/utilities/constants.ts b/ui/src/utilities/constants.ts index 5cc329f5..98529d75 100644 --- a/ui/src/utilities/constants.ts +++ b/ui/src/utilities/constants.ts @@ -90,7 +90,8 @@ export const isOfflineCMSDataRequired = process.env.REACT_APP_OFFLINE_CMS export const CONTENT_MAPPING_STATUS: ObjectType = { '1': 'Mapped', '2': 'Verified', - '3': 'Failed' + '3': 'Failed', + '4': 'All' // '4': 'Auto-Dump' } export const STATUS_ICON_Mapping: { [key: string]: string } = {