Skip to content
Merged

Dev #185

Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
546cbc2
[CMG-214] - Destination Stack | Error message is not showing when max…
sayalijoshi27 Jul 9, 2024
7d6658c
Merge pull request #178 from contentstack/feature/CMG-57
v1shalpatel Jul 9, 2024
2231f01
logs details
RohitKini Jul 10, 2024
9754728
logger
RohitKini Jul 10, 2024
7c24b73
Conflict resolved
sayalijoshi27 Jul 10, 2024
3473dea
Merge branch 'feature/profile-design' of https://github.com/contentst…
sayalijoshi27 Jul 10, 2024
b0ac49b
refactor:resolved duplicate mapper fields
AishDani Jul 10, 2024
2e3782b
refactor:removed console
AishDani Jul 10, 2024
5326ca9
Merge pull request #179 from contentstack/feature/legacy-cms
v1shalpatel Jul 10, 2024
a5e30cd
Merge branch 'dev' of https://github.com/contentstack/migration-v2-no…
sayalijoshi27 Jul 10, 2024
ad2adc9
Test Migration Logger screen completed
sayalijoshi27 Jul 10, 2024
d1531b5
Merge pull request #180 from contentstack/feature/profile-design
v1shalpatel Jul 10, 2024
ef423e9
refactor:legacy cms bugs
AishDani Jul 11, 2024
b04cd02
Merge branch 'dev' of github.com:contentstack/migration-v2-node-serve…
AishDani Jul 11, 2024
01225da
Merge pull request #181 from contentstack/feature/legacy-cms
v1shalpatel Jul 11, 2024
571a1ba
solved functional bugs on dest stack
snehalsankhe Jul 12, 2024
79a9be4
merged from dev
snehalsankhe Jul 12, 2024
29c4c83
Merge pull request #183 from contentstack/layout-changes
v1shalpatel Jul 12, 2024
8da6a61
refactor:destination stack modal bug resolved
AishDani Jul 12, 2024
cddcd75
Merge branch 'dev' of github.com:contentstack/migration-v2-node-serve…
AishDani Jul 12, 2024
520637c
Merge pull request #184 from contentstack/bugs-legacyCMS
v1shalpatel Jul 12, 2024
8d7eb78
refactor:close modal prop added
AishDani Jul 12, 2024
a0c0e38
Merge pull request #186 from contentstack/bugs-legacyCMS
v1shalpatel Jul 12, 2024
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
1 change: 1 addition & 0 deletions api/src/models/project-lowdb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ interface LegacyCMS {
};
file_path: string;
is_fileValid: boolean;
is_localPath: boolean;
}

