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
4 changes: 2 additions & 2 deletions api/src/services/migration.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const createTestStack = async (req: Request): Promise<LoginServiceType> => {
.get("projects")
.findIndex({ id: projectId })
.value();
console.log(index);

if (index > -1) {
ProjectModelLowdb.update((data: any) => {
data.projects[index].current_test_stack_id = res.data.stack.uid;
Expand Down Expand Up @@ -143,7 +143,7 @@ const deleteTestStack = async (req: Request): Promise<LoginServiceType> => {
.get("projects")
.findIndex({ id: projectId })
.value();
console.log(index);

if (index > -1) {
ProjectModelLowdb.update((data: any) => {
data.projects[index].current_test_stack_id = "";
Expand Down
62 changes: 31 additions & 31 deletions api/src/services/projects.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,16 +240,16 @@ const updateLegacyCMS = async (req: Request) => {
throw new BadRequestError(HTTP_TEXTS.CANNOT_UPDATE_LEGACY_CMS);
}

if (project.current_step > STEPPER_STEPS.LEGACY_CMS) {
contentMapperService.removeMapping(projectId);
logger.info(
getLogMessage(
srcFunc,
`Content Mapping for project [Id : ${projectId}] has been successfully removed.`,
token_payload
)
);
}
// if (project.current_step > STEPPER_STEPS.LEGACY_CMS) {
// await contentMapperService.removeMapping(projectId);
// logger.info(
// getLogMessage(
// srcFunc,
// `Content Mapping for project [Id : ${projectId}] has been successfully removed.`,
// token_payload
// )
// );
// }

try {
ProjectModelLowdb.update((data: any) => {
Expand Down Expand Up @@ -383,16 +383,16 @@ const updateFileFormat = async (req: Request) => {
throw new BadRequestError(HTTP_TEXTS.CANNOT_UPDATE_FILE_FORMAT);
}

if (project.current_step > STEPPER_STEPS.LEGACY_CMS) {
contentMapperService.removeMapping(projectId);
logger.info(
getLogMessage(
srcFunc,
`Content Mapping for project [Id : ${projectId}] has been successfully removed.`,
token_payload
)
);
}
// if (project.current_step > STEPPER_STEPS.LEGACY_CMS) {
// await contentMapperService.removeMapping(projectId);
// logger.info(
// getLogMessage(
// srcFunc,
// `Content Mapping for project [Id : ${projectId}] has been successfully removed.`,
// token_payload
// )
// );
// }

try {
ProjectModelLowdb.update((data: any) => {
Expand Down Expand Up @@ -507,16 +507,16 @@ const updateDestinationStack = async (req: Request) => {
);
throw new BadRequestError(HTTP_TEXTS.CANNOT_UPDATE_DESTINATION_STACK);
}
if (project.current_step > STEPPER_STEPS.DESTINATION_STACK) {
await contentMapperService.resetAllContentTypesMapping(projectId);
logger.info(
getLogMessage(
srcFunc,
`Content Mapping for project [Id : ${projectId}] has been successfully reset.`,
token_payload
)
);
}
// if (project.current_step > STEPPER_STEPS.DESTINATION_STACK) {
// await contentMapperService.resetAllContentTypesMapping(projectId);
// logger.info(
// getLogMessage(
// srcFunc,
// `Content Mapping for project [Id : ${projectId}] has been successfully reset.`,
// token_payload
// )
// );
// }
try {
const [err, res] = await safePromise(
https({
Expand Down Expand Up @@ -760,7 +760,7 @@ const deleteProject = async (req: Request) => {
};

const revertProject = async (req: Request) => {
const { orgId, projectId } = req?.params;
const { orgId, projectId } = req.params;
const decodedToken = req.body.token_payload;
const { user_id = "", region = "" } = decodedToken;
const srcFunc = "revertProject";
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/LegacyCms/Actions/LoadPrefix.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const LoadPreFix = (props: LoadSelectCmsProps) => {
} else if (!isValidPrefix(value)) {
setIsRestrictedKey(false);
setIsError(true);
setErrorMessage('Affix should not contain more than 5 characters or fewer than 2.');
setErrorMessage('Affix should be 2 to 5 alphabetic characters');
} else {
setPrefix(value);
setIsError(false);
Expand Down
6 changes: 3 additions & 3 deletions ui/src/components/LegacyCms/Actions/LoadUploadFile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface Props {
fileDetails: FileDetails;
}

const FileComponent = ({fileDetails}:Props ) => {
const FileComponent = ({fileDetails}:Props ) => {

return (
<div>
Expand Down Expand Up @@ -120,7 +120,7 @@ const LoadUploadFile = (props: LoadUploadFileProps) => {
setIsValidated(true);
setValidationMessage('Validation is successful');

if(! isEmptyString(newMigrationData?.legacy_cms?.affix) || ! isEmptyString(newMigrationData?.legacy_cms?.selectedCms?.cms_id) || ! isEmptyString(newMigrationData?.legacy_cms?.selectedFileFormat?.fileformat_id)){
if(! isEmptyString(newMigrationData?.legacy_cms?.affix) && ! isEmptyString(newMigrationData?.legacy_cms?.selectedCms?.cms_id) && ! isEmptyString(newMigrationData?.legacy_cms?.selectedFileFormat?.fileformat_id)){
props.handleStepChange(props?.currentStep, true);
}

Expand Down Expand Up @@ -346,7 +346,7 @@ const LoadUploadFile = (props: LoadUploadFileProps) => {
const validationClassName = isValidated ? 'success' : 'error';

const containerClassName = `validation-container ${isValidationAttempted && !isValidated ? 'error-container pb-2' : ''}`;

return (
<div className="row">
<div className="col-12">
Expand Down
6 changes: 2 additions & 4 deletions ui/src/components/LegacyCms/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,8 @@ const LegacyCMSComponent = forwardRef(({ legacyCMSData, projectData, isCompleted
if (!isEmptyString(newMigrationData?.legacy_cms?.selectedCms?.cms_id) && !isEmptyString(newMigrationData?.legacy_cms?.affix)) {
setInternalActiveStepIndex(1);
}
if(!isEmptyString(newMigrationData?.legacy_cms?.selectedCms?.cms_id) && !isEmptyString(newMigrationData?.legacy_cms?.affix) && ! isEmptyString(newMigrationData?.legacy_cms?.selectedFileFormat?.fileformat_id)){
setInternalActiveStepIndex(2);
}
if(!isEmptyString(newMigrationData?.legacy_cms?.selectedCms?.cms_id) && !isEmptyString(newMigrationData?.legacy_cms?.affix) && ! isEmptyString(newMigrationData?.legacy_cms?.selectedFileFormat?.fileformat_id) && newMigrationData?.legacy_cms?.uploadedFile?.isValidated){

if(!isEmptyString(newMigrationData?.legacy_cms?.selectedCms?.cms_id) && !isEmptyString(newMigrationData?.legacy_cms?.affix) && newMigrationData?.legacy_cms?.uploadedFile?.isValidated){
setInternalActiveStepIndex(3);
}

Expand Down
19 changes: 7 additions & 12 deletions ui/src/pages/Migration/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,7 @@ const Migration = () => {
setIsLoading(false);

if (legacyCMSRef.current) {
const currentIndex = legacyCMSRef.current.getInternalActiveStepIndex() + 1;

const currentIndex = legacyCMSRef.current.getInternalActiveStepIndex() + 1;
let result;
switch (currentIndex ) {
case 0:
Expand All @@ -212,19 +211,15 @@ const Migration = () => {
result = 'Enter Affix';
break;
case 2:
result = 'File Format';
break;
case 3:
result = 'Imported File';
break;
default:
result = 'all';
break;
}
Notification({
notificationContent: { text: `Please complete ${result} step` },
type: 'warning'
});
if (currentIndex !== 3) {
Notification({
notificationContent: { text: `Please complete ${result} step` },
type: 'warning'
});
}
}

}
Expand Down
2 changes: 1 addition & 1 deletion uplaode-api/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
PORT=4002
NODE_BACKEND_API =http://localhost:5000
NODE_BACKEND_API =http://localhost:5001
2 changes: 1 addition & 1 deletion uplaode-api/src/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ router.get('/validator', express.json(), fileOperationLimiter, async function (r
throw new Error('No data collected from the stream.');
}
const data = await handleFileProcessing(fileExt, zipBuffer, cmsType);
res.json(data);
res.status(data?.status || 200).json(data);
if (data?.status === 200) {
const filePath = path.join(__dirname, '../../extracted_files', name);
createSitecoreMapper(filePath, projectId, app_token)
Expand Down
4 changes: 2 additions & 2 deletions uplaode-api/src/services/fileProcessing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const handleFileProcessing = async (fileExt: string, zipBuffer: any, cmsType: st
if (fileExt === 'zip') {
const zip = new JSZip();
await zip.loadAsync(zipBuffer);
if (validator({ data: zip, type: cmsType, extension: fileExt })) {
if (await validator({ data: zip, type: cmsType, extension: fileExt })) {
const isSaved = await saveZip(zip);
if (isSaved) {
logger.info('Validation success:', {
Expand Down Expand Up @@ -38,7 +38,7 @@ const handleFileProcessing = async (fileExt: string, zipBuffer: any, cmsType: st
// if file is not zip
// Convert the buffer to a string assuming it's UTF-8 encoded
const jsonString = Buffer?.from?.(zipBuffer)?.toString?.('utf8');
if (validator({ data: jsonString, type: cmsType, extension: fileExt })) {
if (await validator({ data: jsonString, type: cmsType, extension: fileExt })) {
logger.info('Validation success:', {
status: HTTP_CODES?.OK,
message: HTTP_TEXTS?.VALIDATION_SUCCESSFULL,
Expand Down
29 changes: 15 additions & 14 deletions uplaode-api/src/validators/sitecore/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,30 @@ async function sitecoreValidator({ data }: props) {
const configuration: any[] = [];
let blob: any[] = [];
let mediaLibrary: any[] = [];
Object.keys(data?.files).forEach(async function (filename: any) {
if (await filename?.includes?.('/templates')) {
templates?.push(await filename);
for (const filename of Object.keys(data?.files)) {
if (filename.includes('/templates') && !filename.includes('properties/items/master/sitecore/templates')) {
templates?.push(filename);
}
if (await filename?.includes?.('/content')) {
content?.push(await filename);
if (filename.includes('/content')) {
content?.push(filename);
}
//optional
if (await filename?.includes?.('/Configuration')) {
configuration?.push(await filename);
// optional
if (filename.includes('/Configuration')) {
configuration.push(filename);
}
if (await filename?.includes?.('/Blob')) {
blob?.push(await filename);
if (filename?.includes('/blob')) {
blob?.push(filename);
}
if (await filename?.includes?.('/media library')) {
mediaLibrary?.push(await filename);
if (filename?.includes('/media library')) {
mediaLibrary?.push(filename);
}
});
}
templates = await Promise.all(templates);
content = await Promise.all(content);
blob = await Promise.all(blob);
mediaLibrary = await Promise.all(mediaLibrary);
if (templates?.length > 0 && content?.length > 0 && blob?.length > 0 && mediaLibrary?.length > 0) {

if (templates?.length > 0 && content?.length > 0 && blob?.length > 0 && mediaLibrary?.length > 0) {
return true;
}
return false;
Expand Down