handleTabStep(idx)}
>
diff --git a/ui/src/components/TestMigration/index.tsx b/ui/src/components/TestMigration/index.tsx
index 3671c760..17ba79bc 100644
--- a/ui/src/components/TestMigration/index.tsx
+++ b/ui/src/components/TestMigration/index.tsx
@@ -1,18 +1,25 @@
-import { useEffect, useState } from 'react';
-import { Field, FieldLabel, TextInput, Link, Icon, Tooltip, Button } from '@contentstack/venus-components';
-import { useSelector } from 'react-redux';
+import { useEffect, useState, useRef } from 'react';
+import { useParams } from 'react-router';
+import { Field, FieldLabel, TextInput, Link, Icon, Tooltip, Button, Notification } from '@contentstack/venus-components';
+import { useSelector, useDispatch } from 'react-redux';
// Redux files
import { RootState } from '../../store';
+import { updateNewMigrationData } from '../../store/slice/migrationDataSlice';
+
// Services
import { getCMSDataFromFile } from '../../cmsData/cmsSelector';
+import { getOrgDetails, createTestStack, createTestMigration } from '../../services/api/migration.service';
+import { getAllStacksInOrg } from '../../services/api/stacks.service';
// Utilities
import { CS_ENTRIES } from '../../utilities/constants';
// Interface
import { MigrationType } from './testMigration.interface';
+import { INewMigration } from '../../context/app/app.interface';
+
// Component
import LogViewer from '../LogScreen';
@@ -22,9 +29,12 @@ import './index.scss';
const TestMigration = () => {
const [data, setData] = useState
({});
+ const [showLogs, setShowLogs] = useState(false);
- const newMigrationData = useSelector((state: RootState)=>state?.migration?.newMigrationData);
-
+ const newMigrationData = useSelector((state: RootState) => state?.migration?.newMigrationData);
+ const selectedOrganisation = useSelector((state: RootState)=>state?.authentication?.selectedOrganisation);
+ const { projectId = '' } = useParams();
+ const dispatch = useDispatch();
/********** ALL USEEFFECT HERE *************/
useEffect(() => {
@@ -37,6 +47,60 @@ const TestMigration = () => {
});
}, []);
+ console.log("projectId", projectId);
+
+
+ // Method to create test stack
+ const handleCreateTestStack = async () => {
+ //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') || '';
+
+ const max_stack_limit = orgDetails?.data?.organization?.plan?.features[stacks_details_key]?.max_limit;
+
+ const stackData = await getAllStacksInOrg(selectedOrganisation?.value, ''); // org id will always be there
+
+ const stack_count = stackData?.data?.stacks?.length;
+
+ if (stack_count >= max_stack_limit) {
+ // setIsLoading(false);
+ Notification({
+ notificationContent: { text: 'You have reached the maximum limit of stacks for your organization' },
+ type: 'warning'
+ });
+ return;
+ }
+
+ const data = {
+ name: newMigrationData?.destination_stack?.selectedStack?.label,
+ description: 'test migration stack',
+ master_locale: newMigrationData?.destination_stack?.selectedStack?.master_locale
+ };
+
+ const res = await createTestStack(
+ newMigrationData?.destination_stack?.selectedOrg?.value,
+ projectId,
+ data
+ );
+
+ 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 () => {
+ const testRes = await createTestMigration(
+ newMigrationData?.destination_stack?.selectedOrg?.value,
+ projectId
+ );
+
+ console.log("testRes", testRes);
+
+ }
+
return (
@@ -45,7 +109,7 @@ const TestMigration = () => {
Test Migration is a step where some content types are migrated in a test stack for review. A user can verify the stack and data. If the data is migrated properly then it can proceed with the final Migration Execution process.
@@ -85,10 +149,10 @@ const TestMigration = () => {
)}
Start Test Migration
@@ -97,11 +161,10 @@ const TestMigration = () => {
}
-
diff --git a/ui/src/pages/Migration/index.tsx b/ui/src/pages/Migration/index.tsx
index ae9b3be3..c119e57a 100644
--- a/ui/src/pages/Migration/index.tsx
+++ b/ui/src/pages/Migration/index.tsx
@@ -390,26 +390,7 @@ const Migration = () => {
const handleOnClickContentMapper = async (event: MouseEvent) => {
setIsModalOpen(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') || '';
-
- const max_stack_limit = orgDetails?.data?.organization?.plan?.features[stacks_details_key]?.max_limit;
-
- const stackData = await getAllStacksInOrg(selectedOrganisation?.value, ''); // org id will always be there
-
- const stack_count = stackData?.data?.stacks?.length;
-
- if (stack_count >= max_stack_limit) {
- setIsLoading(false);
- Notification({
- notificationContent: { text: 'You have reached the maximum limit of stacks for your organization' },
- type: 'warning'
- });
- return;
- }
-
- if(newMigrationData?.content_mapping?.isDropDownChanged){
+ if(newMigrationData?.content_mapping?.isDropDownChanged) {
return cbModal({
component: (props: ModalObj) => (