diff --git a/ui/src/components/MigrationFlowHeader/index.tsx b/ui/src/components/MigrationFlowHeader/index.tsx index af891b1d4..7e7a6767c 100644 --- a/ui/src/components/MigrationFlowHeader/index.tsx +++ b/ui/src/components/MigrationFlowHeader/index.tsx @@ -28,6 +28,8 @@ const MigrationFlowHeader = ({projectData, handleOnClick, isLoading }: Migration const params: Params = useParams(); const selectedOrganisation = useSelector((state: RootState)=>state?.authentication?.selectedOrganisation); + const newMigrationData = useSelector((state: RootState) => state?.migration?.newMigrationData); + useEffect(() => { fetchProject(); @@ -65,6 +67,7 @@ const MigrationFlowHeader = ({projectData, handleOnClick, isLoading }: Migration version="v2" aria-label='Save and Continue' isLoading={isLoading} + disabled={newMigrationData?.testStacks?.length > 0} > {stepValue} diff --git a/ui/src/components/Stepper/HorizontalStepper/HorizontalStepper.tsx b/ui/src/components/Stepper/HorizontalStepper/HorizontalStepper.tsx index 96a6859cd..0c65cb27c 100644 --- a/ui/src/components/Stepper/HorizontalStepper/HorizontalStepper.tsx +++ b/ui/src/components/Stepper/HorizontalStepper/HorizontalStepper.tsx @@ -97,9 +97,6 @@ const HorizontalStepper = forwardRef( useEffect(() => { const stepIndex = parseInt(stepId || '', 10) - 1; - - console.log("stepIndex", stepIndex); - if (!Number.isNaN(stepIndex) && stepIndex >= 0 && stepIndex < steps?.length) { setShowStep(stepIndex); @@ -193,7 +190,7 @@ const HorizontalStepper = forwardRef( !stepsCompleted.includes(idx) && idx !== showStep && !stepsCompleted?.includes(idx - 1) ? 'disableEvents' : ''; - const completeDisable = stepsCompleted?.includes(idx) && idx < steps?.length - 1 ? 'completed disableEvents' : ''; + const completeDisable = stepsCompleted?.includes(idx) && idx < steps?.length - 3 ? 'completed disableEvents' : ''; return (
diff --git a/ui/src/components/TestMigration/index.tsx b/ui/src/components/TestMigration/index.tsx index 17ba79bc4..5a1cbf86f 100644 --- a/ui/src/components/TestMigration/index.tsx +++ b/ui/src/components/TestMigration/index.tsx @@ -18,7 +18,7 @@ import { CS_ENTRIES } from '../../utilities/constants'; // Interface import { MigrationType } from './testMigration.interface'; -import { INewMigration } from '../../context/app/app.interface'; +import { INewMigration, TestStacks } from '../../context/app/app.interface'; // Component @@ -29,7 +29,7 @@ import './index.scss'; const TestMigration = () => { const [data, setData] = useState({}); - const [showLogs, setShowLogs] = useState(false); + const [isLoading, setIsLoading] = useState(false); const newMigrationData = useSelector((state: RootState) => state?.migration?.newMigrationData); const selectedOrganisation = useSelector((state: RootState)=>state?.authentication?.selectedOrganisation); @@ -47,11 +47,10 @@ const TestMigration = () => { }); }, []); - console.log("projectId", projectId); - - // Method to create test stack const handleCreateTestStack = async () => { + setIsLoading(true); + //get org plan details const orgDetails = await getOrgDetails(selectedOrganisation?.value); const stacks_details_key = Object.keys(orgDetails?.data?.organization?.plan?.features).find(key => orgDetails?.data?.organization?.plan?.features[key].uid === 'stacks') || ''; @@ -83,12 +82,17 @@ const TestMigration = () => { data ); - const newMigrationDataObj: INewMigration = { - ...newMigrationData, - test_migration: { stack_link: res?.data?.data?.url, stack_api_key: res?.data?.data?.data?.stack?.api_key } - }; + if (res?.status === 200) { + setIsLoading(false); + - dispatch(updateNewMigrationData((newMigrationDataObj))); + const newMigrationDataObj: INewMigration = { + ...newMigrationData, + test_migration: { stack_link: res?.data?.data?.url, stack_api_key: res?.data?.data?.data?.stack?.api_key } + }; + + dispatch(updateNewMigrationData((newMigrationDataObj))); + } } const handleTestMigration = async () => { @@ -96,9 +100,6 @@ const TestMigration = () => { newMigrationData?.destination_stack?.selectedOrg?.value, projectId ); - - console.log("testRes", testRes); - } return ( @@ -111,9 +112,10 @@ const TestMigration = () => { className="mt-3" onClick={handleCreateTestStack} version="v2" - // size="medium" + disabled={newMigrationData?.testStacks?.some((stack: TestStacks) => stack?.isMigrated === false)} + isLoading={isLoading} > - Create Test Stack + Create Test Stack {(newMigrationData?.test_migration?.stack_api_key || newMigrationData?.test_migration?.stack_link) && { existingGlobal: existingGlobalFields }, stackDetails: projectData?.stackDetails, - // mapper_keys: projectData?.mapper_keys, + testStacks: projectData?.test_stacks }; dispatch(updateNewMigrationData(projectMapper)); @@ -451,12 +451,8 @@ const Migration = () => { handleOnClickContentMapper, handleOnClickTestMigration ]; - - return ( - -
{projectData && <>