Skip to content

Commit 127ca45

Browse files
authored
Merge pull request #1007 from contentstack/bugfix/cmg-832
refactor: simplify option mapping in ContentMapper and improve destin…
2 parents 37aaa7b + 7b728ae commit 127ca45

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

ui/src/components/ContentMapper/index.tsx

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3008,20 +3008,19 @@ const ContentMapper = forwardRef(({ handleStepChange }: contentMapperProps, ref:
30083008
});
30093009
}
30103010

3011-
const options = contentModels?.map?.((item) => {
3012-
return {
3013-
label: item?.title,
3014-
value: item?.title,
3015-
id: item?.uid,
3016-
isDisabled: (contentTypeMapped && Object.values(contentTypeMapped).includes(item?.uid))
3017-
};
3018-
});
3019-
3020-
3011+
const isDestinationMappedByAnotherSource = (destinationUid: string | undefined) =>
3012+
!!destinationUid &&
3013+
!!contentTypeMapped &&
3014+
Object.entries(contentTypeMapped).some(
3015+
([sourceUid, mappedDestUid]) =>
3016+
mappedDestUid === destinationUid && sourceUid !== selectedContentType?.contentstackUid
3017+
);
30213018

3022-
const adjustedOption = options?.map?.((option) => ({
3023-
...option,
3024-
isDisabled: filteredContentTypes?.some?.((ct) => ct?.contentstackUid === option?.id) || (contentTypeMapped && Object.values(contentTypeMapped)?.includes?.(option?.id))
3019+
const adjustedOption = contentModels?.map?.((item) => ({
3020+
label: item?.title,
3021+
value: item?.title,
3022+
id: item?.uid,
3023+
isDisabled: isDestinationMappedByAnotherSource(item?.uid)
30253024
}));
30263025

30273026
// Function to toggle filter panel

0 commit comments

Comments
 (0)