Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
3753d46
Resolved mapped content types disable issue
sayalijoshi27 Sep 16, 2024
7d3a1ea
Merge pull request #277 from contentstack/bugfix/content-mapper
RohitKini Sep 16, 2024
d330ad9
refactor:content mapper bugs
AishDani Sep 17, 2024
1942f7b
Merge pull request #278 from contentstack/feature/dropdown-field-choices
RohitKini Sep 17, 2024
9111c79
[CMG-312] - Destination stack | When an existing project is open and …
sayalijoshi27 Sep 17, 2024
ee3449f
Merge pull request #279 from contentstack/bugfix/content-mapper
RohitKini Sep 17, 2024
b2d3fdc
Fixed bug CMG-315
BhagyahsreeMatere Sep 17, 2024
e87f622
Merge pull request #280 from contentstack/bugfix/popup-modal
RohitKini Sep 17, 2024
4058b10
refactor:resolved uncaught error deu to token expiration
AishDani Sep 17, 2024
1d709e7
[CMG-317] - Destination stack | When creating a new project and going…
sayalijoshi27 Sep 17, 2024
76816e2
Merge branch 'dev' of https://github.com/contentstack/migration-v2-no…
sayalijoshi27 Sep 17, 2024
3072571
refactor:content-mapper-bugs
AishDani Sep 5, 2024
ab68581
refactor:css for required text
AishDani Sep 17, 2024
a4d6731
Merge branch 'dev' of github.com:contentstack/migration-v2-node-serve…
AishDani Sep 17, 2024
3aaf384
refactor:legacy cms validation msg was getting showed for empty project
AishDani Sep 18, 2024
7c8ede5
refactor:required text in all steps of legacy cms
AishDani Sep 18, 2024
55937b8
Merge pull request #282 from contentstack/feature/dropdown-field-choices
RohitKini Sep 18, 2024
05f941c
Merge pull request #281 from contentstack/bugfix/content-mapper
RohitKini Sep 18, 2024
8a12ba4
[CMG-129], [CMG-136]
sayalijoshi27 Sep 18, 2024
fd18eba
Merge pull request #285 from contentstack/bugfix/content-mapper
RohitKini Sep 18, 2024
b29e2b0
refactor:content mapper bugs
AishDani Sep 20, 2024
e8d18db
Merge branch 'dev' of github.com:contentstack/migration-v2-node-serve…
AishDani Sep 20, 2024
5391588
Merge pull request #287 from contentstack/feature/dropdown-field-choices
RohitKini Sep 20, 2024
4ddabee
refactor:changed logic for setting stepIndex in stepper to avoid by d…
AishDani Sep 20, 2024
0586d91
refactor:removed file format confirmation api call form useEffect
AishDani Sep 20, 2024
d8d6bbc
refactor:content mapper bugs and api calls
AishDani Sep 20, 2024
be3c5c5
refcator:uncommented code for isDropdown change
AishDani Sep 20, 2024
0170197
Merge pull request #288 from contentstack/feature/dropdown-field-choices
RohitKini Sep 20, 2024
20e5293
[CMG-324] - Content mapper | Global fields | When opening global fiel…
sayalijoshi27 Sep 20, 2024
b1eff9c
Conflict resolved
sayalijoshi27 Sep 20, 2024
ebf6800
Dropdown placeholder changes for global fields
sayalijoshi27 Sep 23, 2024
b57a338
Merge pull request #289 from contentstack/bugfix/content-mapper
RohitKini Sep 23, 2024
a26cd52
Merge branch 'dev' of https://github.com/contentstack/migration-v2-no…
RohitKini Sep 24, 2024
c456e3e
stacks limit check
RohitKini Sep 26, 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:content mapper bugs
  • Loading branch information
