@@ -249,6 +249,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
249249 const isNewStack = newMigrationData ?. stackDetails ?. isNewStack ;
250250 const [ isFieldDeleted , setIsFieldDeleted ] = useState < boolean > ( false ) ;
251251 const [ isContentDeleted , setIsContentDeleted ] = useState < boolean > ( false ) ;
252+ const [ isCsCTypeUpdated , setsCsCTypeUpdated ] = useState < boolean > ( false ) ;
252253
253254
254255 /** ALL HOOKS Here */
@@ -435,7 +436,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
435436 // if exsting content type is changed in contentstack, reflect those changes for
436437 // maaped fields
437438 useEffect ( ( ) => {
438- if ( existingField ) {
439+ if ( existingField && ! isCsCTypeUpdated ) {
439440
440441 contentTypeSchema ?. forEach ( ( item ) => {
441442 for ( const [ key , value ] of Object . entries ( existingField ) ) {
@@ -467,7 +468,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
467468
468469 } , [ contentTypeSchema ] ) ;
469470 useEffect ( ( ) => {
470- if ( existingField ) {
471+ if ( existingField && isCsCTypeUpdated ) {
471472 const matchedKeys = new Set < string > ( ) ;
472473
473474 contentTypeSchema ?. forEach ( ( item ) => {
@@ -674,7 +675,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
674675 setActive ( i ) ;
675676 const otherTitle = filteredContentTypes ?. [ i ] ?. contentstackUid ;
676677 const mappedContentType = contentModels && contentModels ?. find ( ( item ) => item ?. uid === newMigrationData ?. content_mapping ?. content_type_mapping ?. [ otherTitle ] ) ;
677- setOtherCmsTitle ( otherTitle ) ;
678+ setOtherCmsTitle ( filteredContentTypes ?. [ i ] ?. otherCmsTitle ) ;
678679 setContentTypeUid ( filteredContentTypes ?. [ i ] ?. id ?? '' ) ;
679680 fetchFields ( filteredContentTypes ?. [ i ] ?. id ?? '' , searchText || '' ) ;
680681 setOtherCmsUid ( filteredContentTypes ?. [ i ] ?. otherCmsUid ) ;
@@ -884,6 +885,8 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
884885 } ;
885886
886887 const handleDropDownChange = ( value : FieldTypes ) => {
888+ ( value ?. id !== otherContentType ?. id ) && setsCsCTypeUpdated ( true ) ;
889+
887890 setOtherContentType ( value ) ;
888891 } ;
889892
@@ -964,17 +967,22 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
964967 data ?. otherCmsField === 'title' ||
965968 data ?. otherCmsField === 'url' ||
966969 data ?. otherCmsType === 'reference' ||
967- data ?. otherCmsType === 'global_field'
970+ data ?. contentstackFieldType === 'global_field'
968971 ) && (
969972 < Tooltip
970973 content = "Advanced properties"
971974 position = "top"
972975 disabled = {
973976 data ?. otherCmsField === 'title' ||
974- data ?. otherCmsField === 'url'
977+ data ?. otherCmsField === 'url' ||
978+ newMigrationData ?. project_current_step > 4
975979 }
976980 >
977- < Icon
981+ < Button
982+ buttonType = "light"
983+ disabled = { newMigrationData ?. project_current_step > 4 }
984+ >
985+ < Icon
978986 version = "v2"
979987 icon = "Sliders"
980988 size = "small"
@@ -983,6 +991,9 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
983991 }
984992 disabled = { newMigrationData ?. project_current_step > 4 }
985993 />
994+
995+ </ Button >
996+
986997 </ Tooltip >
987998 ) }
988999 </ div >
@@ -1470,7 +1481,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
14701481 selectedContentType ?. otherCmsUid &&
14711482 otherContentType ?. label
14721483 ) {
1473- setContentTypeMapped ( ( prevState : ContentTypeMap ) => ( {
1484+ otherContentType ?. id && setContentTypeMapped ( ( prevState : ContentTypeMap ) => ( {
14741485 ...prevState ,
14751486 [ selectedContentType ?. contentstackUid ] : otherContentType ?. id ?? ''
14761487 } ) ) ;
@@ -1525,6 +1536,17 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
15251536 dispatch ( updateNewMigrationData ( newMigrationDataObj ) ) ;
15261537
15271538 }
1539+ else {
1540+ const newMigrationDataObj : INewMigration = {
1541+ ...newMigrationData ,
1542+ content_mapping : {
1543+ ...newMigrationData ?. content_mapping ,
1544+ isDropDownChanged : false
1545+ }
1546+ } ;
1547+ dispatch ( updateNewMigrationData ( newMigrationDataObj ) ) ;
1548+
1549+ }
15281550
15291551
15301552
@@ -1672,10 +1694,13 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
16721694 try {
16731695 const { data , status} = await getExistingContentTypes ( projectId , otherContentType ?. id ?? '' ) ;
16741696 if ( status == 201 && data ?. contentTypes ?. length > 0 ) {
1675- otherContentType ?. id && setOtherContentType ( {
1697+ ( otherContentType ?. id === data ?. selectedContentType ?. uid ) && setsCsCTypeUpdated ( false ) ;
1698+
1699+ ( otherContentType ?. id && otherContentType ?. label !== data ?. selectedContentType ?. title )
1700+ && setOtherContentType ( {
16761701 label : data ?. selectedContentType ?. title ,
16771702 value : data ?. selectedContentType ?. title ,
1678- id :data ?. selectedContentType ?. uid
1703+ id : data ?. selectedContentType ?. uid
16791704 } )
16801705 setContentModels ( data ?. contentTypes ) ;
16811706 const newMigrationDataObj : INewMigration = {
@@ -1717,10 +1742,13 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
17171742 const { data, status } = await getExistingGlobalFields ( projectId , otherContentType ?. id ?? '' ) ;
17181743
17191744 if ( status == 201 && data ?. globalFields ?. length > 0 ) {
1720- otherContentType ?. id && setOtherContentType ( {
1745+ ( otherContentType ?. id === data ?. selectedGlobalField ?. uid ) && setsCsCTypeUpdated ( false ) ;
1746+
1747+ ( otherContentType ?. id && otherContentType ?. label !== data ?. selectedGlobalField ?. title )
1748+ && setOtherContentType ( {
17211749 label : data ?. selectedGlobalField ?. title ,
17221750 value :data ?. selectedGlobalField ?. title ,
1723- id :data ?. selectedGlobalField ?. uid
1751+ id : data ?. selectedGlobalField ?. uid
17241752 } )
17251753 setContentModels ( data ?. globalFields ) ;
17261754
@@ -1907,7 +1935,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
19071935 </ div >
19081936 :
19091937 < div className = "step-container" >
1910- { contentTypes . length > 0 ?
1938+ { ( contentTypes . length > 0 || tableData ?. length > 0 ) ?
19111939 < div className = "d-flex flex-wrap table-container" >
19121940 { /* Content Types List */ }
19131941 < div className = "content-types-list-wrapper" >
0 commit comments