Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
126 changes: 112 additions & 14 deletions ui/src/components/ContentMapper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,85 @@ import AdvanceSettings from '../AdvancePropertise';

// Styles
import './index.scss';
const dummy_obj:any = {
'single_line_text':{
label : 'Single Line Textbox',
options : {
'Single Line Textbox':'single_line_text',
'Multi Line Textbox':'multi_line_text',
'HTML Rich text Editor':'html',
'JSON Rich Text Editor':'json'}
},
'multi_line_text':{
label : 'Multi Line Textbox',
options : {
'HTML Rich text Editor': 'html',
'JSON Rich Text Editor':'json'}
},
'json':{
label:'JSON Rich Text Editor',
options : {
'JSON Rich Text Editor':'json'}
},
'html':{
label : 'HTML Rich text Editor',
options : {
'HTML Rich text Editor': 'html',
'JSON Rich Text Editor':'json'}

},
'text':{
label : 'Single Line Textbox',
options: {'Single Line Textbox':'single_line_text'}
},
'url': {
label: 'URL',
options:{'URL':'url'}
},
'file': {
label:'File',
options: {'File':'file'}
},
'number': {
label:'Number',
options: {'Number':'number'}
},
'isodate': { label :'Date',
options: {'Date':'isodate'}
},
'boolean': {
label: 'Boolean',
options: {'Boolean':'boolean'}
},
'link': {
label:'Link',
options: {'Link':'link'}
},
'reference':{
label: 'Reference',
options: {'Reference':'reference'}
},
'dropdown': {
label:'Dropdown',
options: {'Dropdown':'dropdown'}
},
'radio': {
label :'Select',
options: {'Select':'select'}
},
'CheckBox': {
label:'Select',
options: {'Select':'checkbox'}
},
'global_field':{
label : 'Global',
options: {'Global':'global_field'}},
'group': {
label: 'Group',
options: {'Group':'group'}
}

}

