Skip to content

Commit 7d61294

Browse files
committed
[CMG-538] - Contentful v1.0.0 | Content mapper | For group field selection or deselection, child is not selecting or deselecting and with that in test stack, its migrating Title and Url only
1 parent 49edecf commit 7d61294

File tree

6 files changed

+49
-57
lines changed

6 files changed

+49
-57
lines changed

ui/src/components/ContentMapper/contentMapper.interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ export interface ModifiedField {
191191
at: number;
192192
checked: boolean;
193193
id: string;
194-
otherCmsType: string;
194+
backupFieldType: string;
195195
parentId: string;
196196
uid: string;
197197
}

ui/src/components/ContentMapper/index.tsx

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -821,13 +821,13 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
821821
}
822822

823823
const modifiedObj = (obj: FieldMapType) => {
824-
const {otherCmsType, uid, id} = obj
824+
const {backupFieldType, uid, id} = obj
825825
const excludeArr = ["group"]
826826
return {
827827
id,
828-
otherCmsType,
828+
backupFieldType,
829829
uid,
830-
parentId : excludeArr?.includes(otherCmsType?.toLowerCase()) ? '' : getParentId(uid?.split('.')[0])
830+
parentId : excludeArr?.includes(backupFieldType?.toLowerCase()) ? '' : getParentId(uid?.split('.')[0]?.toLowerCase())
831831
}
832832
}
833833

@@ -897,9 +897,10 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
897897
// Get the latest action performed row
898898
const latestRow = findLatest(rowHistoryObj);
899899

