Skip to content

Commit 96375f8

Browse files
authored
Merge pull request #603 from contentstack/feature/content-mapper
Language mapper and Legacy CMS step changes
2 parents 9d2325e + d994a0b commit 96375f8

File tree

5 files changed

+28
-34
lines changed

5 files changed

+28
-34
lines changed

ui/src/cmsData/legacyCms.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@
327327
},
328328
"title": "Select CMS",
329329
"description": "Select the CMS you are migrating content from",
330-
"step_lock_text": "Editing this step is currently disabled. To make changes in Draft mode, please deactivate the migration.",
330+
"step_lock_text": "Editing this step is currently disabled. To make changes in Draft mode, please deactivate the migration",
331331
"lock": false,
332332
"active": true,
333333
"empty_step_placeholder": "No CMS selected..."
@@ -339,7 +339,7 @@
339339
},
340340
"title": "Add Source Affix",
341341
"description": "Add a 2–5 character affix for the source name. Use only letters, no numbers or special characters",
342-
"step_lock_text": "Editing this step is currently disabled. To make changes in Draft mode, please deactivate the migration.",
342+
"step_lock_text": "Editing this step is currently disabled. To make changes in Draft mode, please deactivate the migration",
343343
"lock": false,
344344
"active": false,
345345
"empty_step_placeholder": "No affix Entered..."
@@ -351,7 +351,7 @@
351351
},
352352
"title": "Select File Format",
353353
"description": "Select the file format compatible with the selected CMS",
354-
"step_lock_text": "Editing this step is currently disabled. To make changes in Draft mode, please deactivate the migration.",
354+
"step_lock_text": "Editing this step is currently disabled. To make changes in Draft mode, please deactivate the migration",
355355
"lock": false,
356356
"active": true,
357357
"empty_step_placeholder": "No File Format selected..."
@@ -363,7 +363,7 @@
363363
},
364364
"title": "Uploaded File",
365365
"description": "This is the file you have uploaded",
366-
"step_lock_text": "Editing this step is currently disabled. To make changes in Draft mode, please deactivate the migration.",
366+
"step_lock_text": "Editing this step is currently disabled. To make changes in Draft mode, please deactivate the migration",
367367
"lock": false,
368368
"active": true,
369369
"empty_step_placeholder": "No File Uploaded..."
@@ -373,7 +373,7 @@
373373
"title": "https://www.contentstack.com/docs/developers/create-content-types/restricted-keywords-for-uids",
374374
"href": "https://www.contentstack.com/docs/developers/create-content-types/restricted-keywords-for-uids"
375375
},
376-
"file_format_checkbox_text": "Please acknowledge that you have read the file export guidelines.",
376+
"file_format_checkbox_text": "Please acknowledge that you have read the file export guidelines",
377377
"restricted_keyword_checkbox_text": "Please acknowledge that you have referred to the Contentstack restricted keywords",
378378
"affix_cta": "Continue",
379379
"file_format_cta": "Continue"