const Fields: Mapping = {
'Single Line Textbox': [
Expand Down Expand Up @@ -162,6 +241,7 @@ const ContentMapper = () => {
const [contentTypeSchema, setContentTypeSchema] = useState<ContentTypesSchema[]>([]);
const [showFilter, setShowFilter] = useState<boolean>(false);
const [filteredContentTypes, setFilteredContentTypes] = useState<ContentType[]>([])
const [count, setCount] = useState<number>(0);

/** ALL HOOKS Here */
const { projectId = '' } = useParams();
Expand Down Expand Up @@ -244,6 +324,7 @@ const ContentMapper = () => {
const { data } = await getContentTypes(projectId || '', 0, 5000, searchContentType || ''); //org id will always present

setContentTypes(data?.contentTypes);
setCount(data?.contentTypes?.length);
setFilteredContentTypes(data?.contentTypes);
setSelectedContentType(data?.contentTypes?.[0]);
setTotalCounts(data?.contentTypes?.[0]?.fieldMapping?.length);
Expand Down Expand Up @@ -480,21 +561,36 @@ const ContentMapper = () => {
});
};
const SelectAccessor = (data: FieldMapType) => {
const OptionsForRow = Fields[data?.backupFieldType as keyof Mapping];

const option = Array.isArray(OptionsForRow)
? OptionsForRow.map((option) => ({ label: option, value: option }))
: [{ label: OptionsForRow, value: OptionsForRow }];

//const OptionsForRow = Fields[data?.backupFieldType as keyof Mapping];
const OptionsForRow = dummy_obj?.[data?.backupFieldType]?.options ;
const initialOption = {
label: dummy_obj?.[data?.ContentstackFieldType]?.label,
value: dummy_obj?.[data?.ContentstackFieldType]?.label,
};
let option:any;
if (Array.isArray(OptionsForRow)) {
option = OptionsForRow.map((option) => ({
label: option,
value: option,
}));
} else if (typeof OptionsForRow === 'object') {
option = Object.entries(OptionsForRow).map(([label, value]) => ({
label,
value,
}));
}else{
option = [{ label: OptionsForRow, value: OptionsForRow }]
}

const fieldLabel = data?.ContentstackFieldType === 'url' || data?.ContentstackFieldType === 'group'
? data?.ContentstackFieldType : option?.[0]?.label

return (
<div className="table-row">
<div className="select">
<Select
id={data?.uid}
value={{ label: data?.ContentstackFieldType, value: fieldValue }}
value={initialOption || fieldValue}
onChange={(selectedOption: FieldTypes) => handleValueChange(selectedOption, data?.uid)}
placeholder="Select Field"
version={'v2'}
Expand Down Expand Up @@ -925,13 +1021,15 @@ const ContentMapper = () => {
}

(e?.target as HTMLElement)?.closest('li')?.classList?.add('active-filter');
const filteredCT = contentTypes?.filter((ct) => CONTENT_MAPPING_STATUS[ct?.status] === value);

const filteredCT = contentTypes?.filter((ct) => {return CONTENT_MAPPING_STATUS[ct?.status] === value});
if (value !== 'All') {
setFilteredContentTypes(filteredCT)
setFilteredContentTypes(filteredCT);
setCount(filteredCT?.length);
} else {
setFilteredContentTypes(contentTypes)
}
setFilteredContentTypes(contentTypes);
setCount(contentTypes?.length);
}
setShowFilter(false);
}

Expand All @@ -952,15 +1050,15 @@ const ContentMapper = () => {
return result;
}
const tableHeight = calcHeight();

return (
<div className="step-container">
<div className="d-flex flex-wrap table-container">
{/* Content Types List */}
<div className="content-types-list-wrapper">
<div className="content-types-list-header d-flex align-items-center justify-content-between">
{contentTypesHeading && <h2>{contentTypesHeading}</h2> }
{contentTypes && validateArray(contentTypes) && contentTypes?.length }
{contentTypes && validateArray(contentTypes) && count }
</div>

<div className='ct-search-wrapper'>
Expand Down
14 changes: 6 additions & 8 deletions ui/src/components/LegacyCms/Actions/LoadUploadFile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,9 @@ const LoadUploadFile = (props: LoadUploadFileProps) => {
dispatch(updateNewMigrationData(newMigrationDataObj));

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

},1000);
setIsValidated(true);
setValidationMessage('Validation is successful');

setIsDisabled(true);

if(! isEmptyString(newMigrationData?.legacy_cms?.affix) && ! isEmptyString(newMigrationData?.legacy_cms?.selectedCms?.cms_id) && ! isEmptyString(newMigrationData?.legacy_cms?.selectedFileFormat?.fileformat_id)){
Expand Down Expand Up @@ -339,7 +337,7 @@ const LoadUploadFile = (props: LoadUploadFileProps) => {
setFileFormat(savedState.fileFormat);
setProcessing(savedState.processing);
}
if (savedState && savedState.isLoading) {
if (savedState && savedState.isLoading && !newMigrationData?.legacy_cms?.uploadedFile?.isValidated) {

handleOnFileUploadCompletion();
}
Expand Down Expand Up @@ -376,7 +374,7 @@ const LoadUploadFile = (props: LoadUploadFileProps) => {
]);

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

setIsValidated(true);
Expand Down Expand Up @@ -431,7 +429,7 @@ const LoadUploadFile = (props: LoadUploadFileProps) => {
<CircularLoader/>
</div>
}
{showMessage &&
{showMessage && ! showProgress &&
(
<>
<Paragraph className={`${validationClassName}` } tagName='p' variant="p2" text={validationMessgae}/>
Expand Down
1 change: 1 addition & 0 deletions ui/src/components/MainHeader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const MainHeader = () => {
useEffect(()=>{
const handlePopState = (event: PopStateEvent) => {
event.preventDefault();
window.history.pushState(null, '', window.location.href);
handleonClick();

};
Expand Down
2 changes: 1 addition & 1 deletion ui/src/pages/Migration/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ const Migration = () => {
result = 'Imported File';
break;
}
if (currentIndex !== 3) {
if (currentIndex !== 3 || currentIndex !== 4) {
Notification({
notificationContent: { text: `Please complete ${result} step` },
type: 'warning'
Expand Down
8 changes: 5 additions & 3 deletions ui/src/services/api/migration.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,11 @@ export const getContentTypes = (
skip: number,
limit: number,
searchText: string
) => {
) => {
try {
const encodedSearchText = encodeURIComponent(searchText) ;
return getCall(
`${API_VERSION}/mapper/contentTypes/${projectId}/${skip}/${limit}/${searchText}?`,
`${API_VERSION}/mapper/contentTypes/${projectId}/${skip}/${limit}/${encodedSearchText}?`,
options
);
} catch (error: any) {
Expand All @@ -107,8 +108,9 @@ export const getFieldMapping = async (
searchText: string
) => {
try {
const encodedSearchText = encodeURIComponent(searchText) ;
return await getCall(
`${API_VERSION}/mapper/fieldMapping/${contentTypeId}/${skip}/${limit}/${searchText}?`,
`${API_VERSION}/mapper/fieldMapping/${contentTypeId}/${skip}/${limit}/${encodedSearchText}?`,
options
);
} catch (error: any) {
Expand Down