Skip to content
Merged

Dev #117

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
a11d0ad
Precommit changes
sayalijoshi27 May 15, 2024
0322120
Merge branch 'dev' of https://github.com/contentstack/migration-v2-no…
sayalijoshi27 May 15, 2024
210505a
refactor:changed stack select dropdown to asyncselect
AishDani May 15, 2024
46ec28e
refactor:code formatted by precommit
AishDani May 15, 2024
700d5f4
refactor:resolved PR comment
AishDani May 16, 2024
a3fea8f
Merge pull request #112 from contentstack/feature/project-dashboard
snehalsankhe May 16, 2024
058a350
fetch Single ContentType API
shristi-sinha May 16, 2024
8fd7ba3
Merge pull request #113 from contentstack/feature/CMG-100
sayalijoshi27 May 17, 2024
78d2b53
work around for group field uncheck
sayalijoshi27 May 17, 2024
617a92e
refactor:resolved empty selectcms issue
AishDani May 17, 2024
4f4a3b3
refactor:removed commented code
AishDani May 17, 2024
580a016
Merge pull request #114 from contentstack/feature/project-dashboard
snehalsankhe May 17, 2024
52378a9
[CMG-101] - UI for Fetch API
sayalijoshi27 May 20, 2024
49caa80
Merge branch 'dev' of https://github.com/contentstack/migration-v2-no…
sayalijoshi27 May 20, 2024
95e9149
[CMG-103] - On group uncheck child elements also get unchecked
sayalijoshi27 May 20, 2024
56826dd
Merge pull request #115 from contentstack/feature/CMG-101
AishDani May 20, 2024
d1a0a82
Merge branch 'dev' of https://github.com/contentstack/migration-v2-no…
sayalijoshi27 May 20, 2024
b55c3ca
Merge pull request #116 from contentstack/bugfix/projects
AishDani May 20, 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
Prev Previous commit
Next Next commit
refactor:resolved empty selectcms issue
  • Loading branch information
AishDani committed May 17, 2024
commit 617a92e4c80afe2da9ebe5e0026d19ea4ec2aac2
42 changes: 23 additions & 19 deletions ui/src/components/LegacyCms/Actions/LoadSelectCms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useParams } from 'react-router';

// Service
import { updateLegacyCMSData } from '../../../services/api/migration.service';
import { fileValidation } from '../../../services/api/upload.service';
import { fileValidation, getConfig } from '../../../services/api/upload.service';

// Utilities
import { isEmptyString, validateArray } from '../../../utilities/functions';
Expand Down Expand Up @@ -44,7 +44,7 @@ const LoadSelectCms = (props: LoadSelectCmsProps) => {
const [searchText, setSearchText] = useState<string>('');
const [cmsFilterStatus, setCmsFilterStatus] = useState<IFilterStatusType>({});
const [cmsFilter, setCmsFilter] = useState<string[]>([]);
const [cmsType, setCmsType] = useState<string | null>(
const [cmsType, setCmsType] = useState<string>(
newMigrationData?.legacy_cms?.selectedCms?.title?.toLowerCase()
);

Expand All @@ -63,9 +63,10 @@ const LoadSelectCms = (props: LoadSelectCmsProps) => {
}
});

await updateLegacyCMSData(selectedOrganisation?.value, projectId, { legacy_cms: cms?.cms_id });

props?.handleStepChange(props?.currentStep);
// await updateLegacyCMSData(selectedOrganisation?.value, projectId, { legacy_cms: cms?.cms_id });
if (!isEmptyString(cms?.title)) {
props?.handleStepChange(props?.currentStep);
}
};

//Handle CMS Filter Updation in local storage.
Expand All @@ -89,10 +90,11 @@ const LoadSelectCms = (props: LoadSelectCmsProps) => {
const filterCMSData = async (searchText: string) => {
const { all_cms = [] } = migrationData?.legacyCMSData || {};

const res: any = await fileValidation();
const cms = res?.data?.file_details?.cmsType?.toLowerCase();
setCmsType(cms);
const cmstype = cms; // Fetch the specific CMS type
const apiRes: any = await getConfig(); // api call to get cms type from upload service

const cms = apiRes?.data?.cmsType?.toLowerCase();

const cmstype = !isEmptyString(cmsType) ? cmsType : cms; // Fetch the specific CMS type

let filteredCmsData: ICMSType[] = [];
if (isEmptyString(searchText) && !validateArray(cmsFilter) && !cmstype) {
Expand Down Expand Up @@ -158,16 +160,18 @@ const LoadSelectCms = (props: LoadSelectCmsProps) => {
}
}, [cmsType, selectedCard]);

useEffect(() => {
const getCmsType = async () => {
const res: any = await fileValidation();
const cms = res?.data?.file_details?.cmsType?.toLowerCase();
setCmsType(cms);
filterCMSData(cms);
return cmsType;
};
getCmsType();
}, [cmsType]);
// useEffect(() => {
// const getCmsType = async () => {
// const res: any = await fileValidation();
// const cms = res?.data?.file_details?.cmsType?.toLowerCase();
// if(isEmptyString(cmsType || '')){
// setCmsType(cms);
// }
// filterCMSData(cms);
// return cmsType;
// };
// //getCmsType();
// }, [cmsType]);

return (
<div>
Expand Down
5 changes: 4 additions & 1 deletion ui/src/components/LegacyCms/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { isEmptyString, validateArray } from '../../utilities/functions';
import { ICardType, defaultCardType } from '../Common/Card/card.interface';
import './legacyCms.scss';
import { IFilterType } from '../Common/Modal/FilterModal/filterModal.interface';
import { updateCurrentStepData } from '../../services/api/migration.service';
import { updateCurrentStepData, updateLegacyCMSData } from '../../services/api/migration.service';
import { MigrationResponse } from '../../services/api/service.interface';
import { getCMSDataFromFile } from '../../cmsData/cmsSelector';

Expand Down Expand Up @@ -60,6 +60,9 @@ const LegacyCMSComponent = ({ legacyCMSData, projectData }: LegacyCMSComponentPr
event.preventDefault();

//Update Data in backend
await updateLegacyCMSData(selectedOrganisation?.value, projectId, {
legacy_cms: newMigrationData?.legacy_cms?.selectedCms?.cms_id
});
const res = await updateCurrentStepData(selectedOrganisation.value, projectId);
if (res) {
const url = `/projects/${projectId}/migration/steps/2`;
Expand Down
8 changes: 8 additions & 0 deletions ui/src/services/api/upload.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,11 @@ export const fileValidation = () => {
return error;
}
};

export const getConfig = () => {
try {
return getCall(`${UPLOAD_FILE_RELATIVE_URL}config`);
} catch (error) {
return error;
}
};