Skip to content
Merged

Dev #177

Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions api/src/services/contentMapper.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ import { ContentTypesMapper } from "../models/contentTypesMapper-lowdb.js";
// Developer service to create dummy contentmapping data
const putTestData = async (req: Request) => {
const projectId = req.params.projectId;
const contentTypes = req.body.contentTypes;
const contentTypes = req.body.contentTypes;

await FieldMapperModel.read();
contentTypes.map((type: any, index: any) => {
const fieldIds: string[] = [];
const fields = type?.fieldMapping?.map?.((field: any) => {
const id = uuidv4();
const id = field?.id || uuidv4();
fieldIds.push(id);
return { id, isDeleted: true, ...field };
});
Expand All @@ -45,7 +45,7 @@ const putTestData = async (req: Request) => {
await ContentTypesMapperModelLowdb.read();
const contentIds: string[] = [];
const contentType = contentTypes.map((item: any) => {
const id = uuidv4();
const id = item?.id || uuidv4();
contentIds.push(id);
return { ...item, id };
});
Expand Down
19 changes: 17 additions & 2 deletions ui/src/components/LegacyCms/Actions/LoadUploadFile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const LoadUploadFile = (props: LoadUploadFileProps) => {

const newMigrationData = useSelector((state:RootState)=>state?.migration?.newMigrationData);
const selectedOrganisation = useSelector((state:RootState)=>state?.authentication?.selectedOrganisation);
const migrationData = useSelector((state:RootState)=>state?.migration?.migrationData);


const dispatch = useDispatch();
Expand All @@ -70,7 +71,7 @@ const LoadUploadFile = (props: LoadUploadFileProps) => {
const [fileExtension, setFileExtension] = useState<string>('');
const [progressPercentage, setProgressPercentage] = useState<number>(0);
const [showProgress, setShowProgress]= useState<boolean>(false);
const [fileFormat, setFileFormat] = useState(newMigrationData?.legacy_cms?.selectedFileFormat?.title);
const [fileFormat, setFileFormat] = useState(newMigrationData?.legacy_cms?.selectedFileFormat?.fileformat_id);
const [processing, setProcessing] = useState('');
const [isCancelLoading, setIsCancelLoading] = useState<boolean>(false);

Expand Down Expand Up @@ -211,6 +212,20 @@ const LoadUploadFile = (props: LoadUploadFileProps) => {

dispatch(updateNewMigrationData(newMigrationDataObj));

const { all_cms = [] } = migrationData?.legacyCMSData || {};
let filteredCmsData:any = all_cms;
if (res?.data?.cmsType) {
filteredCmsData = all_cms?.filter((cms: any) => cms?.parent?.toLowerCase() === res?.data?.cmsType?.toLowerCase());
}

const isFormatValid = filteredCmsData[0]?.allowed_file_formats?.find((format: any) => {
const isValid = format?.fileformat_id?.toLowerCase() === extension;
return isValid;
});

setIsDisabled(!isFormatValid);



// if (res?.data?.localPath !== newMigrationData?.legacy_cms?.uploadedFile?.file_details?.localPath) {
// console.log("INNNNNNNNN",res?.data?.localPath, newMigrationData?.legacy_cms?.uploadedFile?.file_details?.localPath);
Expand Down Expand Up @@ -322,7 +337,7 @@ const LoadUploadFile = (props: LoadUploadFileProps) => {
// setIsValidated(false);
// }
},[isValidated,newMigrationData])

useEffect(()=>{
if(newMigrationData?.legacy_cms?.selectedFileFormat?.fileformat_id){
setFileFormat(newMigrationData?.legacy_cms?.selectedFileFormat?.fileformat_id);}
Expand Down
7 changes: 4 additions & 3 deletions ui/src/components/LegacyCms/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ const LegacyCMSComponent = forwardRef(({ legacyCMSData, projectData, isCompleted

//Update New Migration data;
const selectedCmsData: ICMSType = validateArray(data.all_cms)
? data.all_cms?.find((cms: ICMSType) => {
? data.all_cms?.some((cms: ICMSType) => {
return cms?.cms_id === legacyCMSData?.cms})
: DEFAULT_CMS_TYPE;

Expand Down Expand Up @@ -170,13 +170,14 @@ const LegacyCMSComponent = forwardRef(({ legacyCMSData, projectData, isCompleted
!isEmptyString(selectedFileFormatData?.fileformat_id)
) {
setInternalActiveStepIndex(2);
}
}
dispatch(updateNewMigrationData({
...newMigrationData,
legacy_cms: {
...newMigrationData?.legacy_cms,
currentStep: internalActiveStepIndex,
selectedCms: selectedCmsData,
selectedFileFormat: selectedFileFormatData || defaultCardType,
selectedFileFormat: selectedFileFormatData || newMigrationData?.legacy_cms?.selectedFileFormat ,
uploadedFile: {
file_details:{
localPath: legacyCMSData?.file_path,
Expand Down
6 changes: 4 additions & 2 deletions ui/src/components/MainHeader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,16 @@ const MainHeader = () => {
const handleonClick = async () => {
const currentIndex = newMigrationData?.legacy_cms?.currentStep + 1;
const pathSegments = location?.pathname.split('/');
const lastPathSegment = pathSegments[pathSegments.length - 1];
const lastPathSegment = pathSegments[pathSegments.length - 4];
const response = await getProject(selectedOrganisation?.uid || '', lastPathSegment);
const current_step = response?.data?.current_step;

const goback = () => {
dispatch(updateNewMigrationData(DEFAULT_NEW_MIGRATION))
navigate(`/projects`, { replace: true });
}

if(-1 < currentIndex && currentIndex < 4 && ( !isEmptyString(newMigrationData?.legacy_cms?.selectedCms?.cms_id) || !isEmptyString(newMigrationData?.legacy_cms?.affix) || newMigrationData?.legacy_cms?.uploadedFile?.isValidated ) && lastPathSegment === '1')
if(-1 < currentIndex && currentIndex < 4 && ( !isEmptyString(newMigrationData?.legacy_cms?.selectedCms?.cms_id) || !isEmptyString(newMigrationData?.legacy_cms?.affix) || newMigrationData?.legacy_cms?.uploadedFile?.isValidated ) && current_step === 1)
{

return cbModal({
Expand Down
11 changes: 11 additions & 0 deletions uplaode-api/migration-sitecore/libs/contenttypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ const ContentTypeSchema = ({ type, name, uid, default_value = "", description =
switch (type) {
case 'Single-Line Text': {
return {
id: id,
uid: sitecoreKey,
"otherCmsField": name,
"otherCmsType": type,
Expand All @@ -118,6 +119,7 @@ const ContentTypeSchema = ({ type, name, uid, default_value = "", description =
}
case 'Checkbox': {
return {
id: id,
uid: sitecoreKey,
"otherCmsField": name,
"otherCmsType": type,
Expand All @@ -130,6 +132,7 @@ const ContentTypeSchema = ({ type, name, uid, default_value = "", description =
}
case 'Rich Text': {
return {
id: id,
uid: sitecoreKey,
"otherCmsField": name,
"otherCmsType": type,
Expand All @@ -142,6 +145,7 @@ const ContentTypeSchema = ({ type, name, uid, default_value = "", description =

case 'Droplist': {
return {
id: id,
uid: sitecoreKey,
"otherCmsField": name,
"otherCmsType": type,
Expand All @@ -154,6 +158,7 @@ const ContentTypeSchema = ({ type, name, uid, default_value = "", description =

case "Image": {
return {
id: id,
uid: sitecoreKey,
"otherCmsField": name,
"otherCmsType": type,
Expand All @@ -166,6 +171,7 @@ const ContentTypeSchema = ({ type, name, uid, default_value = "", description =
case "General Link":
case "Internal Link": {
return {
id: id,
uid: sitecoreKey,
"otherCmsField": name,
"otherCmsType": type,
Expand All @@ -178,6 +184,7 @@ const ContentTypeSchema = ({ type, name, uid, default_value = "", description =

case "Multi-Line Text": {
return {
id: id,
uid: sitecoreKey,
"otherCmsField": name,
"otherCmsType": type,
Expand All @@ -192,6 +199,7 @@ const ContentTypeSchema = ({ type, name, uid, default_value = "", description =
case "Integer":
case "Number": {
return {
id: id,
uid: sitecoreKey,
"otherCmsField": name,
"otherCmsType": type,
Expand All @@ -206,6 +214,7 @@ const ContentTypeSchema = ({ type, name, uid, default_value = "", description =
case "Date":
case "Time": {
return {
id: id,
uid: sitecoreKey,
"otherCmsField": name,
"otherCmsType": type,
Expand All @@ -219,6 +228,7 @@ const ContentTypeSchema = ({ type, name, uid, default_value = "", description =
case 'Grouped Droplist': {
if (choices?.length) {
return {
id: id,
uid: sitecoreKey,
"otherCmsField": name,
"otherCmsType": type,
Expand All @@ -233,6 +243,7 @@ const ContentTypeSchema = ({ type, name, uid, default_value = "", description =
case "Treelist": {
if (sourLet?.key !== "source") {
return {
id: id,
uid: sitecoreKey,
"otherCmsField": name,
"otherCmsType": type,
Expand Down