interface ExecutionLog {
Expand Down
2 changes: 1 addition & 1 deletion api/src/services/contentMapper.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ const updateContentType = async (req: Request) => {
});
}
await ContentTypesMapperModelLowdb.read();
ContentTypesMapperModelLowdb.update((data: any) => {
await ContentTypesMapperModelLowdb.update((data: any) => {
data.ContentTypesMappers[updateIndex].status = CONTENT_TYPE_STATUS[2];
});
// fetch updated data to return in response
Expand Down
4 changes: 2 additions & 2 deletions api/src/services/projects.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,7 @@ const affixConfirmation = async (req: Request) => {

const updateFileFormat = async (req: Request) => {
const { orgId, projectId } = req.params;
const { token_payload, file_format, file_path, is_fileValid, awsDetails } =
req.body;
const { token_payload, file_format,file_path,is_localPath,is_fileValid,awsDetails } = req.body;
const srcFunc = "updateFileFormat";
const projectIndex = (await getProjectUtil(
projectId,
Expand Down Expand Up @@ -401,6 +400,7 @@ const updateFileFormat = async (req: Request) => {
data.projects[projectIndex].legacy_cms.file_format = file_format;
data.projects[projectIndex].legacy_cms.file_path = file_path;
data.projects[projectIndex].legacy_cms.is_fileValid = is_fileValid;
data.projects[projectIndex].legacy_cms.is_localPath = is_localPath;
data.projects[projectIndex].current_step = STEPPER_STEPS.LEGACY_CMS;
data.projects[projectIndex].status = NEW_PROJECT_STATUS[0];
data.projects[projectIndex].updated_at = new Date().toISOString();
Expand Down
15 changes: 10 additions & 5 deletions ui/src/components/LegacyCms/Actions/LoadFileFormat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import { isEmptyString } from '../../../utilities/functions';

// Services
import {
fileformatConfirmation,
updateFileFormatData
fileformatConfirmation
} from '../../../services/api/migration.service';

// Interface
Expand Down Expand Up @@ -44,7 +43,7 @@ const LoadFileFormat = (props: LoadFileFormatProps) => {
const [fileIcon, setFileIcon] = useState(newMigrationData?.legacy_cms?.selectedFileFormat?.title);
const [isError, setIsError] = useState<boolean>(false);
const [error, setError] = useState<string>('');

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


Expand Down Expand Up @@ -85,8 +84,11 @@ const LoadFileFormat = (props: LoadFileFormatProps) => {
const cmsType = !isEmptyString(newMigrationData?.legacy_cms?.selectedCms?.parent) ? newMigrationData?.legacy_cms?.selectedCms?.parent : apiRes?.data?.cmsType?.toLowerCase();
const filePath = apiRes?.data?.localPath?.toLowerCase();
const fileFormat = getFileExtension(filePath);

const { all_cms = [] } = migrationData?.legacyCMSData || {};
if(! isEmptyString(selectedCard?.fileformat_id)){
setFileIcon(selectedCard?.title);
}
else{
const { all_cms = [] } = migrationData?.legacyCMSData || {};
let filteredCmsData:any = all_cms;
if (cmsType) {
filteredCmsData = all_cms?.filter((cms: any) => cms?.parent?.toLowerCase() === cmsType?.toLowerCase());
Expand Down Expand Up @@ -121,6 +123,9 @@ const LoadFileFormat = (props: LoadFileFormatProps) => {

setFileIcon(fileFormat === 'zip' ? fileFormat?.charAt(0).toUpperCase() + fileFormat.slice(1) : fileFormat?.toUpperCase());
dispatch(updateNewMigrationData(newMigrationDataObj));

}


}

Expand Down
11 changes: 6 additions & 5 deletions ui/src/components/LegacyCms/Actions/LoadSelectCms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ const LoadSelectCms = (props: LoadSelectCmsProps) => {
} else {
newSelectedCard = DEFAULT_CMS_TYPE;
}

setIsLoading(false);

if (!isEmptyString(newSelectedCard?.title)) {
setSelectedCard(newSelectedCard);
setErrorMessage('');
Expand All @@ -190,7 +191,7 @@ const LoadSelectCms = (props: LoadSelectCmsProps) => {
dispatch(updateNewMigrationData(newMigrationDataObj));
props?.handleStepChange(props?.currentStep);
}
setIsLoading(false);

};

/**** ALL USEEffects HERE ****/
Expand All @@ -205,15 +206,15 @@ const LoadSelectCms = (props: LoadSelectCmsProps) => {
return (
<div>
<div className="col-12">
{ isError ?
{ isError &&
<div className="empty_search_description">
<EmptyState
heading={<div className="empty_search_heading">No matching CMS found!</div>}
img={SEARCH_ICON}
/>
</div>
:
isLoading ? (
}
{ isLoading ? (
<div className='loader'>
<CircularLoader/>
</div>
Expand Down
119 changes: 80 additions & 39 deletions ui/src/components/LegacyCms/Actions/LoadUploadFile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,17 @@ const LoadUploadFile = (props: LoadUploadFileProps) => {
const [showMessage, setShowMessage] = useState<boolean>(newMigrationData?.legacy_cms?.uploadedFile?.isValidated);
const [validationMessgae, setValidationMessage] = useState<string>('');
const [isValidationAttempted, setIsValidationAttempted] = useState<boolean>(false);
const [isDisabled, setIsDisabled] = useState<boolean>(false);
const [isConfigLoading, setIsConfigLoading] = useState<boolean>(true);
const [isDisabled, setIsDisabled] = useState<boolean>( newMigrationData?.legacy_cms?.uploadedFile?.isValidated);
const [isConfigLoading, setIsConfigLoading] = useState<boolean>(false);
const [cmsType, setCmsType]= useState('');
const [fileDetails, setFileDetails] = useState<FileDetails>(newMigrationData?.legacy_cms?.uploadedFile?.file_details || {});
const [fileDetails, setFileDetails] = useState(newMigrationData?.legacy_cms?.uploadedFile?.file_details);
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?.fileformat_id);
const [processing, setProcessing] = useState('');
const [isCancelLoading, setIsCancelLoading] = useState<boolean>(false);
const [isFormatValid, setIsFormatValid] = useState<boolean>(false);

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

Expand All @@ -84,15 +85,24 @@ const LoadUploadFile = (props: LoadUploadFileProps) => {

//Handle further action on file is uploaded to server
const handleOnFileUploadCompletion = async () => {
setIsValidationAttempted(false);
setValidationMessage('');
setIsLoading(true);
setProgressPercentage(30);
setShowProgress(true);
setProcessing('Processing..30%')

setProcessing('Processing...30%');

await new Promise(resolve => setTimeout(resolve, 1000));

const res: any = await fileValidation(projectId);
setIsLoading(false);

setProgressPercentage(70);
setProcessing('Processing...70%');


await new Promise(resolve => setTimeout(resolve, 1000));


const newMigrationDataObj: INewMigration = {
...newMigrationData,
legacy_cms: {
Expand Down Expand Up @@ -120,8 +130,12 @@ const LoadUploadFile = (props: LoadUploadFileProps) => {
dispatch(updateNewMigrationData(newMigrationDataObj));

if(res?.status === 200){
setIsValidated(true);
setValidationMessage('Validation is successful');
setTimeout(()=>{
setIsValidated(true);
setValidationMessage('Validation is successful');

},1000);
setIsDisabled(true);

if(! isEmptyString(newMigrationData?.legacy_cms?.affix) && ! isEmptyString(newMigrationData?.legacy_cms?.selectedCms?.cms_id) && ! isEmptyString(newMigrationData?.legacy_cms?.selectedFileFormat?.fileformat_id)){
props.handleStepChange(props?.currentStep, true);
Expand Down Expand Up @@ -150,9 +164,23 @@ const LoadUploadFile = (props: LoadUploadFileProps) => {

}

setProgressPercentage(100);
setProcessing('Processing...100%');

await new Promise(resolve => setTimeout(resolve, 1000));

setTimeout(() => {
setShowProgress(false);
setShowMessage(true);
}, 1000);

setIsLoading(false);
saveStateToLocalStorage({
isLoading,
isConfigLoading,
isValidated,
validationMessgae,
isDisabled,
cmsType,
fileDetails,
fileExtension,
Expand All @@ -161,14 +189,8 @@ const LoadUploadFile = (props: LoadUploadFileProps) => {
fileFormat,
processing
}, projectId);


setShowMessage(true);
setProgressPercentage(100);
setTimeout(() => {
setProcessing('Processing ...100%')
setShowProgress(false);
}, 1000);


};

Expand All @@ -181,7 +203,13 @@ const LoadUploadFile = (props: LoadUploadFileProps) => {
const getConfigDetails = async () =>{
setIsConfigLoading(true);
const res: any = await getConfig();


if (!isEmptyString(fileDetails?.localPath) && res?.data?.localPath !== fileDetails?.localPath) {
setIsDisabled(false);
setShowMessage(true);
setValidationMessage('');

}

if(res?.status === 200){
const extension = getFileExtension(res?.data?.localPath);
Expand Down Expand Up @@ -211,31 +239,31 @@ const LoadUploadFile = (props: LoadUploadFileProps) => {
}
};

dispatch(updateNewMigrationData(newMigrationDataObj));
if(isEmptyString(newMigrationData?.legacy_cms?.uploadedFile?.file_details?.localPath) ){
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 isFormatValid = filteredCmsData[0]?.allowed_file_formats?.some((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);

// setIsDisabled(false);
// //setShowMessage(true);
// setValidationMessage('');
// }
}
setIsFormatValid(isFormatValid);
if(!isFormatValid){
setIsDisabled(!isFormatValid);
setValidationMessage('');

}


}
if((! isEmptyString(newMigrationData?.legacy_cms?.selectedCms?.parent?.toLowerCase()) &&
newMigrationData?.legacy_cms?.selectedCms?.parent.toLowerCase() !== res?.data?.cmsType.toLowerCase()))
{
Expand Down Expand Up @@ -278,14 +306,20 @@ const LoadUploadFile = (props: LoadUploadFileProps) => {
}

useEffect(() => {
getConfigDetails();
if(isEmptyString(newMigrationData?.legacy_cms?.uploadedFile?.file_details?.localPath)){
getConfigDetails();
}

}, []);

useEffect(() => {
const savedState = getStateFromLocalStorage(projectId);
if (savedState) {
setIsLoading(savedState.isLoading);
setIsConfigLoading(savedState.isConfigLoading);
setIsValidated(savedState?.isValidated);
setValidationMessage(savedState?.validationMessage);
setIsDisabled(savedState?.isDisabled);
setCmsType(savedState.cmsType);
setFileDetails(savedState.fileDetails);
setFileExtension(savedState.fileExtension);
Expand All @@ -295,7 +329,7 @@ const LoadUploadFile = (props: LoadUploadFileProps) => {
setProcessing(savedState.processing);
}
if (savedState && savedState.isLoading) {

handleOnFileUploadCompletion();
}
},[]);
Expand All @@ -304,6 +338,9 @@ const LoadUploadFile = (props: LoadUploadFileProps) => {
saveStateToLocalStorage({
isLoading,
isConfigLoading,
isValidated,
validationMessgae,
isDisabled,
cmsType,
fileDetails,
fileExtension,
Expand All @@ -315,6 +352,9 @@ const LoadUploadFile = (props: LoadUploadFileProps) => {
}, [
isLoading,
isConfigLoading,
isValidated,
validationMessgae,
isDisabled,
cmsType,
fileDetails,
fileExtension,
Expand All @@ -324,10 +364,10 @@ const LoadUploadFile = (props: LoadUploadFileProps) => {
processing
]);

useEffect(()=>{

useEffect(()=>{
if(newMigrationData?.legacy_cms?.uploadedFile?.isValidated)
{

setIsValidated(true);
setShowMessage(true)
setValidationMessage('Validation is successful');
Expand All @@ -338,8 +378,9 @@ const LoadUploadFile = (props: LoadUploadFileProps) => {
// else{
// setIsValidated(false);
// }
},[isValidated,newMigrationData])


},[isValidated])

useEffect(()=>{
if(newMigrationData?.legacy_cms?.selectedFileFormat?.fileformat_id){
setFileFormat(newMigrationData?.legacy_cms?.selectedFileFormat?.fileformat_id);}
Expand All @@ -349,13 +390,13 @@ const LoadUploadFile = (props: LoadUploadFileProps) => {
const validationClassName = isValidated ? 'success' : 'error';

const containerClassName = `validation-container ${isValidationAttempted && !isValidated ? 'error-container pb-2' : ''}`;

return (
<div className="row">
<div className="col-12">
<div className="col-12">
<div className={containerClassName}>
{!isConfigLoading && !isEmptyString(cmsType) ? (
{!isConfigLoading && !isEmptyString(fileDetails?.localPath) ? (
<div className='file-icon-group'>
<FileComponent fileDetails={fileDetails || {}} />
{/* {(showMessage && !isCancelLoading) &&
Expand Down Expand Up @@ -386,7 +427,7 @@ const LoadUploadFile = (props: LoadUploadFileProps) => {
)
}
{showProgress && isLoading &&
<Paragraph className='pb-2' tagName='p' variant="p2" text={processing}/>
<Paragraph className='pb-2 processing-test' tagName='p' variant="p2" text={processing}/>
}

</div>
Expand Down
Loading