ui/src/components/ContentMapper/index.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -612,10 +612,12 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
612612
useBlockNavigation(isModalOpen);
613613
// Method to fetch content types
614614
const fetchContentTypes = async (searchText: string) => {
615+
setIsLoading(true);
616+
615617
try {
616-
setIsLoading(true);
617618
const { data } = await getContentTypes(projectId || '', 0, 5000, searchContentType || ''); //org id will always present
618619

620+
setIsLoading(false);
619621
setContentTypes(data?.contentTypes);
620622
setCount(data?.contentTypes?.length);
621623
setFilteredContentTypes(data?.contentTypes);
@@ -670,8 +672,8 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
670672

671673
const validTableData = data?.fieldMapping?.filter((field: FieldMapType) => field?.otherCmsType !== undefined);
672674

673-
setTableData(validTableData || []);
674-
setSelectedEntries(validTableData);
675+
setTableData(validTableData ?? []);
676+
setSelectedEntries(validTableData ?? []);
675677
setTotalCounts(validTableData?.length);
676678
setInitialRowSelectedData(validTableData?.filter((item: FieldMapType) => !item?.isDeleted))
677679
setIsLoading(false);
@@ -1072,6 +1074,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
10721074
maxWidth="290px"
10731075
isClearable={false}
10741076
options={option}
1077+
menuPlacement="auto"
10751078
isDisabled={
10761079
data?.otherCmsType === "Group" ||
10771080
data?.otherCmsField === 'title' ||
@@ -1577,6 +1580,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
15771580
isClearable={selectedOptions?.includes?.(existingField?.[data?.uid]?.label ?? '')}
15781581
options={adjustedOptions}
15791582
isDisabled={OptionValue?.isDisabled || newMigrationData?.project_current_step > 4}
1583+
menuPlacement="auto"
15801584
/>
15811585
</div>
15821586
{(!OptionValue?.isDisabled || OptionValue?.label === 'Dropdown'||

ui/src/components/DestinationStack/Actions/LoadLanguageMapper.tsx

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ const Mapper = ({
6868
if (selectedCsOptions?.length === 0) {
6969
setcsOptions(options);
7070
}
71+
7172
}, [options]);
7273

7374
useEffect(() => {
@@ -79,15 +80,16 @@ const Mapper = ({
7980
useEffect(() => {
8081
const formattedoptions = options?.filter(
8182
(item: { label: string; value: string }) =>
82-
!selectedCsOptions?.some((selected: string) => selected === item?.value)
83+
!selectedCsOptions?.some((selected: string) => selected === item?.value) && !cmsLocaleOptions?.some((locale: {label: string, value: string}) => locale?.label === item?.value)
8384
);
85+
8486
const adjustedOptions = sourceOptions?.filter(
8587
(item: { label: string; value: string }) =>
8688
!selectedSourceOption?.some((selected: string) => selected === item?.label)
8789
);
8890
setcsOptions(formattedoptions);
8991
setsourceoptions(adjustedOptions);
90-
}, [selectedCsOptions, selectedSourceOption]);
92+
}, [selectedCsOptions, selectedSourceOption, options]);
9193

9294
useEffect(() => {
9395
setExistingField((prevExisting: ExistingFieldType) => {
@@ -117,6 +119,12 @@ const Mapper = ({
117119
type: 'csLocale' | 'sourceLocale'
118120
) => {
119121
const selectedLocaleKey = selectedValue?.value;
122+
123+
if (!selectedValue?.label) {
124+
setselectedCsOption((prevSelected) =>
125+
prevSelected?.filter((item) => item !== existingField?.[index]?.label)
126+
);
127+
}
120128

121129

122130
setExistingField((prevOptions: ExistingFieldType) => {
@@ -285,6 +293,7 @@ const Mapper = ({
285293
isDisabled={true} // Ensure it's disabled
286294
className="select-container"
287295
noOptionsMessage={() => ''}
296+
menuPlacement="auto"
288297
/>
289298
</div>
290299
</Tooltip>
@@ -306,6 +315,7 @@ const Mapper = ({
306315
isClearable={true}
307316
isDisabled={isDisabled}
308317
className="select-container"
318+
menuPlacement="auto"
309319
/>
310320
)}
311321
<span className="span">-</span>
@@ -354,6 +364,7 @@ const Mapper = ({
354364
isClearable={true}
355365
isDisabled={isDisabled}
356366
className="select-container"
367+
menuPlacement="auto"
357368
/>
358369
}
359370
<div className={''}>
@@ -508,21 +519,9 @@ const LanguageMapper = () => {
508519
isDisabled={newMigrationData?.project_current_step > 2}
509520
/>
510521
}
511-
// footerComponent={
512-
// <Button className="ml-10 mt-10 mb-10"
513-
// buttonType="secondary"
514-
// version={'v2'}
515-
// icon="AddPlus"
516-
// onClick={addRowComp}
517-
// size='small'>
518-
// Add Language
519-
// </Button>
520-
521-
// }
522522
type="Secondary"
523523
/>
524524
<Button
525-
className="mt-10"
526525
buttonType="secondary"
527526
aria-label="add language"
528527
version={'v2'}

ui/src/components/DestinationStack/DestinationStack.scss

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,6 @@
197197
align-items: center;
198198
padding: $px-10;
199199
}
200-
.lang-container {
201-
//display: flex;
202-
//flex-wrap: wrap;
203-
//padding: $px-20;
204-
//padding-bottom: 50px;
205-
}
206200
.language-mapper {
207201
border-top: 1px solid $color-brand-secondary-lightest;
208202
margin-top: 16px;
@@ -212,7 +206,6 @@
212206
&.Field--full {
213207
.field-content {
214208
width: 100% !important;
215-
//border-left: none !important;
216209
}
217210
}
218211
}
@@ -250,13 +243,11 @@
250243
margin-top: 10px;
251244
overflow: visible !important;
252245
position: relative;
253-
//width: 120px;
254246
}
255247
.lang-container {
256-
// margin-bottom: 30px;
257-
// margin-left: 10px;
258-
// margin-top: 10px;
259248
display: flex;
249+
margin-bottom: 20px;
250+
margin-top: 10px;
260251
}
261252
.info-tag {
262253
max-width: 500px;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const LoadPreFix = (props: LoadSelectCmsProps) => {
6767
} else if (!isValidPrefix(value)) {
6868
setIsRestrictedKey(false);
6969
setIsError(true);
70-
setErrorMessage('Affix must be 2 to 5 letters, with no numbers or special characters.');
70+
setErrorMessage('Affix must be 2 to 5 letters, with no numbers or special characters');
7171
const newMigrationDataObj: INewMigration = {
7272
...newMigrationData,
7373
legacy_cms: {

0 commit comments

Comments
 (0)