Skip to content
Closed
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
1,240 changes: 661 additions & 579 deletions api/package-lock.json

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions api/src/services/migration.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,11 +461,11 @@ const startTestMigration = async (req: Request): Promise<any> => {
default:
break;
}
if (cms !== CMS.AEM) {
await testFolderCreator?.({
destinationStackId: project?.current_test_stack_id,
});
}
// if (cms !== CMS.AEM) {
// await testFolderCreator?.({
// destinationStackId: project?.current_test_stack_id,
// });
// }
await utilsCli?.runCli(
region,
user_id,
Expand Down Expand Up @@ -716,7 +716,7 @@ const startMigration = async (req: Request): Promise<any> => {
);
break;
}

default:
break;
}
Expand Down
14 changes: 5 additions & 9 deletions api/src/services/sitecore.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,7 @@ const createEntry = async ({
for await (const ctType of contentTypes) {
const message = getLogMessage(
srcFunc,
`Transforming entries of Content Type ${
keyMapper?.[ctType?.contentstackUid] ?? ctType?.contentstackUid
`Transforming entries of Content Type ${keyMapper?.[ctType?.contentstackUid] ?? ctType?.contentstackUid
} has begun.`,
{}
);
Expand Down Expand Up @@ -395,9 +394,8 @@ const createEntry = async ({
entryLocale[uid] = unflatten(entryObj) ?? {};
const message = getLogMessage(
srcFunc,
`Entry title "${entryObj?.title}"(${
keyMapper?.[ctType?.contentstackUid] ??
ctType?.contentstackUid
`Entry title "${entryObj?.title}"(${keyMapper?.[ctType?.contentstackUid] ??
ctType?.contentstackUid
}) in the ${newLocale} locale has been successfully transformed.`,
{}
);
Expand All @@ -413,7 +411,7 @@ const createEntry = async ({
);
const mapperCt: string =
keyMapper?.[ctType?.contentstackUid] !== '' &&
keyMapper?.[ctType?.contentstackUid] !== undefined
keyMapper?.[ctType?.contentstackUid] !== undefined
? keyMapper?.[ctType?.contentstackUid]
: ctType?.contentstackUid;
const fileMeta = { '1': `${newLocale}.json` };
Expand All @@ -428,8 +426,7 @@ const createEntry = async ({
} else {
const message = getLogMessage(
srcFunc,
`No entries found for the content type ${
keyMapper?.[ctType?.contentstackUid] ?? ctType?.contentstackUid
`No entries found for the content type ${keyMapper?.[ctType?.contentstackUid] ?? ctType?.contentstackUid
}.`,
{}
);
Expand Down Expand Up @@ -490,7 +487,6 @@ const createLocale = async (
{}
);
await customLogger(projectId, destinationStackId, 'info', message);
} else {
}
}

Expand Down
16 changes: 10 additions & 6 deletions api/src/utils/entries-field-creator.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,12 @@ export const entriesFieldCreator = async ({

case 'dropdown': {
const isOptionPresent = field?.advanced?.options?.find(
(ops: any) => ops?.key === content || ops?.value === content
(ops: any) =>
ops?.key === content ||
ops?.value === content ||
ops?.uid === content ||
// Check if content matches any part of a compound uid (format: {guid}/{guid})
(ops?.uid && ops?.uid.includes('/') && ops?.uid.split('/').includes(content))
);
if (isOptionPresent) {
if (field?.advanced?.Multiple) {
Expand Down Expand Up @@ -248,7 +253,7 @@ export const entriesFieldCreator = async ({
});
return allAssetJSON?.[assetUid] ?? null;
} else {
console.info('more', item?.attrs);
console.info('File not found', item?.attrs);
}
}
return null;
Expand All @@ -275,6 +280,7 @@ export const entriesFieldCreator = async ({
}

case 'reference': {
console.info("=====", content, field?.refrenceTo)
const refs: any = [];
if (field?.refrenceTo?.length) {
field?.refrenceTo?.forEach((entry: any) => {
Expand Down Expand Up @@ -373,8 +379,7 @@ export const entriesFieldCreator = async ({
// Check if the date is valid
if (!dayjsDate.isValid()) {
console.warn(
`Invalid date format for field: ${
field?.contentstackFieldUid || 'unknown'
`Invalid date format for field: ${field?.contentstackFieldUid || 'unknown'
}, value: ${content}`
);
return null;
Expand All @@ -383,8 +388,7 @@ export const entriesFieldCreator = async ({
return dayjsDate.toISOString();
} catch (error) {
console.error(
`Error converting date for field: ${
field?.contentstackFieldUid || 'unknown'
`Error converting date for field: ${field?.contentstackFieldUid || 'unknown'
}, value: ${content}`,
error
);
Expand Down
5 changes: 1 addition & 4 deletions ui/src/components/DestinationStack/Actions/LoadStacks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,7 @@ const LoadStacks = (props: LoadFileFormatProps) => {
master_locale: stack?.master_locale,
locales: stack?.locales,
created_at: stack?.created_at,
isNewStack: newStackCreated,
isDisabled: newMigrationDataRef?.current?.destination_stack?.migratedStacks?.includes(
stack?.api_key
)
isNewStack: newStackCreated
}))
: [];

Expand Down
26 changes: 2 additions & 24 deletions ui/src/components/LogScreen/MigrationLogViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ const MigrationLogViewer = ({ serverPath }: LogsType) => {
const [zoomLevel, setZoomLevel] = useState(1);

const newMigrationData = useSelector((state: RootState) => state?.migration?.newMigrationData);
const selectedOrganisation = useSelector(
(state: RootState) => state?.authentication?.selectedOrganisation
);

const user = useSelector((state: RootState) => state?.authentication?.user);

const dispatch = useDispatch();
Expand Down Expand Up @@ -157,11 +155,6 @@ const MigrationLogViewer = ({ serverPath }: LogsType) => {
* Zooms out the logs container.
*/
const handleZoomOut = () => {
// const logsContainer = document.querySelector('.logs-magnify') as HTMLElement;
// if (logsContainer) {
// setZoomLevel(prevZoomLevel => prevZoomLevel - 0.1);
// logsContainer.style.transform = `scale(${zoomLevel})`;
// }
setZoomLevel((prevZoomLevel) => {
const newZoomLevel = Math.max(prevZoomLevel - 0.1, 0.6); // added minimum level for zoom out
return newZoomLevel;
Expand Down Expand Up @@ -261,26 +254,11 @@ const MigrationLogViewer = ({ serverPath }: LogsType) => {
>
{logs.map((log, index) => {
try {
//const logObject = JSON.parse(log);
const { level, timestamp, message } = log;

return newMigrationData?.destination_stack?.migratedStacks?.includes(
newMigrationData?.destination_stack?.selectedStack?.value
) ? (
<div
key={`${index?.toString}`}
style={logStyles[level || ''] || logStyles.info}
className="log-entry text-center"
>
<div className="log-message generic-log-message">
Migration has already done in selected stack. Please create a new project.
</div>
</div>
) : (
return (
<div
key={index}
// style={logStyles[level || ''] || logStyles.info}
// className="log-entry logs-bg"
>
{message === 'Migration logs will appear here once the process begins.' ? (
<div
Expand Down
3 changes: 1 addition & 2 deletions ui/src/components/MigrationFlowHeader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ const MigrationFlowHeader = ({
isFileValidated :
isStep4AndNotMigrated ||
isStepInvalid ||
isExecutionStarted ||
destinationStackMigrated
isExecutionStarted
}
>
{stepValue}
Expand Down
113 changes: 89 additions & 24 deletions upload-api/migration-sitecore/libs/contenttypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,47 +334,62 @@ const ContentTypeSchema = ({
};
}
default: {
return {
id,
uid: sitecoreKey,
otherCmsField: name,
otherCmsType: type,
contentstackField: name,
contentstackFieldUid: uidCorrector({ uid }),
contentstackFieldType: 'reference',
backupFieldUid: uid,
backupFieldType: 'reference'
};
return null;
// return {
// id,
// uid: sitecoreKey,
// otherCmsField: name,
// otherCmsType: type,
// contentstackField: name,
// contentstackFieldUid: uidCorrector({ uid }),
// contentstackFieldType: 'reference',
// backupFieldUid: uid,
// backupFieldType: 'reference'
// };
}
}
};

function makeUnique({ data }) {
const newData = data;
let tempMapping = {};

if (newData?.[0]?.key) {
newData?.forEach((choice) => {
if (choice?.key) {
if (!tempMapping?.[choice?.value]) {
tempMapping[choice?.value] = [];
tempMapping[choice?.value] = {
keys: [],
uids: []
};
}
tempMapping[choice?.value].keys.push(choice?.key);
if (choice?.uid) {
tempMapping[choice?.value].uids.push(choice?.uid);
}
tempMapping[choice?.value].push(choice?.key);
}
});
const result = Object?.entries(tempMapping).map(([value, keys]) => {

const result = Object?.entries(tempMapping).map(([value, data]) => {
return {
key: keys?.join('/'),
value: value
key: data.keys?.join('/'),
value: value,
uid: data.uids?.join('/') || undefined
};
});

const newValue = [];
result?.forEach((item) => {
if (item?.key === undefined) {
newValue?.push({ ...item, key: item?.value });
} else {
newValue?.push(item);
const newItem = {
key: item?.key === undefined ? item?.value : item?.key,
value: item?.value
};
if (item?.uid) {
newItem.uid = item.uid;
}
newValue?.push(newItem);
});

return newValue;
} else {
let uniqueValues = [];
Expand All @@ -386,18 +401,28 @@ function makeUnique({ data }) {
return true;
}
});

const newValue = [];
result?.forEach((item) => {
if (item?.key === undefined) {
newValue?.push({ ...item, key: item?.value });
} else {
newValue?.push(item);
const newItem = {
key: item?.key === undefined ? item?.value : item?.key,
value: item?.value
};
if (item?.uid) {
newItem.uid = item.uid;
}
newValue?.push(newItem);
});

return newValue;
}
}

function findValueByKey(fields, searchKey) {
const field = fields.find(f => f.$?.key === searchKey);
return field?.content || null;
}

const groupFlat = (data, item) => {
const flat = [];
if (
Expand Down Expand Up @@ -507,6 +532,46 @@ const contentTypeMapper = ({
}
}
}
const sourcePaths = read(
path?.join?.(
sitecore_folder,
'master',
item?.content?.replace?.('Datasource=', '')?.replace?.('Interest', 'interest')
)
);
if (sourcePaths?.length) {
const optionsArray = [];
let ctDataUid = null;
for (const pth of sourcePaths) {
if (pth?.endsWith?.('data.json')) {
const fileData = helper?.readFile?.(
path?.join?.(sitecore_folder, 'master', item?.content?.replace?.('Datasource=', '')?.replace?.('Interest', 'interest'), pth)
);
const fields = fileData?.item?.fields?.field || [];
const key = findValueByKey(fields, "key");
const value = findValueByKey(fields, "value");
if (key && value) {
optionsArray?.push({ key, value, uid: fileData?.item?.$?.id });
} else {
if (pth?.startsWith?.('{') && pth?.endsWith?.('data.json')) {
ctDataUid = fileData?.item?.$?.template
}
}
}
}
if (optionsArray?.length === 0) {
contentTypeKeyMapper({
template: { id: content_type?.contentstackUid },
contentType: { uid: { name, uid: field?.key, unique: [ctDataUid] } },
contentTypeKey: 'treeListRef'
});
} else {
sourceType = makeUnique({ data: optionsArray });
compType.content = 'Droplist';
}
} else {
console.info('No paths found for source:', item?.content);
}
} else {
if (source) {
if (item?.content?.includes('datasource=')) {
Expand Down
Loading