Skip to content
14 changes: 11 additions & 3 deletions ui/src/components/ContentMapper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,15 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
[key]: { label: item?.display_name, value: item },
}));
}
if (item?.data_type === "group" && Array.isArray(item?.schema)) {
if(contentTypeSchema?.every((item)=> value?.value?.uid !== item?.uid)){
setExistingField((prevOptions: ExistingFieldType) => {
const { [key]: _, ...rest } = prevOptions; // Destructure to exclude the key to remove
return {
...rest
};
})
}
else if (item?.data_type === "group" && Array.isArray(item?.schema)) {
item?.schema?.forEach((schemaItem) => {

if (value?.value?.uid === schemaItem?.uid && value?.label === `${item?.display_name} > ${schemaItem?.display_name}`) {
Expand Down Expand Up @@ -1918,7 +1926,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
...newMigrationData,
content_mapping:{
...newMigrationData?.content_mapping,
existingCT: contentTypes,
[isContentType ? 'existingCT' : 'existingGlobal']: contentTypes,
content_type_mapping : updatedContentTypeMapping

}
Expand Down Expand Up @@ -2289,7 +2297,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
</span>
<span className='ml-10'>
<Tooltip content="Schema Preview" position="bottom">
<button className='list-button schema-preview' onClick={() => handleSchemaPreview(content?.otherCmsTitle, content?.id ?? '')}>{SCHEMA_PREVIEW}</button>
<button className='list-button schema-preview' aria-label="schemaPreview" onClick={() => handleSchemaPreview(content?.otherCmsTitle, content?.id ?? '')}>{SCHEMA_PREVIEW}</button>
</Tooltip>
</span>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ const LanguageMapper = () => {

setoptions(allLocales);
Object?.entries(newMigrationData?.destination_stack?.localeMapping)?.length === 0 &&
newMigrationData?.project_current_step <= 2 &&
setcmsLocaleOptions((prevList: { label: string; value: string }[]) => {
const newLabel = newMigrationData?.destination_stack?.selectedStack?.master_locale;

Expand Down
12 changes: 7 additions & 5 deletions ui/src/components/DestinationStack/Actions/LoadStacks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,10 @@ const LoadStacks = (props: LoadFileFormatProps) => {
dispatch(updateNewMigrationData(newMigrationDataObj));
}
const newMigrationDataObj: INewMigration = {
// ...newMigrationDataRef?.current,
...newMigrationData,
...newMigrationDataRef?.current,
//...newMigrationData,
destination_stack: {
...newMigrationData?.destination_stack,
...newMigrationDataRef?.current?.destination_stack,
csLocale: csLocales?.data?.locales
}
};
Expand Down Expand Up @@ -316,15 +316,17 @@ const LoadStacks = (props: LoadFileFormatProps) => {
</div>
</div>
<div className="col-12">
<label className="title">Master Locale <span className='asterisk_input'></span>
<label className="title" htmlFor="master_locale">Master Locale <span className='asterisk_input'></span>
</label>
<Tooltip content="Master Locale is auto-selected based on the chosen stack." position='right'>
<Icon icon='Information' version='v2' size='small'></Icon>
</Tooltip>

</div>
<div className="col-12 pb-2">
<div className="col-12 pb-2" id="master_locale">
<TextInput
id="master_locale"
aria-label="master_locale"
version={'v2'}
placeholder={selectedStack?.master_locale ? '' : 'Master Locale will be set after stack selection'}
value={selectedStack?.master_locale }
Expand Down
4 changes: 2 additions & 2 deletions ui/src/components/LegacyCms/Actions/LoadFileFormat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const LoadFileFormat = (props: LoadFileFormatProps) => {
...newMigrationDataRef?.current,
legacy_cms: {
...newMigrationDataRef?.current?.legacy_cms,
selectedFileFormat: selectedFileFormatObj
selectedFileFormat: selectedFileFormatObj,
}
};

Expand All @@ -131,7 +131,7 @@ const LoadFileFormat = (props: LoadFileFormatProps) => {
/**** ALL USEEffects HERE ****/
useEffect(()=>{
handleFileFormat();
handleBtnClick();
//handleBtnClick();
},[]);

useEffect(() => {
Expand Down
4 changes: 3 additions & 1 deletion ui/src/components/LegacyCms/Actions/LoadUploadFile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ const LoadUploadFile = (props: LoadUploadFileProps) => {
//const [isCancelLoading, setIsCancelLoading] = useState<boolean>(false);
//const [setIsFormatValid] = useState<boolean>(false);
const [affix, setAffix] = useState<string>(newMigrationData?.legacy_cms?.affix);
const [reValidate, setReValidate] = useState<boolean>(newMigrationData?.legacy_cms?.uploadedFile?.reValidate || false);

const { projectId = '' } = useParams();

Expand Down Expand Up @@ -394,6 +395,7 @@ const LoadUploadFile = (props: LoadUploadFileProps) => {
if(!isEmptyString(newMigrationData?.legacy_cms?.affix) && !newMigrationData?.legacy_cms?.uploadedFile?.isValidated ){
setIsDisabled(false);
}
setReValidate(newMigrationData?.legacy_cms?.uploadedFile?.reValidate || false);

// else{
// setIsValidated(false);
Expand Down Expand Up @@ -466,7 +468,7 @@ const LoadUploadFile = (props: LoadUploadFileProps) => {
isLoading={isLoading}
loadingColor="#6c5ce7"
version="v2"
disabled={isDisabled || isEmptyString(affix)}
disabled={isDisabled || isEmptyString(affix) || reValidate}
>
Validate File
</Button>
Expand Down
5 changes: 3 additions & 2 deletions ui/src/components/LegacyCms/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ const LegacyCMSComponent = forwardRef(({ legacyCMSData, isCompleted, handleOnAll
? selectedCmsData.allowed_file_formats?.find(
(cms: ICardType) => cms?.fileformat_id === legacyCMSData?.file_format
)
: defaultCardType;
: newMigrationData?.legacy_cms?.selectedFileFormat;

//Make Step 1 Complete
if (!isEmptyString(selectedCmsData?.cms_id || newMigrationData?.legacy_cms?.selectedCms?.cms_id)) {
Expand Down Expand Up @@ -164,7 +164,8 @@ const LegacyCMSComponent = forwardRef(({ legacyCMSData, isCompleted, handleOnAll
awsData: legacyCMSData?.awsDetails,
isLocalPath: legacyCMSData?.is_localPath
},
isValidated: legacyCMSData?.is_fileValid ,
isValidated: legacyCMSData?.is_fileValid,
reValidate: newMigrationData?.legacy_cms?.uploadedFile?.reValidate
}, //need to add backend data once endpoint exposed.
affix: legacyCMSData?.affix ?? '',
isFileFormatCheckboxChecked: true, //need to add backend data once endpoint exposed.
Expand Down
2 changes: 1 addition & 1 deletion ui/src/context/app/app.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ export const DEFAULT_NEW_MIGRATION: INewMigration = {
destination_stack: DEFAULT_DESTINATION_STACK,
content_mapping: DEFAULT_CONTENT_MAPPER,
test_migration: DEFAULT_TEST_MIGRATION,
isprojectMapped: false,
isprojectMapped: true,
stackDetails: DEFAULT_DROPDOWN,
testStacks: [],
migration_execution: DEFAULT_MIGRATION_EXECUTION_STEP,
Expand Down
25 changes: 13 additions & 12 deletions ui/src/pages/Migration/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,14 @@ const Migration = () => {
const [isLoading, setIsLoading] = useState(false);
const [currentStepIndex, setCurrentStepIndex] = useState(0);
const [isCompleted, setIsCompleted] = useState<boolean>(false);
const [isProjectMapper, setIsProjectMapper] = useState<boolean>(false);
const [isProjectMapper, setIsProjectMapper] = useState<boolean>(true);

const [disableMigration, setDisableMigration] = useState(false);
const [isModalOpen, setIsModalOpen] = useState(false);


const saveRef = useRef<ContentTypeSaveHandles>(null);
const newMigrationDataRef = useRef(newMigrationData);

useEffect(() => {
fetchData();
Expand All @@ -99,14 +100,14 @@ const Migration = () => {
/**
* Dispatches the isprojectMapped key to redux
*/
useEffect(()=> {
dispatch(updateNewMigrationData({
...newMigrationData,
isprojectMapped: isProjectMapper
// useEffect(()=> {
// dispatch(updateNewMigrationData({
// ...newMigrationDataRef?.current,
// isprojectMapped: isProjectMapper

}));
// }));

},[isProjectMapper]);
// },[isProjectMapper]);


useBlockNavigation(isModalOpen);
Expand Down Expand Up @@ -182,15 +183,14 @@ const Migration = () => {
*/
const fetchProjectData = async () => {
if (isEmptyString(selectedOrganisation?.value) || isEmptyString(params?.projectId)) return;

setIsProjectMapper(true);
const data = await getMigrationData(selectedOrganisation?.value, params?.projectId ?? '');
const migratedstacks = await getMigratedStacks(selectedOrganisation?.value, projectId );

if (data) {
setIsLoading(false);
setProjectData(data?.data);
}
setIsProjectMapper(true);
const projectData = data?.data;

const legacyCmsData:ILegacyCMSComponent = await getCMSDataFromFile(CS_ENTRIES.LEGACY_CMS);
Expand Down Expand Up @@ -239,11 +239,11 @@ const Migration = () => {
const projectMapper = {
...newMigrationData,
legacy_cms: {
...newMigrationData?.legacy_cms,
...newMigrationDataRef?.current?.legacy_cms,
selectedCms: selectedCmsData,
selectedFileFormat: selectedFileFormatData,
affix: projectData?.legacy_cms?.affix ,
uploadedFile: {
...newMigrationDataRef?.current?.legacy_cms,
file_details: {
localPath: projectData?.legacy_cms?.file_path,
awsData: {
Expand Down Expand Up @@ -289,6 +289,7 @@ const Migration = () => {
},
stackDetails: projectData?.stackDetails,
testStacks: projectData?.test_stacks,
isprojectMapped: false,
project_current_step: projectData?.current_step,
};

Expand Down Expand Up @@ -502,7 +503,7 @@ const Migration = () => {
} else if (! hasNonEmptyMapping) {
setIsLoading(false);
Notification({
notificationContent: { text: 'Please complete the language mapping to preceed futher' },
notificationContent: { text: 'Please complete the language mapping to proceed futher' },
type: 'warning'
});
}
Expand Down
Loading