-
Notifications
You must be signed in to change notification settings - Fork 8
Feature/cli optimise #598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/cli optimise #598
Changes from 1 commit
95c1394
39f66c8
47a94a4
04d5db7
9e81663
92d4f93
0815e4a
b0c5e79
4795e19
4a0510d
59448cc
27e1e06
0ccd460
4a2886e
72ae80f
3f8c00f
2575a74
0fed8a6
d399989
6c2e172
5950213
48fc79a
acaa527
a26f27a
aab5c08
ea3531d
8e6c55c
492c76e
d9f6c4f
822e878
6e3d5d8
f8c312f
4074906
2487445
91b4993
23af79d
bf8f200
342e897
970a3ea
a34198a
b8f3925
2d79661
b02be15
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -94,10 +94,31 @@ const Mapper = ({ | |
| useEffect(() => { | ||
| setExistingField((prevExisting: ExistingFieldType) => { | ||
| const updatedExisting = { ...prevExisting }; | ||
| const validLabels = cmsLocaleOptions?.map(locale => locale.label) || []; | ||
| Object.entries(updatedExisting).forEach(([index, entry]) => { | ||
| const [labelPart] = entry.label.split('-'); | ||
| if (!validLabels.includes(labelPart)) { | ||
| delete updatedExisting[index]; | ||
|
||
| } | ||
| }); | ||
|
|
||
| setSelectedMappings((prev) => { | ||
| const updated = { ...prev }; | ||
|
|
||
| Object.keys(updated).forEach((key) => { | ||
| const [labelPart] = key.split('-'); | ||
| if (!validLabels.includes(labelPart)) { | ||
| delete updated[key]; | ||
|
||
| } | ||
| }); | ||
|
|
||
| return updated; | ||
| }); | ||
|
|
||
| cmsLocaleOptions?.forEach((locale: { label: string; value: string }, index: number) => { | ||
| if (locale?.value === 'master_locale' && !updatedExisting?.[index]) { | ||
| setSelectedMappings((prev) => ({ | ||
|
|
||
| ...prev, | ||
| [`${locale?.label}-master_locale`]: '' | ||
| })); | ||
|
|
@@ -422,18 +443,28 @@ const LanguageMapper = () => { | |
| value: item | ||
| })); | ||
| setsourceLocales(sourceLocale); | ||
|
|
||
| setoptions(allLocales); | ||
| Object?.entries(newMigrationData?.destination_stack?.localeMapping)?.length === 0 && | ||
| const keys = Object.keys(newMigrationData?.destination_stack?.localeMapping || {})?.find( key => key === `${newMigrationData?.destination_stack?.selectedStack?.master_locale}-master_locale`); | ||
|
|
||
| (Object?.entries(newMigrationData?.destination_stack?.localeMapping)?.length === 0 || keys !== `${newMigrationData?.destination_stack?.selectedStack?.master_locale}-master_locale` ) && | ||
| newMigrationData?.project_current_step <= 2 && | ||
| setcmsLocaleOptions((prevList: { label: string; value: string }[]) => { | ||
| const newLabel = newMigrationData?.destination_stack?.selectedStack?.master_locale; | ||
|
|
||
| const isPresent = prevList.some( | ||
| (item: { label: string; value: string }) => item?.value === 'master_locale' | ||
| const isPresent = prevList.filter( | ||
|
||
| (item: { label: string; value: string }) => (item?.value === 'master_locale') | ||
| ); | ||
|
|
||
| if (!isPresent) { | ||
|
|
||
| if(isPresent[0]?.label !== newLabel){ | ||
|
||
| return [ | ||
| ...prevList.filter(item => item.value !== 'master_locale'), | ||
AishDani marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| label: newLabel, | ||
| value: 'master_locale', | ||
| } | ||
| ]; | ||
| } | ||
| if (isPresent?.length <= 0 ) { | ||
| return [ | ||
| ...prevList, | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const validLabels = cmsLocaleOptions?.map(locale => locale?.label) || [];
Object.entries(updatedExisting)?.forEach(([index, entry]) => {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done