diff --git a/ui/src/components/DestinationStack/Actions/LoadLanguageMapper.tsx b/ui/src/components/DestinationStack/Actions/LoadLanguageMapper.tsx index 23c302040..2c5be0421 100644 --- a/ui/src/components/DestinationStack/Actions/LoadLanguageMapper.tsx +++ b/ui/src/components/DestinationStack/Actions/LoadLanguageMapper.tsx @@ -32,12 +32,14 @@ const Mapper = ({ cmsLocaleOptions, handleLangugeDelete, options, - sourceOptions + sourceOptions, + isDisabled }: { cmsLocaleOptions: Array<{ label: string; value: string }>; handleLangugeDelete: (index: number, locale: { label: string; value: string }) => void; options: Array<{ label: string; value: string }>; sourceOptions: Array<{ label: string; value: string }>; + isDisabled: boolean }) => { const [selectedMappings, setSelectedMappings] = useState<{ [key: string]: string }>({}); const [existingField, setExistingField] = useState({}); @@ -259,7 +261,7 @@ const Mapper = ({ ) : ( handleSelectedSourceLocale(data, index, 'sourceLocale', locale) } + styles={{ + menuPortal: (base:any) => ({ ...base, zIndex: 9999 }) + }} options={sourceoptions} placeholder={placeholder} isSearchable - maxMenuHeight={150} + maxMenuHeight={100} multiDisplayLimit={5} - menuPortalTarget={document.querySelector('.language-mapper')} + //menuPortalTarget={document.querySelector('.mini-table')} + menuShouldScrollIntoView={true} width="270px" version="v2" hideSelectedOptions={true} isClearable={true} - isDisabled={false} + isDisabled={isDisabled} className="select-container" /> }
- {locale?.value !== 'master_locale' && ( + {locale?.value !== 'master_locale' && + !isDisabled && ( )} @@ -373,7 +381,8 @@ const LanguageMapper = () => { setsourceLocales(sourceLocale); setoptions(allLocales); - setcmsLocaleOptions((prevList: { label: string; value: string }[]) => { + Object?.entries(newMigrationData?.destination_stack?.localeMapping)?.length === 0 && + 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'); @@ -390,6 +399,28 @@ const LanguageMapper = () => { return prevList; }); + if (newMigrationData?.project_current_step > 2) { + Object.entries(newMigrationData?.destination_stack?.localeMapping || {})?.forEach(([key, value]) => { + setcmsLocaleOptions((prevList) => { + const labelKey = key?.replace(/-master_locale$/, ""); + + // Check if the key already exists in the list + const exists = prevList?.some((item) => item?.label === labelKey); + + if (!exists) { + return [ + ...prevList, + { + label: labelKey, + value: String(value), + }, + ]; + } + + return prevList; // Return the same list if key exists + }); + }); + } setisLoading(false); } catch (error) { console.error('Error fetching locales:', error); @@ -397,7 +428,7 @@ const LanguageMapper = () => { }; fetchData(); - }, []); + }, [newMigrationData?.destination_stack]); // const fetchLocales = async () => { // return await getStackLocales(newMigrationData?.destination_stack?.selectedOrg?.value); @@ -435,6 +466,7 @@ const LanguageMapper = () => { cmsLocaleOptions={cmsLocaleOptions} handleLangugeDelete={handleDeleteLocale} sourceOptions={sourceLocales} + isDisabled={newMigrationData?.project_current_step > 2} /> } // footerComponent={ @@ -461,7 +493,7 @@ const LanguageMapper = () => { disabled={ Object.keys(newMigrationData?.destination_stack?.localeMapping || {})?.length === newMigrationData?.destination_stack?.sourceLocale?.length || - cmsLocaleOptions?.length === newMigrationData?.destination_stack?.sourceLocale?.length + cmsLocaleOptions?.length === newMigrationData?.destination_stack?.sourceLocale?.length || newMigrationData?.project_current_step > 2 }> Add Language diff --git a/ui/src/components/DestinationStack/DestinationStack.scss b/ui/src/components/DestinationStack/DestinationStack.scss index a4650b1a9..01947872c 100644 --- a/ui/src/components/DestinationStack/DestinationStack.scss +++ b/ui/src/components/DestinationStack/DestinationStack.scss @@ -230,6 +230,12 @@ } } } + .field-content__content{ + height: auto !important; + max-height: unset !important; + overflow: visible !important; + z-index: 9999; + } } .span { padding: 10px 20px; @@ -254,6 +260,8 @@ .mini-table { margin-left: 40px; margin-top: 10px; + overflow: visible !important; + position: relative; //width: 120px; } .lang-container { diff --git a/ui/src/pages/Migration/index.tsx b/ui/src/pages/Migration/index.tsx index 70613b22c..f39310a2c 100644 --- a/ui/src/pages/Migration/index.tsx +++ b/ui/src/pages/Migration/index.tsx @@ -227,6 +227,15 @@ const Migration = () => { const stackLink = `${CS_URL[projectData?.region]}/stack/${projectData?.current_test_stack_id}/dashboard`; const stackName = projectData?.test_stacks?.find((stack:TestStacks)=> stack?.stackUid === projectData?.current_test_stack_id)?.stackName; + const masterLocaleEntries = projectData?.master_locale + ? Object?.entries(projectData?.master_locale).map(([key, value]) => [`${key}-master_locale`, value]) + : []; + + const locales = { + ...Object?.fromEntries(masterLocaleEntries), + ...projectData?.locales + }; + const projectMapper = { ...newMigrationData, legacy_cms: { @@ -258,7 +267,8 @@ const Migration = () => { stackArray: [], migratedStacks: migratedstacks?.data?.destinationStacks, sourceLocale: projectData?.source_locales, - csLocale: csLocales?.data?.locales + csLocale: csLocales?.data?.locales, + localeMapping: locales }, content_mapping: { isDropDownChanged: false, @@ -438,11 +448,10 @@ const Migration = () => { setIsLoading(true); const hasNonEmptyMapping = - newMigrationData?.destination_stack?.localeMapping && - Object.values(newMigrationData?.destination_stack?.localeMapping)?.some( - (value) => value !== '' || value !== null || value !== undefined - ); - console.log(hasNonEmptyMapping); + newMigrationData?.destination_stack?.localeMapping && + Object.values(newMigrationData?.destination_stack?.localeMapping)?.every( + (value) => value !== '' && value !== null && value !== undefined + ); const master_locale:any = {}; const locales: any= {}; @@ -456,7 +465,7 @@ const Migration = () => { if ( isCompleted && !isEmptyString(newMigrationData?.destination_stack?.selectedStack?.value) && - hasNonEmptyMapping + hasNonEmptyMapping ) { event?.preventDefault(); //Update Data in backend