From 298481f2f51763c567d6372872fc63b1b4a4a9f3 Mon Sep 17 00:00:00 2001 From: AishDani Date: Fri, 9 Aug 2024 18:14:46 +0530 Subject: [PATCH 1/2] refactor:added html rte option for json rte in mapping --- ui/src/components/ContentMapper/index.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/src/components/ContentMapper/index.tsx b/ui/src/components/ContentMapper/index.tsx index 1e77a423d..6122664ec 100644 --- a/ui/src/components/ContentMapper/index.tsx +++ b/ui/src/components/ContentMapper/index.tsx @@ -84,7 +84,8 @@ const dummy_obj:any = { 'json':{ label:'JSON Rich Text Editor', options : { - 'JSON Rich Text Editor':'json' + 'JSON Rich Text Editor':'json', + 'HTML Rich text Editor': 'html' } }, 'html':{ From 6ad8f99d1cadd57fb820d893b5330427ae5feb97 Mon Sep 17 00:00:00 2001 From: AishDani Date: Fri, 9 Aug 2024 18:15:58 +0530 Subject: [PATCH 2/2] refactor:blocked user navigation from brower buttons in project dashboard and authentication pages --- ui/src/components/DestinationStack/index.tsx | 5 +--- ui/src/components/LegacyCms/index.tsx | 13 ++++---- ui/src/pages/Home/index.tsx | 2 ++ ui/src/pages/Login/index.tsx | 31 +++++++++++++++++++- ui/src/pages/Projects/index.tsx | 3 +- 5 files changed, 42 insertions(+), 12 deletions(-) diff --git a/ui/src/components/DestinationStack/index.tsx b/ui/src/components/DestinationStack/index.tsx index 81c411022..4790b4ab5 100644 --- a/ui/src/components/DestinationStack/index.tsx +++ b/ui/src/components/DestinationStack/index.tsx @@ -39,7 +39,7 @@ const DestinationStackComponent = ({ const [isLoading, setIsLoading] = useState(true); // const [isCompleted, setIsCompleted] = useState(false); const [isMigrationLocked, setIsMigrationLocked] = useState(false); - const [stepperKey, setStepperKey] = useState('v-mig-destination-step'); + const [stepperKey, setStepperKey] = useState('destination-Vertical-stepper'); const [internalActiveStepIndex, setInternalActiveStepIndex] = useState(-1); const autoVerticalStepperComponent = useRef(null); @@ -169,9 +169,6 @@ const DestinationStackComponent = ({ fetchCMSData(); }, []); - useEffect(() => { - setStepperKey('destination-Vertical-stepper'); - }, [isLoading]); useEffect(() => { updateDestinationStackData(); diff --git a/ui/src/components/LegacyCms/index.tsx b/ui/src/components/LegacyCms/index.tsx index d71d83775..636654247 100644 --- a/ui/src/components/LegacyCms/index.tsx +++ b/ui/src/components/LegacyCms/index.tsx @@ -1,4 +1,4 @@ -import { forwardRef, useEffect, useRef, useState , useImperativeHandle} from 'react'; +import { forwardRef, useEffect, useRef, useState , useImperativeHandle, useMemo} from 'react'; import { useDispatch,useSelector } from 'react-redux'; import AutoVerticalStepper from '../Stepper/VerticalStepper/AutoVerticalStepper'; import { getLegacyCMSSteps } from './StepperSteps'; @@ -45,7 +45,8 @@ const LegacyCMSComponent = forwardRef(({ legacyCMSData, projectData, isCompleted const [isMigrationLocked, setIsMigrationLocked] = useState(false); const [isLoading, setIsLoading] = useState(true); const [internalActiveStepIndex, setInternalActiveStepIndex] = useState(-1); - const [stepperKey, setStepperKey] = useState('v-mig-step'); + const [stepperKey, setStepperKey] = useState('legacy-Vertical-stepper'); + const { projectId = '' } = useParams(); const [isValidated, setisValidated] = useState( newMigrationData?.legacy_cms?.uploadedFile?.isValidated || false @@ -202,7 +203,7 @@ const LegacyCMSComponent = forwardRef(({ legacyCMSData, projectData, isCompleted }, []); useEffect(() => { - setStepperKey('legacy-Vertical-stepper'); + setisValidated(newMigrationData?.legacy_cms?.uploadedFile?.isValidated || false); }, [isLoading]); @@ -219,9 +220,7 @@ const LegacyCMSComponent = forwardRef(({ legacyCMSData, projectData, isCompleted autoVerticalStepper.current.handleDynamicStepChange(internalActiveStepIndex, true); } } - }, [internalActiveStepIndex]); - useEffect(()=>{ dispatch(updateNewMigrationData( { ...newMigrationData, @@ -232,7 +231,9 @@ const LegacyCMSComponent = forwardRef(({ legacyCMSData, projectData, isCompleted })); - },[internalActiveStepIndex]); + + }, [internalActiveStepIndex]); + useEffect(()=>{ if (!isEmptyString(newMigrationData?.legacy_cms?.selectedCms?.cms_id)) { diff --git a/ui/src/pages/Home/index.tsx b/ui/src/pages/Home/index.tsx index 2436eaf71..0110a4fa3 100644 --- a/ui/src/pages/Home/index.tsx +++ b/ui/src/pages/Home/index.tsx @@ -12,9 +12,11 @@ import { CS_ENTRIES } from '../../utilities/constants'; // Interface import { HomepageType } from './home.interface'; +import useBlockNavigation from '../../hooks/userNavigation'; const Home = () => { const [data, setData] = useState({}); + useBlockNavigation(true); const fetchData = async () => { //check if offline CMS data field is set to true, if then read data from cms data file. diff --git a/ui/src/pages/Login/index.tsx b/ui/src/pages/Login/index.tsx index f87da3b70..1b2eedad0 100644 --- a/ui/src/pages/Login/index.tsx +++ b/ui/src/pages/Login/index.tsx @@ -1,5 +1,5 @@ // Libraries -import { FC,useEffect, useState } from 'react'; +import { FC,useEffect, useRef, useState } from 'react'; import { useNavigate, useLocation } from 'react-router-dom'; import { useDispatch } from 'react-redux'; @@ -66,6 +66,7 @@ const Login: FC = () => { // ************* ALL States Here ************ const [loginStates, setLoginStates] = useState(defaultStates); const [isLoading, setIsLoading] = useState(false) + const [isBlock, setIsBlock] = useState(false); const navigate = useNavigate(); const location = useLocation(); @@ -177,6 +178,14 @@ const Login: FC = () => { } }; + useEffect(()=>{ + if(region && loginStates?.tfa){ + setIsBlock(true); + + } + + },[loginStates]); + // Function for TFA validation const TFAValidation = (value: string): string | undefined => { if (value?.length) { @@ -186,6 +195,26 @@ const Login: FC = () => { } }; + + useEffect(()=>{ + const handlePopState = (event: PopStateEvent) => { + event.preventDefault(); + window.history.pushState(null, '', window.location.href); + + }; + if(isBlock){ + window.history.pushState(null, '', window.location.href); + + } + window.history.pushState(null, '', window.location.href); + window.addEventListener('popstate',handlePopState); + + + return () => { + window.removeEventListener('popstate', handlePopState); + }; + + },[isBlock]); return ( {loginStates?.tfa ? ( diff --git a/ui/src/pages/Projects/index.tsx b/ui/src/pages/Projects/index.tsx index 66e5dc545..cfa5ffbdb 100644 --- a/ui/src/pages/Projects/index.tsx +++ b/ui/src/pages/Projects/index.tsx @@ -133,7 +133,8 @@ const Projects = () => { const onClose = () => { fetchProjects(); }; - useBlockNavigation(isModalOpen) + useBlockNavigation(isModalOpen || true); + // Function for open modal const openModal = () => { setIsModalOpen(true);