900-
if(latestRow?.otherCmsType?.toLowerCase() === "group" && latestRow?.parentId === ''){
900+
if(latestRow?.backupFieldType?.toLowerCase() === "group" && latestRow?.parentId === '') {
901901
// get all child rows of group
902-
const childItems = tableData?.filter((entry) => entry?.uid?.startsWith(latestRow?.uid + '.'));
902+
const groupUid = latestRow?.uid?.toLowerCase();
903+
const childItems = tableData?.filter((entry) => entry?.uid?.toLowerCase()?.startsWith(groupUid + '.'));
903904
if (childItems && validateArray(childItems)) {
904905
if(latestRow?.checked){
905906
const lastEle = getLastElements(rowHistoryObj)
@@ -930,19 +931,19 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
930931
}
931932
} else if(latestRow?.parentId && !["title", "url"]?.includes(latestRow?.uid?.toLowerCase())){
932933
// Extract the group UID if item is child of any group
933-
const uidBeforeDot = latestRow?.uid?.split('.')[0];
934-
const groupItem = tableData?.find((entry) => entry?.uid === uidBeforeDot);
935-
const childItems = tableData?.filter((entry) => entry?.uid?.startsWith(groupItem?.uid + '.'));
934+
const uidBeforeDot = latestRow?.uid?.split('.')[0]?.toLowerCase();
935+
const groupItem = tableData?.find((entry) => entry?.uid === uidBeforeDot);
936+
const childItems = tableData?.filter((entry) => entry?.uid?.toLowerCase()?.startsWith(groupItem?.uid + '.'));
936937

937-
if(latestRow?.checked){
938+
if(latestRow?.checked) {
938939
if(!selectedObj[latestRow?.parentId]){
939940
selectedObj[latestRow?.parentId] = true
940941
}
941942
if(!selectedObj[latestRow?.id]){
942943
selectedObj[latestRow?.id] = true
943944
}
944-
}else{
945-
const lastEle = getLastElements(rowHistoryObj)
945+
} else {
946+
const lastEle = getLastElements(rowHistoryObj);
946947

947948
let allChildFalse = 0
948949
childItems?.forEach((child) => {
@@ -976,7 +977,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
976977
const handleValueChange = (value: FieldTypes, rowIndex: string) => {
977978
setIsDropDownChanged(true);
978979
setFieldValue(value);
979-
const updatedRows: FieldMapType[] = tableData?.map((row) => {
980+
const updatedRows: FieldMapType[] = selectedEntries?.map((row) => {
980981
if (row?.uid === rowIndex) {
981982
return { ...row, contentstackFieldType: value?.value };
982983
}
@@ -1124,8 +1125,8 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
11241125
item?.child?.some(e => e?.id)
11251126
)
11261127

1127-
if(groupArray?.[0]?.child && previousSelectedValue !== selectedValue?.label && groupArray[0]?.uid === rowIndex){
1128-
for(const item of groupArray[0]?.child ?? []){
1128+
if(groupArray?.[0]?.child && previousSelectedValue !== selectedValue?.label && groupArray?.[0]?.uid === rowIndex){
1129+
for(const item of groupArray?.[0]?.child ?? []){
11291130
deletedExstingField[item?.uid] = {
11301131
label:item?.uid,
11311132
value:existingField[item?.uid]
@@ -1298,7 +1299,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
12981299
OptionsForRow.push(getMatchingOption(value, true, updatedDisplayName, uid ?? ''));
12991300
}
13001301

1301-
const existingLabel = existingField[groupArray[0]?.uid]?.label ?? '';
1302+
const existingLabel = existingField[groupArray?.[0]?.uid]?.label ?? '';
13021303
const lastLabelSegment = existingLabel.includes('>')
13031304
? existingLabel?.split('>')?.pop()?.trim()
13041305
: existingLabel;
@@ -1309,7 +1310,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
13091310
for (const item of array) {
13101311
const fieldTypeToMatch = Fields[item?.backupFieldType as keyof Mapping]?.type;
13111312
if (item?.id === data?.id) {
1312-
for (const key of existingField[groupArray[0]?.uid]?.value?.schema || []) {
1313+
for (const key of existingField[groupArray?.[0]?.uid]?.value?.schema || []) {
13131314

13141315
if (checkConditions(fieldTypeToMatch, key, item)) {
13151316
OptionsForRow.push(getMatchingOption(key, true, `${updatedDisplayName} > ${key?.display_name}` || '', `${uid}.${key?.uid}`));
@@ -1422,7 +1423,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
14221423
item?.child?.some(e => e?.id === data?.id)
14231424
);
14241425

1425-
const array = groupArray[0]?.child || []
1426+
const array = groupArray?.[0]?.child || []
14261427

14271428
if(value.data_type === 'group'){
14281429
processSchema(value, data, array,groupArray, OptionsForRow, fieldsOfContentstack)
@@ -1440,33 +1441,33 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
14401441

14411442
// Handle case where there is exactly one match and it is auto-mapped
14421443
if(OptionsForRow?.length === 1 &&
1443-
(OptionsForRow[0]?.value?.uid === 'url' || OptionsForRow[0]?.value?.uid === 'title' || OptionsForRow[0]?.value?.data_type === 'group' || OptionsForRow[0]?.value?.data_type === 'reference'
1444+
(OptionsForRow?.[0]?.value?.uid === 'url' || OptionsForRow?.[0]?.value?.uid === 'title' || OptionsForRow?.[0]?.value?.data_type === 'group' || OptionsForRow?.[0]?.value?.data_type === 'reference'
14441445
))
14451446
{
14461447
updatedRows = updatedRows.map((row: FieldMapType) => {
14471448
if (row?.uid === data?.uid) {
14481449
return {
14491450
...row,
1450-
contentstackField: OptionsForRow[0]?.value?.display_name ?? '',
1451-
contentstackFieldUid: OptionsForRow[0]?.value?.uid ?? '',
1451+
contentstackField: OptionsForRow?.[0]?.value?.display_name ?? '',
1452+
contentstackFieldUid: OptionsForRow?.[0]?.value?.uid ?? '',
14521453
advanced: {
1453-
validationRegex: OptionsForRow[0]?.value?.format ?? '',
1454-
mandatory: OptionsForRow[0]?.value?.mandatory,
1455-
multiple: OptionsForRow[0]?.value?.multiple,
1456-
unique: OptionsForRow[0]?.value?.unique,
1457-
nonLocalizable: OptionsForRow[0]?.value?.non_localizable,
1454+
validationRegex: OptionsForRow?.[0]?.value?.format ?? '',
1455+
mandatory: OptionsForRow?.[0]?.value?.mandatory,
1456+
multiple: OptionsForRow?.[0]?.value?.multiple,
1457+
unique: OptionsForRow?.[0]?.value?.unique,
1458+
nonLocalizable: OptionsForRow?.[0]?.value?.non_localizable,
14581459
},
14591460
};
14601461
}
14611462
return row;
14621463
});
14631464

14641465
// Disable option if it's not already in existingField
1465-
if (!existingField[data?.uid] && OptionsForRow[0]) {
1466+
if (!existingField[data?.uid] && OptionsForRow?.[0]) {
14661467
OptionsForRow[0].isDisabled = true;
14671468
}
1468-
const newLabel = OptionsForRow[0]?.value?.display_name;
1469-
const newvalue = OptionsForRow[0]?.value;
1469+
const newLabel = OptionsForRow?.[0]?.value?.display_name;
1470+
const newvalue = OptionsForRow?.[0]?.value;
14701471

14711472
// Check if there's already a matching entry in updatedExstingField
14721473
const hasMatchingEntry = Object.values(updatedExstingField)?.some(
@@ -1483,7 +1484,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
14831484
existingField[data?.uid] = { label: newLabel, value: newvalue }
14841485
}
14851486

1486-
const newValue: string = OptionsForRow[0]?.value?.display_name;
1487+
const newValue: string = OptionsForRow?.[0]?.value?.display_name;
14871488
if (!updatedSelectedOptions?.includes(newValue)) {
14881489
updatedSelectedOptions.push(newValue);
14891490
}
@@ -1512,12 +1513,12 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
15121513

15131514
const OptionValue: FieldTypes =
15141515
OptionsForRow?.length === 1 && (existingField[data?.uid] || updatedExstingField[data?.uid] ) &&
1515-
(OptionsForRow[0]?.value?.uid === 'url' || OptionsForRow[0]?.value?.uid === 'title' || OptionsForRow[0]?.value?.data_type === 'group' || OptionsForRow[0]?.value?.data_type === 'reference'
1516+
(OptionsForRow?.[0]?.value?.uid === 'url' || OptionsForRow?.[0]?.value?.uid === 'title' || OptionsForRow?.[0]?.value?.data_type === 'group' || OptionsForRow?.[0]?.value?.data_type === 'reference'
15161517

15171518
)
15181519
? {
1519-
label: OptionsForRow[0]?.value?.display_name,
1520-
value: OptionsForRow[0]?.value,
1520+
label: OptionsForRow?.[0]?.value?.display_name,
1521+
value: OptionsForRow?.[0]?.value,
15211522
isDisabled: true
15221523
}
15231524
: (OptionsForRow?.length === 0 || (OptionsForRow?.length > 0 && OptionsForRow?.every((item)=>item?.isDisabled)

ui/src/components/LegacyCms/Actions/LoadUploadFile.tsx

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -429,22 +429,9 @@ const LoadUploadFile = (props: LoadUploadFileProps) => {
429429
<div className="col-12">
430430
<div className={containerClassName}>
431431
{!isConfigLoading && !isEmptyString(fileDetails?.localPath) ? (
432-
<div className='file-icon-group'>
432+
// <div className='file-icon-group'>
433433
<FileComponent fileDetails={fileDetails || {}} />
434-
{/* {(showMessage && !isCancelLoading) &&
435-
(<Tooltip content='cancel validation' position='top'>
436-
<Icon icon='CloseNoborder' version='v2' onClick={handleCancelValidation}/>
437-
438-
</Tooltip> )
439-
} */}
440-
{/* { isCancelLoading &&
441-
<div style={{justifyContent:'center', alignItems:'center', marginTop:'7px'}}>
442-
<AsyncLoader color='$color-brand-primary-base'/>
443-
</div>
444-
} */}
445-
</div>
446-
447-
434+
// </div>
448435
) :
449436

450437
<div className='loader'>

ui/src/components/LegacyCms/legacyCms.scss

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@
7474
margin-left: 10px !important;
7575
border: 1px solid $color-brand-secondary-lightest;
7676
border-radius: var(--TermCount, 5px);
77-
78-
}
79-
.validation-container > * {
80-
margin-right: 10px;
81-
margin-left: 15px;
77+
padding: 10px 15px;
8278
}
79+
// .validation-container > * {
80+
// margin-right: 10px;
81+
// margin-left: 15px;
82+
// }
8383
.error-container{
8484
display: flex;
8585
background-color: $color-base-white-5;

ui/src/context/app/app.provider.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ const AppContextProvider: FC<IProps> = ({ children }) => {
116116

117117
useEffect(() => {
118118
const token = getDataFromLocalStorage('app_token');
119-
setAuthToken(token || '');
119+
setAuthToken(token ?? '');
120120

121121
const storedNewMigration = sessionStorage.getItem('newMigration');
122122
if (storedNewMigration) {
@@ -129,6 +129,11 @@ const AppContextProvider: FC<IProps> = ({ children }) => {
129129
if (!isEmptyString(authToken)) {
130130
getUserDetails();
131131
}
132+
133+
// Debug token issue for hosting
134+
const token = getDataFromLocalStorage('app_token');
135+
setAuthToken(token ?? '');
136+
132137
}, [authToken]);
133138

134139
useEffect(() => {

upload-api/src/config/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export default {
22
plan: {
33
dropdown: { optionLimit: 100 }
44
},
5-
cmsType: 'Wordpress',
5+
cmsType: 'contentful',
66
isLocalPath: true,
77
awsData: {
88
awsRegion: 'us-east-2',
@@ -12,7 +12,6 @@ export default {
1212
bucketName: 'migartion-test',
1313
buketKey: 'project/package 45.zip'
1414
},
15-
16-
localPath: '/home/gaurishn/Documents/contentstack/sitetitle.xml' //package 45.zip'
15+
localPath: '/Users/sayali.joshi/Downloads/contentfulDummyEmbedData.json' //package 45.zip'
1716
// localPath: '/Users/umesh.more/Documents/ui-migration/migration-v2-node-server/upload-api/extracted_files/package 45.zip'
1817
};

0 commit comments

Comments
 (0)