Skip to content

Commit 1bb92ea

Browse files
authored
Merge pull request #431 from contentstack/feature/dropdown-field-choices
refactor:update current-step after migration from api side and stack-…
2 parents c496a78 + 20952be commit 1bb92ea

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

api/src/services/runCli.service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ export const runCli = async (rg: string, user_id: string, stack_uid: any, projec
6363
!isTest && ProjectModelLowdb.update((data: any) => {
6464
data.projects[projectIndex].isMigrationCompleted = true;
6565
data.projects[projectIndex].isMigrationStarted = false;
66+
data.projects[projectIndex].current_step = 5;
67+
data.projects[projectIndex].status = 5;
6668
})
6769
}
6870
});

ui/src/components/LogScreen/MigrationLogViewer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ const MigrationLogViewer = ({ serverPath }: LogsType) => {
193193
/**
194194
* Updates the Migration excution step as completed in backend if migration completes.
195195
*/
196-
updateCurrentStepData(selectedOrganisation.value, projectId);
196+
//await updateCurrentStepData(selectedOrganisation.value, projectId);
197197

198198
return cbModal({
199199
component: (props: ModalObj) => (

ui/src/pages/Migration/index.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
DEFAULT_IFLOWSTEP,
2424
IFlowStep
2525
} from '../../components/Stepper/FlowStepper/flowStep.interface';
26-
import { IDropDown, INewMigration, ICMSType, ILegacyCMSComponent, DEFAULT_CMS_TYPE } from '../../context/app/app.interface';
26+
import { IDropDown, INewMigration, ICMSType, ILegacyCMSComponent, DEFAULT_CMS_TYPE, TestStacks } from '../../context/app/app.interface';
2727
import { ContentTypeSaveHandles } from '../../components/ContentMapper/contentMapper.interface';
2828
import { ICardType } from "../../components/Common/Card/card.interface";
2929
import { ModalObj } from '../../components/Modal/modal.interface';
@@ -203,6 +203,7 @@ const Migration = () => {
203203
const existingGlobalFields = await fetchExistingGlobalFields();
204204

205205
const stackLink = `${CS_URL[projectData?.region]}/stack/${projectData?.current_test_stack_id}/dashboard`;
206+
const stackName = projectData?.test_stacks?.find((stack:TestStacks)=> stack?.stackUid === projectData?.current_test_stack_id)?.stackName;
206207

207208
const projectMapper = {
208209
...newMigrationData,
@@ -245,7 +246,8 @@ const Migration = () => {
245246
stack_link: stackLink,
246247
stack_api_key: projectData?.current_test_stack_id,
247248
isMigrationStarted: newMigrationData?.test_migration?.isMigrationStarted || false,
248-
isMigrationComplete: newMigrationData?.test_migration?.isMigrationStarted || false
249+
isMigrationComplete: newMigrationData?.test_migration?.isMigrationStarted || false,
250+
stack_name: stackName,
249251
},
250252
migration_execution: {
251253
migrationStarted: projectData?.isMigrationStarted,
@@ -361,8 +363,9 @@ const Migration = () => {
361363
}
362364
});
363365
const res = await updateCurrentStepData(selectedOrganisation.value, projectId);
366+
364367
handleStepChange(1);
365-
if (res) {
368+
if (res?.status === 200) {
366369
setIsLoading(false);
367370

368371
const url = `/projects/${projectId}/migration/steps/2`;
@@ -418,9 +421,9 @@ const Migration = () => {
418421
created_at:newMigrationData?.destination_stack?.selectedStack?.created_at,
419422
isNewStack: newMigrationData?.destination_stack?.selectedStack?.isNewStack
420423
})
421-
handleStepChange(2);
422424
const res = await updateCurrentStepData(selectedOrganisation?.value, projectId);
423-
if (res) {
425+
if (res?.status === 200) {
426+
handleStepChange(2);
424427
setIsLoading(false);
425428
const url = `/projects/${projectId}/migration/steps/3`;
426429
navigate(url, { replace: true });
@@ -486,8 +489,11 @@ const Migration = () => {
486489

487490
await updateMigrationKey(selectedOrganisation.value, projectId);
488491

489-
await updateCurrentStepData(selectedOrganisation.value, projectId);
490-
handleStepChange(4);
492+
const res = await updateCurrentStepData(selectedOrganisation.value, projectId);
493+
if(res?.status === 200){
494+
handleStepChange(4);
495+
}
496+
491497
}
492498

493499
/**

0 commit comments

Comments
 (0)