Skip to content

Commit be47c79

Browse files
authored
Merge pull request #468 from contentstack/feature/dropdown-field-choices
refactor:added mapping for marketplace-app and extension for contentful
2 parents 2cb3e47 + ccfcda5 commit be47c79

File tree

2 files changed

+30
-9
lines changed

2 files changed

+30
-9
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export interface FieldMetadata {
102102
}
103103
export interface ContentTypesSchema {
104104
display_type: string;
105-
data_type?: 'text' | 'number' | 'isodate' | 'json' | 'file' | 'reference' | 'group' | 'boolean' | 'link';
105+
data_type?: 'text' | 'number' | 'isodate' | 'json' | 'file' | 'reference' | 'group' | 'boolean' | 'link' | 'Marketplace app' | 'Extension';
106106
display_name: string;
107107
enum?: any;
108108
error_messages?: ErrorMessages;

ui/src/components/ContentMapper/index.tsx

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,16 @@ const Fields: MappingFields = {
200200
label: 'Group',
201201
options: {'Group':'group'},
202202
type:'Group'
203+
},
204+
'app':{
205+
label: 'Marketplace app',
206+
options: {'Marketplace app':'app'},
207+
type:'app'
208+
},
209+
'extension':{
210+
label: 'Extension',
211+
options: {'Extension':'extension'},
212+
type:'extension'
203213
}
204214

205215
}
@@ -1061,7 +1071,9 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
10611071
data?.backupFieldType === 'reference'||
10621072
data?.contentstackFieldType === "global_field" ||
10631073
data?.otherCmsType === undefined ||
1064-
newMigrationData?.project_current_step > 4
1074+
newMigrationData?.project_current_step > 4 ||
1075+
data?.backupFieldType === 'extension' ||
1076+
data?.backupFieldType === 'app'
10651077
}
10661078
/>
10671079
</div>
@@ -1071,7 +1083,9 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
10711083
data?.otherCmsField === 'url' ||
10721084
data?.otherCmsType === 'reference' ||
10731085
data?.contentstackFieldType === 'global_field' ||
1074-
data?.otherCmsType === undefined
1086+
data?.otherCmsType === undefined ||
1087+
data?.backupFieldType === 'extension' ||
1088+
data?.backupFieldType === 'app'
10751089
) && (
10761090
<Tooltip
10771091
content="Advanced properties"
@@ -1427,7 +1441,8 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
14271441

14281442
// Handle case where there is exactly one match and it is auto-mapped
14291443
if(OptionsForRow?.length === 1 &&
1430-
(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'
1445+
))
14311446
{
14321447
updatedRows = updatedRows.map((row: FieldMapType) => {
14331448
if (row?.uid === data?.uid) {
@@ -1496,10 +1511,11 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
14961511
}
14971512

14981513

1499-
15001514
const OptionValue: FieldTypes =
15011515
OptionsForRow?.length === 1 && (existingField[data?.uid] || updatedExstingField[data?.uid] ) &&
1502-
(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'
1517+
1518+
)
15031519
? {
15041520
label: OptionsForRow[0]?.value?.display_name,
15051521
value: OptionsForRow[0]?.value,
@@ -1516,7 +1532,9 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
15161532
data?.backupFieldType === "reference" ||
15171533
data?.contentstackFieldType === "global_field" ||
15181534
data?.contentstackFieldType === "dropdown" ||
1519-
data?.otherCmsType === undefined
1535+
data?.otherCmsType === undefined ||
1536+
data?.backupFieldType === 'app' ||
1537+
data?.backupFieldType === 'extension'
15201538
}
15211539
: {
15221540
label: `${selectedOption} matches`,
@@ -1530,7 +1548,9 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
15301548
...option,
15311549
isDisabled: selectedOptions?.includes(option?.label ?? '')
15321550
}));
1533-
1551+
console.log("**** ", data?.backupFieldType,!OptionValue?.isDisabled , OptionValue?.label === 'Dropdown',
1552+
(data?.backupFieldType !== 'extension' && data?.backupFieldType !== 'app'));
1553+
15341554
return (
15351555
<div className="table-row">
15361556
<div className="select">
@@ -1551,7 +1571,8 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
15511571
isDisabled={OptionValue?.isDisabled || newMigrationData?.project_current_step > 4}
15521572
/>
15531573
</div>
1554-
{(!OptionValue?.isDisabled || OptionValue?.label === 'Dropdown') && (
1574+
{(!OptionValue?.isDisabled || OptionValue?.label === 'Dropdown'||
1575+
(data?.backupFieldType !== 'extension' && data?.backupFieldType !== 'app')) && (
15551576
<div className='advanced-setting-button'>
15561577
<Tooltip
15571578
content="Advanced properties"

0 commit comments

Comments
 (0)