Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 21 additions & 26 deletions api/src/services/projects.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ const createProject = async (req: Request) => {
//Add logic to create Project from DB
await ProjectModelLowdb.read();

ProjectModelLowdb.update((data: any) => {
await ProjectModelLowdb.update((data: any) => {
data.projects.push(projectData);
});

Expand Down Expand Up @@ -204,7 +204,7 @@ const updateProject = async (req: Request) => {

try {
// Update the project fields
ProjectModelLowdb.update((data: any) => {
await ProjectModelLowdb.update((data: any) => {
data.projects[projectIndex].name = updateData?.name;
data.projects[projectIndex].description = updateData?.description;
if (
Expand Down Expand Up @@ -308,7 +308,7 @@ const updateLegacyCMS = async (req: Request) => {
// }

try {
ProjectModelLowdb.update((data: any) => {
await ProjectModelLowdb.update((data: any) => {
data.projects[projectIndex].legacy_cms.cms = legacy_cms;
data.projects[projectIndex].current_step = STEPPER_STEPS.LEGACY_CMS;
data.projects[projectIndex].status = NEW_PROJECT_STATUS[0];
Expand Down Expand Up @@ -368,7 +368,7 @@ const updateAffix = async (req: Request) => {
true
)) as number;

ProjectModelLowdb.update((data: any) => {
await ProjectModelLowdb.update((data: any) => {
data.projects[projectIndex].legacy_cms.affix = affix;
data.projects[projectIndex].updated_at = new Date().toISOString();
});
Expand Down Expand Up @@ -405,7 +405,7 @@ const affixConfirmation = async (req: Request) => {
true
)) as number;

ProjectModelLowdb.update((data: any) => {
await ProjectModelLowdb.update((data: any) => {
data.projects[projectIndex].legacy_cms.affix_confirmation =
affix_confirmation;
data.projects[projectIndex].updated_at = new Date().toISOString();
Expand Down Expand Up @@ -477,7 +477,7 @@ const updateFileFormat = async (req: Request) => {
// }

try {
ProjectModelLowdb.update((data: any) => {
await ProjectModelLowdb.update((data: any) => {
data.projects[projectIndex].legacy_cms.file_format = file_format;
data.projects[projectIndex].legacy_cms.file_path = file_path;
data.projects[projectIndex].legacy_cms.is_fileValid = is_fileValid;
Expand Down Expand Up @@ -546,7 +546,7 @@ const fileformatConfirmation = async (req: Request) => {
)) as number;

if (!fileformat_confirmation) {
ProjectModelLowdb.update((data: any) => {
await ProjectModelLowdb.update((data: any) => {
data.projects[projectIndex].legacy_cms.file_format_confirmation =
fileformat_confirmation;
data.projects[projectIndex].updated_at = new Date().toISOString();
Expand Down Expand Up @@ -643,7 +643,7 @@ const updateDestinationStack = async (req: Request) => {
if (!res.data.stacks.find((stack: any) => stack.api_key === stack_api_key))
throw new BadRequestError(HTTP_TEXTS.DESTINATION_STACK_NOT_FOUND);

ProjectModelLowdb.update((data: any) => {
await ProjectModelLowdb.update((data: any) => {
data.projects[projectIndex].destination_stack_id = stack_api_key;
data.projects[projectIndex].current_step =
STEPPER_STEPS.DESTINATION_STACK;
Expand Down Expand Up @@ -713,11 +713,6 @@ const updateCurrentStep = async (req: Request) => {
const isStepCompleted =
project?.legacy_cms?.cms && project?.legacy_cms?.file_format;

console.info((project.status === NEW_PROJECT_STATUS[0] ||
!isStepCompleted ||
!project?.destination_stack_id ||
project?.content_mapper?.length === 0 ||
!project?.current_test_stack_id) || !project?.migration_execution);

switch (project.current_step) {
case STEPPER_STEPS.LEGACY_CMS: {
Expand All @@ -732,7 +727,7 @@ const updateCurrentStep = async (req: Request) => {
throw new BadRequestError(HTTP_TEXTS.CANNOT_PROCEED_LEGACY_CMS);
}

ProjectModelLowdb.update((data: any) => {
await ProjectModelLowdb.update((data: any) => {
data.projects[projectIndex].current_step =
STEPPER_STEPS.DESTINATION_STACK;
data.projects[projectIndex].status =
Expand Down Expand Up @@ -760,7 +755,7 @@ const updateCurrentStep = async (req: Request) => {
);
}

ProjectModelLowdb.update((data: any) => {
await ProjectModelLowdb.update((data: any) => {
data.projects[projectIndex].current_step =
STEPPER_STEPS.CONTENT_MAPPING;
data.projects[projectIndex].status = NEW_PROJECT_STATUS[3];
Expand Down Expand Up @@ -789,7 +784,7 @@ const updateCurrentStep = async (req: Request) => {
);
}

ProjectModelLowdb.update((data: any) => {
await ProjectModelLowdb.update((data: any) => {
data.projects[projectIndex].current_step =
STEPPER_STEPS.TESTING;
data.projects[projectIndex].status = NEW_PROJECT_STATUS[4];
Expand Down Expand Up @@ -818,7 +813,7 @@ const updateCurrentStep = async (req: Request) => {
);
}

ProjectModelLowdb.update((data: any) => {
await ProjectModelLowdb.update((data: any) => {
data.projects[projectIndex].current_step =
STEPPER_STEPS.MIGRATION;
data.projects[projectIndex].status = NEW_PROJECT_STATUS[4];
Expand Down Expand Up @@ -847,7 +842,7 @@ const updateCurrentStep = async (req: Request) => {
);
}

ProjectModelLowdb.update((data: any) => {
await ProjectModelLowdb.update((data: any) => {
data.projects[projectIndex].current_step =
STEPPER_STEPS.MIGRATION;
data.projects[projectIndex].status = NEW_PROJECT_STATUS[5];
Expand Down Expand Up @@ -913,7 +908,7 @@ const deleteProject = async (req: Request) => {
await ContentTypesMapperModelLowdb.read();
await FieldMapperModel.read();
if (!isEmpty(content_mapper_id)) {
content_mapper_id.map((item: any) => {
content_mapper_id.map(async (item: any) => {
const contentMapperData = ContentTypesMapperModelLowdb.chain
.get("ContentTypesMappers")
.find({ id: item, projectId: projectId })
Expand All @@ -940,17 +935,17 @@ const deleteProject = async (req: Request) => {
.get("ContentTypesMappers")
.findIndex({ id: item, projectId: projectId })
.value();
ContentTypesMapperModelLowdb.update((Cdata: any) => {
await ContentTypesMapperModelLowdb.update((Cdata: any) => {
delete Cdata.ContentTypesMappers[contentMapperID];
});
});
}
//delete Project
ProjectModelLowdb.update((Pdata: any) => {
await ProjectModelLowdb.update((Pdata: any) => {
delete Pdata.projects[projectIndex];
});
} else {
ProjectModelLowdb.update((data: any) => {
await ProjectModelLowdb.update((data: any) => {
data.projects[projectIndex].isDeleted = true;
});
}
Expand Down Expand Up @@ -1000,7 +995,7 @@ const revertProject = async (req: Request) => {
if (!projects) {
throw new NotFoundError(HTTP_TEXTS.PROJECT_NOT_FOUND);
} else {
ProjectModelLowdb.update((data: any) => {
await ProjectModelLowdb.update((data: any) => {
data.projects[projectIndex].isDeleted = false;
});
logger.info(
Expand Down Expand Up @@ -1047,7 +1042,7 @@ const updateStackDetails = async (req: Request) => {
)) as number;

try {
ProjectModelLowdb.update((data: any) => {
await ProjectModelLowdb.update((data: any) => {
data.projects[projectIndex].stackDetails = stack_details;
data.projects[projectIndex].updated_at = new Date().toISOString();
});
Expand Down Expand Up @@ -1109,7 +1104,7 @@ const updateContentMapper = async (req: Request) => {
)) as number;

try {
ProjectModelLowdb.update((data: any) => {
await ProjectModelLowdb.update((data: any) => {
data.projects[projectIndex].mapperKeys = content_mapper;
data.projects[projectIndex].updated_at = new Date().toISOString();
});
Expand Down Expand Up @@ -1170,7 +1165,7 @@ const updateMigrationExecution = async (req: Request) => {
try {

// Update the project in the `ProjectModelLowdb` database
ProjectModelLowdb.update((data: any) => {
await ProjectModelLowdb.update((data: any) => {
data.projects[projectIndex].migration_execution = true; // Set migration execution to true
data.projects[projectIndex].updated_at = new Date().toISOString(); // Update the `updated_at` timestamp
});
Expand Down
8 changes: 4 additions & 4 deletions ui/src/cmsData/legacyCms.json
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@
"uid": "cs752bfd62296e4791"
},
"title": "Select CMS",
"description": "Select the CMS you are migrating content from.",
"description": "Select the CMS you are migrating content from",
"step_lock_text": "Editing this step is currently disabled. To make changes in Draft mode, please deactivate the migration.",
"lock": false,
"active": true,
Expand All @@ -338,7 +338,7 @@
"uid": "cs6c761d71844ac800"
},
"title": "Add Source Affix",
"description": "Add a 2–5 character affix for the source name. Use only letters, no numbers or special characters.",
"description": "Add a 2–5 character affix for the source name. Use only letters, no numbers or special characters",
"step_lock_text": "Editing this step is currently disabled. To make changes in Draft mode, please deactivate the migration.",
"lock": false,
"active": false,
Expand All @@ -350,7 +350,7 @@
"uid": "cs7c935e15de9ea7c8"
},
"title": "Select File Format",
"description": "Select the file format compatible with the selected CMS.",
"description": "Select the file format compatible with the selected CMS",
"step_lock_text": "Editing this step is currently disabled. To make changes in Draft mode, please deactivate the migration.",
"lock": false,
"active": true,
Expand All @@ -362,7 +362,7 @@
"uid": "cs0279f1f0ce13e83e"
},
"title": "Uploaded File",
"description": "This is the file you have uploaded.",
"description": "This is the file you have uploaded",
"step_lock_text": "Editing this step is currently disabled. To make changes in Draft mode, please deactivate the migration.",
"lock": false,
"active": true,
Expand Down
22 changes: 16 additions & 6 deletions ui/src/pages/Migration/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -623,12 +623,22 @@ const Migration = () => {
}
});
} else {
event.preventDefault();
const url = `/projects/${projectId}/migration/steps/4`;
navigate(url, { replace: true });

await updateCurrentStepData(selectedOrganisation.value, projectId);
handleStepChange(3);
const res = await updateCurrentStepData(selectedOrganisation.value, projectId);
if (res?.status === 200) {
setIsLoading(false);
event.preventDefault();
handleStepChange(3);
const url = `/projects/${projectId}/migration/steps/4`;
navigate(url, { replace: true });
} else {
setIsLoading(false);
Notification({
notificationContent: { text: res?.data?.error?.message },
type: 'error'
});
}

}
};

Expand Down Expand Up @@ -722,7 +732,7 @@ const Migration = () => {
<div className="steps-wrapper">
<HorizontalStepper
ref={stepperRef}
steps={createStepper(projectData ?? defaultMigrationResponse, handleClick)}
steps={createStepper(projectData ?? defaultMigrationResponse, handleStepChange)}
handleSaveCT={saveRef?.current?.handleSaveContentType}
changeDropdownState={changeDropdownState}
projectData={projectData || defaultMigrationResponse}
Expand Down
Loading