Skip to content

Commit c496a78

Browse files
authored
Merge pull request #424 from contentstack/feature/test-migration
Content mapper bugfix
2 parents 666876d + 49596a3 commit c496a78

File tree

2 files changed

+24
-18
lines changed

2 files changed

+24
-18
lines changed

api/src/utils/content-type-creator.utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const arrangGroups = ({ schema, newStack }: any) => {
6363
})
6464
dtSchema?.push(groupSchema);
6565
} else {
66-
if (!(item?.contentstackField.includes('>') && item?.contentstackFieldUid.includes('.'))) {
66+
if (!(item?.contentstackField?.includes('>') && item?.contentstackFieldUid?.includes('.'))) {
6767
dtSchema?.push(item);
6868
}
6969
}

ui/src/components/ContentMapper/index.tsx

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -679,21 +679,21 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
679679
};
680680

681681
const openContentType = (i: number) => {
682-
setIsFieldDeleted(false);
683-
setActive(i);
684-
const otherTitle = filteredContentTypes?.[i]?.contentstackUid;
685-
const mappedContentType = contentModels && contentModels?.find((item)=> item?.uid === newMigrationData?.content_mapping?.content_type_mapping?.[otherTitle]);
686-
setOtherCmsTitle(filteredContentTypes?.[i]?.otherCmsTitle);
687-
setContentTypeUid(filteredContentTypes?.[i]?.id ?? '');
688-
fetchFields(filteredContentTypes?.[i]?.id ?? '', searchText || '');
689-
setOtherCmsUid(filteredContentTypes?.[i]?.otherCmsUid);
690-
setSelectedContentType(filteredContentTypes?.[i]);
691-
setIsContentType(filteredContentTypes?.[i]?.type === "content_type");
692-
setOtherContentType({
693-
label: mappedContentType?.title ?? `Select ${filteredContentTypes?.[i]?.type === "content_type" ? 'Content Type' : 'Global Field'} from existing stack`,
694-
value: mappedContentType?.title ?? `Select ${filteredContentTypes?.[i]?.type === "content_type" ? 'Content Type' : 'Global Field'} from existing stack`,
695-
696-
});
682+
setIsFieldDeleted(false);
683+
setActive(i);
684+
const otherTitle = filteredContentTypes?.[i]?.contentstackUid;
685+
const mappedContentType = contentModels?.find((item)=> item?.uid === newMigrationData?.content_mapping?.content_type_mapping?.[otherTitle]);
686+
setOtherCmsTitle(filteredContentTypes?.[i]?.otherCmsTitle);
687+
setContentTypeUid(filteredContentTypes?.[i]?.id ?? '');
688+
fetchFields(filteredContentTypes?.[i]?.id ?? '', searchText || '');
689+
setOtherCmsUid(filteredContentTypes?.[i]?.otherCmsUid);
690+
setSelectedContentType(filteredContentTypes?.[i]);
691+
setIsContentType(filteredContentTypes?.[i]?.type === "content_type");
692+
setOtherContentType({
693+
label: mappedContentType?.title ?? `Select ${filteredContentTypes?.[i]?.type === "content_type" ? 'Content Type' : 'Global Field'} from existing stack`,
694+
value: mappedContentType?.title ?? `Select ${filteredContentTypes?.[i]?.type === "content_type" ? 'Content Type' : 'Global Field'} from existing stack`,
695+
696+
});
697697
}
698698

699699
const updateFieldSettings = (rowId: string, updatedSettings: Advanced, checkBoxChanged: boolean) => {
@@ -2110,9 +2110,15 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
21102110
<button
21112111
type='button'
21122112
className='list-button ct-names'
2113-
onClick={() => handleOpenContentType(index)}
2113+
onClick={(e) => {
2114+
if (otherCmsUid === filteredContentTypes[index]?.otherCmsUid) {
2115+
e.preventDefault();
2116+
} else {
2117+
handleOpenContentType(index)
2118+
}
2119+
}}
21142120
onKeyDown={(e) => {
2115-
if (e.key === 'Enter') {
2121+
if (e.key === 'Enter' && otherCmsUid !== filteredContentTypes[index]?.otherCmsUid) {
21162122
handleOpenContentType(index);
21172123
}
21182124
}}

0 commit comments

Comments
 (0)