AishDani committed Sep 20, 2024
commit b29e2b0237c461da447b0183d85f4ddd24a9906e
132 changes: 117 additions & 15 deletions ui/src/components/ContentMapper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ const ContentMapper = forwardRef(({projectData}: ContentMapperComponentProps, re
const deletedExstingField : ExistingFieldType= existingField;
const isNewStack = newMigrationData?.stackDetails?.isNewStack;
const [isFieldDeleted, setIsFieldDeleted] = useState<boolean>(false);
const [isContentDeleted, setIsContentDeleted] = useState<boolean>(false);

/** ALL HOOKS Here */
const { projectId = '' } = useParams();
Expand Down Expand Up @@ -323,13 +324,46 @@ const ContentMapper = forwardRef(({projectData}: ContentMapperComponentProps, re
},[tableData]);

useEffect(() => {
if (contentTypeMapped && otherCmsTitle) {
setOtherContentType({
label: contentTypeMapped?.[otherCmsTitle] ?? 'Select content type from existing stack',
value: contentTypeMapped?.[otherCmsTitle] ?? 'Select content type from existing stack'
});
const mappedContentType = contentTypesList && contentTypesList?.find((item)=>item?.title === contentTypeMapped?.[otherCmsTitle]);

if (contentTypeMapped && otherCmsTitle ) {

if (mappedContentType?.uid) {
setOtherContentType({
id: mappedContentType?.uid,
label: contentTypeMapped?.[otherCmsTitle],
value: contentTypeMapped?.[otherCmsTitle],
});
setIsContentDeleted(false);
} else {

setOtherContentType({
label: 'Select content type from existing stack',
value: 'Select content type from existing stack',
});

}

}

}, [contentTypeMapped, otherCmsTitle,contentTypesList]);



useEffect(()=>{
if(isContentDeleted){
setContentTypeMapped((prevState: ContentTypeMap) => {
const { [otherCmsTitle]: removed, ...newState } = prevState;

return newState;
});

setIsFieldDeleted(false);
}
}, [contentTypeMapped, otherCmsTitle]);


},[isContentDeleted, contentTypesList, otherCmsTitle])


useEffect(() => {
if (contentTypeMapped[otherCmsTitle] === otherContentType?.label) {
Expand Down Expand Up @@ -567,10 +601,10 @@ const ContentMapper = forwardRef(({projectData}: ContentMapperComponentProps, re
const otherTitle = contentTypes?.[i]?.otherCmsTitle;
setOtherCmsTitle(otherTitle);

setOtherContentType({
label: contentTypeMapped?.[otherTitle] || 'Select content type from existing stack',
value: contentTypeMapped?.[otherTitle] || 'Select content type from existing stack'
});
// setOtherContentType({
// label: contentTypeMapped?.[otherTitle] || 'Select content type from existing stack',
// value: contentTypeMapped?.[otherTitle] || 'Select content type from existing stack'
// });

setContentTypeUid(contentTypes?.[i]?.id ?? '');
fetchFields(contentTypes?.[i]?.id ?? '', searchText || '');
Expand All @@ -583,6 +617,16 @@ const ContentMapper = forwardRef(({projectData}: ContentMapperComponentProps, re
const { data, status } = await getExistingContentTypes(projectId);
if (status === 201) {
setContentTypesList(data?.contentTypes);
const mappedContentType = data?.contentTypes && data?.contentTypes?.find((item:ContentTypeList)=>item?.title === contentTypeMapped?.[otherCmsTitle]);

if (mappedContentType?.uid) {
setOtherContentType({
id: mappedContentType?.uid,
label: contentTypeMapped?.[otherCmsTitle],
value: contentTypeMapped?.[otherCmsTitle],
});
setIsContentDeleted(false);
}
}
};

Expand Down Expand Up @@ -1480,17 +1524,29 @@ const ContentMapper = forwardRef(({projectData}: ContentMapperComponentProps, re
fieldMapping: updatedRows
}
};
let newstate = {} ;
setContentTypeMapped((prevState: ContentTypeMap) => {
const newState = { ...prevState };

delete newState[otherCmsTitle];
newstate = newState;

return newState;
});
if (orgId && selectedContentType) {
const { status } = await resetToInitialMapping(
orgId,
projectID,
selectedContentType?.id ?? '',
dataCs
);

setExistingField({});
setContentTypeSchema([]);
setContentTypeMapped({});

if (status == 200) {
await updateContentMapper(orgId, projectID, {...newstate} );

Notification({
notificationContent: { text: 'Content type reset successfully' },
notificationProps: {
Expand All @@ -1505,6 +1561,51 @@ const ContentMapper = forwardRef(({projectData}: ContentMapperComponentProps, re

// Function to fetch single content type
const handleFetchContentType = async () => {
const { data , status} = await fetchExistingContentType(projectId,'') ;
// if(status === 201){
// Notification({
// notificationContent: { text: "All Content Types fetched successfully" },
// notificationProps: {
// position: 'bottom-center',
// hideProgressBar: false
// },
// type: 'success'
// });

// }
const contentTypesArr: ContentTypeList[] = contentTypesList;
const index = contentTypesList.findIndex(ct => ct?.uid === data?.uid);

if(index != -1) {
contentTypesArr[index] = data;
}

setContentTypesList(data?.contentTypes);


const content_type = data?.contentTypes?.find((item:any)=>item?.title === otherContentType?.label);
const contentTypeKey = Object.keys(contentTypeMapped).find(key => contentTypeMapped[key] === otherContentType?.label);


if(! content_type && contentTypeKey){
const updatedState = { ...contentTypeMapped };
delete updatedState[contentTypeKey];

setContentTypeMapped((prevState: ContentTypeMap) => {
const newState = { ...prevState };

delete newState[contentTypeKey]

return newState;
});
await updateContentMapper(selectedOrganisation?.value, projectId, {... updatedState} );
setOtherContentType({
label: 'Select content type from existing stack',
value: 'Select content type from existing stack'

});
}

if (otherContentType?.label === "Select Content Type") {
Notification({
notificationContent: { text: "Please Select a Content Type to fetch." },
Expand All @@ -1514,8 +1615,9 @@ const ContentMapper = forwardRef(({projectData}: ContentMapperComponentProps, re
},
type: 'error'
});
} else {
const { data , status} = await fetchExistingContentType(projectId, otherContentType?.id ?? '');
} else if(otherContentType?.id){

const { data , status} = await fetchExistingContentType(projectId, otherContentType?.id ?? '') ;

const index = contentTypesList.findIndex(ct => ct?.uid === data?.uid);

Expand All @@ -1525,7 +1627,7 @@ const ContentMapper = forwardRef(({projectData}: ContentMapperComponentProps, re
contentTypesArr[index] = data;
}

setContentTypesList(contentTypesArr);
//setContentTypesList(contentTypesArr);
setContentTypeSchema(data?.schema);
if (status == 201) {
Notification({
Expand Down Expand Up @@ -1553,7 +1655,7 @@ const ContentMapper = forwardRef(({projectData}: ContentMapperComponentProps, re
}
];

const isOtherContentType = contentTypesList?.some((ct) => ct?.title === otherContentType?.label);
const isOtherContentType = contentTypesList && contentTypesList?.some((ct) => ct?.title === otherContentType?.label);

if (!isNewStack) {
columns?.push({
Expand Down
5 changes: 4 additions & 1 deletion ui/src/context/app/app.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
import { ICardType, defaultCardType } from '../../components/Common/Card/card.interface';
import { CTA } from '../../types/common.interface';
import { IFilterType } from '../../components/Common/Modal/FilterModal/filterModal.interface';
import { ContentTypeList } from '../../components/ContentMapper/contentMapper.interface';
export interface ICTA {
title: string;
href: string;
Expand Down Expand Up @@ -170,6 +171,7 @@ export interface IContentMapper {
content_type_mapping: ContentTypeMap;
isDropDownChanged?: boolean;
otherCmsTitle?: string;
contentTypeList:ContentTypeList[]
}
export interface INewMigration {
mapperKeys: ContentTypeMap;
Expand Down Expand Up @@ -307,7 +309,8 @@ export const DEFAULT_DESTINATION_STACK: IDestinationStack = {
export const DEFAULT_CONTENT_MAPPER: IContentMapper = {
content_type_mapping: {},
isDropDownChanged: false,
otherCmsTitle: ''
otherCmsTitle: '',
contentTypeList: [],
};

export const DEFAULT_TEST_MIGRATION: ITestMigration = {
Expand Down