Skip to content

Commit ed2fff5

Browse files
authored
Merge pull request #303 from contentstack/feature/test-migration
Feature/test migration
2 parents c1d5f95 + f776afa commit ed2fff5

File tree

5 files changed

+30
-25
lines changed

5 files changed

+30
-25
lines changed

ui/src/components/MigrationFlowHeader/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ const MigrationFlowHeader = ({projectData, handleOnClick, isLoading }: Migration
2828
const params: Params<string> = useParams();
2929

3030
const selectedOrganisation = useSelector((state: RootState)=>state?.authentication?.selectedOrganisation);
31+
const newMigrationData = useSelector((state: RootState) => state?.migration?.newMigrationData);
32+
3133

3234
useEffect(() => {
3335
fetchProject();
@@ -65,6 +67,7 @@ const MigrationFlowHeader = ({projectData, handleOnClick, isLoading }: Migration
6567
version="v2"
6668
aria-label='Save and Continue'
6769
isLoading={isLoading}
70+
disabled={newMigrationData?.testStacks?.length > 0}
6871
>
6972
{stepValue}
7073
</Button>

ui/src/components/Stepper/HorizontalStepper/HorizontalStepper.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,6 @@ const HorizontalStepper = forwardRef(
9797

9898
useEffect(() => {
9999
const stepIndex = parseInt(stepId || '', 10) - 1;
100-
101-
console.log("stepIndex", stepIndex);
102-
103100

104101
if (!Number.isNaN(stepIndex) && stepIndex >= 0 && stepIndex < steps?.length) {
105102
setShowStep(stepIndex);
@@ -193,7 +190,7 @@ const HorizontalStepper = forwardRef(
193190
!stepsCompleted.includes(idx) && idx !== showStep && !stepsCompleted?.includes(idx - 1)
194191
? 'disableEvents'
195192
: '';
196-
const completeDisable = stepsCompleted?.includes(idx) && idx < steps?.length - 1 ? 'completed disableEvents' : '';
193+
const completeDisable = stepsCompleted?.includes(idx) && idx < steps?.length - 3 ? 'completed disableEvents' : '';
197194
return (
198195
<React.Fragment key={id}>
199196
<div className="stepWrapperContainer">

ui/src/components/TestMigration/index.tsx

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { CS_ENTRIES } from '../../utilities/constants';
1818

1919
// Interface
2020
import { MigrationType } from './testMigration.interface';
21-
import { INewMigration } from '../../context/app/app.interface';
21+
import { INewMigration, TestStacks } from '../../context/app/app.interface';
2222

2323

2424
// Component
@@ -29,7 +29,7 @@ import './index.scss';
2929

3030
const TestMigration = () => {
3131
const [data, setData] = useState<MigrationType>({});
32-
const [showLogs, setShowLogs] = useState<boolean>(false);
32+
const [isLoading, setIsLoading] = useState<boolean>(false);
3333

3434
const newMigrationData = useSelector((state: RootState) => state?.migration?.newMigrationData);
3535
const selectedOrganisation = useSelector((state: RootState)=>state?.authentication?.selectedOrganisation);
@@ -47,11 +47,10 @@ const TestMigration = () => {
4747
});
4848
}, []);
4949

50-
console.log("projectId", projectId);
51-
52-
5350
// Method to create test stack
5451
const handleCreateTestStack = async () => {
52+
setIsLoading(true);
53+
5554
//get org plan details
5655
const orgDetails = await getOrgDetails(selectedOrganisation?.value);
5756
const stacks_details_key = Object.keys(orgDetails?.data?.organization?.plan?.features).find(key => orgDetails?.data?.organization?.plan?.features[key].uid === 'stacks') || '';
@@ -83,22 +82,24 @@ const TestMigration = () => {
8382
data
8483
);
8584

86-
const newMigrationDataObj: INewMigration = {
87-
...newMigrationData,
88-
test_migration: { stack_link: res?.data?.data?.url, stack_api_key: res?.data?.data?.data?.stack?.api_key }
89-
};
85+
if (res?.status === 200) {
86+
setIsLoading(false);
87+
9088

91-
dispatch(updateNewMigrationData((newMigrationDataObj)));
89+
const newMigrationDataObj: INewMigration = {
90+
...newMigrationData,
91+
test_migration: { stack_link: res?.data?.data?.url, stack_api_key: res?.data?.data?.data?.stack?.api_key }
92+
};
93+
94+
dispatch(updateNewMigrationData((newMigrationDataObj)));
95+
}
9296
}
9397

9498
const handleTestMigration = async () => {
9599
const testRes = await createTestMigration(
96100
newMigrationData?.destination_stack?.selectedOrg?.value,
97101
projectId
98102
);
99-
100-
console.log("testRes", testRes);
101-
102103
}
103104

104105
return (
@@ -111,9 +112,10 @@ const TestMigration = () => {
111112
className="mt-3"
112113
onClick={handleCreateTestStack}
113114
version="v2"
114-
// size="medium"
115+
disabled={newMigrationData?.testStacks?.some((stack: TestStacks) => stack?.isMigrated === false)}
116+
isLoading={isLoading}
115117
>
116-
Create Test Stack
118+
Create Test Stack
117119
</Button>
118120
{(newMigrationData?.test_migration?.stack_api_key || newMigrationData?.test_migration?.stack_link) &&
119121
<Field

ui/src/context/app/app.interface.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ export interface IContentMapper {
176176
contentTypeList:ContentTypeList[]
177177
}
178178
export interface INewMigration {
179+
testStacks: TestStacks[];
179180
mapperKeys: ContentTypeMap;
180181
legacy_cms: ILegacyCms;
181182
destination_stack: IDestinationStack;
@@ -185,6 +186,11 @@ export interface INewMigration {
185186
stackDetails: IDropDown;
186187
}
187188

189+
export interface TestStacks {
190+
stackUid?: string;
191+
isMigrated?: boolean;
192+
}
193+
188194
export interface IMigrationData {
189195
allFlowSteps: IFlowStep[];
190196
currentFlowStep: IFlowStep;
@@ -329,7 +335,8 @@ export const DEFAULT_NEW_MIGRATION: INewMigration = {
329335
content_mapping: DEFAULT_CONTENT_MAPPER,
330336
test_migration: DEFAULT_TEST_MIGRATION,
331337
isprojectMapped: false,
332-
stackDetails: DEFAULT_DROPDOWN
338+
stackDetails: DEFAULT_DROPDOWN,
339+
testStacks: []
333340
};
334341

335342
export const DEFAULT_URL_TYPE: IURLType = {

ui/src/pages/Migration/index.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ const Migration = () => {
217217
existingGlobal: existingGlobalFields
218218
},
219219
stackDetails: projectData?.stackDetails,
220-
// mapper_keys: projectData?.mapper_keys,
220+
testStacks: projectData?.test_stacks
221221
};
222222

223223
dispatch(updateNewMigrationData(projectMapper));
@@ -451,12 +451,8 @@ const Migration = () => {
451451
handleOnClickContentMapper,
452452
handleOnClickTestMigration
453453
];
454-
455-
456454

457455
return (
458-
459-
460456
<div className='migration-steps-wrapper'>
461457
{projectData &&
462458
<>

0 commit comments

Comments
 (0)