Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
68 changes: 24 additions & 44 deletions ui/src/components/ContentMapper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,26 +211,12 @@ const ContentMapper = () => {
};

// Fetch table data
const fetchData = async ({
sortBy,
searchText,
skip,
limit,
startIndex,
stopIndex
}: TableTypes) => {
const fetchData = async ({ searchText }: TableTypes) => {
fetchContentTypes(searchText);
};

// Method for Load more table data
const loadMoreItems = async ({
sortBy,
searchText,
skip,
limit,
startIndex,
stopIndex
}: TableTypes) => {
const loadMoreItems = async ({ searchText, skip, limit, startIndex, stopIndex }: TableTypes) => {
try {
const itemStatusMapCopy: ItemStatusMapProp = { ...itemStatusMap };

Expand Down Expand Up @@ -645,44 +631,38 @@ const ContentMapper = () => {
// accessor: 'otherCmsField',
default: false,
id: 'uuid'
},
{
}
];

if (!IsEmptyStack) {
columns.push({
disableSortBy: true,
Header: `Contentstack: ${newMigrationData?.destination_stack?.selectedStack?.label}`,
// accessor: 'ct_field',
accessor: SelectAccessorOfColumn,
id: 'contentstack_field',
default: false
});
} else {
columns.push({
disableSortBy: true,
Header: `Contentstack: ${
IsEmptyStack ? otherCmsTitle : OtherContentType?.label ?? ''
}`,
accessor: SelectAccessor,
id: 'contentstack_cms_field'
}
// {
// disableSortBy: true,
// Header: contentstackFields.title,
// id: 'contenstatck',
// //id: contentstackFields.title.replace(/\W+/g, '_').toLowerCase(),
// accessor: SelectAccessor
// }
];

// if (!IsEmptyStack) {
// columns?.splice(1, 0, {
// disableSortBy: true,
// Header: `Contentstack: ${newMigrationData?.destination_stack?.selectedStack?.label}`,
// // accessor: 'ct_field',
// accessor: SelectAccessor,
// id: 'contentstack_cms_field'
// //default: false
// });
// }
id: 'contentstack_cms_field',
default: false
});
}
const nextButtonLabel =
currentIndex < contentTypes?.length - 1 ? contentTypes[currentIndex + 1]?.otherCmsTitle : '';

const prevButtonLabel = currentIndex > 0 ? contentTypes[currentIndex - 1]?.otherCmsTitle : '';

const options =
contentTypesList &&
contentTypesList.map((item) => ({
label: item?.title
}));
const options = contentTypesList?.map((item) => ({
label: item?.title,
value: item?.title
}));

// console.log("==============", contentTypesList);

Expand Down
7 changes: 4 additions & 3 deletions ui/src/components/DestinationStack/Actions/LoadStacks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ const LoadStacks = (props: LoadFileFormatProps) => {
updateNewMigrationData(newMigrationDataObj);

//call for Step Change
props.handleStepChange(props?.currentStep, true);
if (props?.handleStepChange) {
props.handleStepChange(props?.currentStep, true);
}
//.handleStepChange(props?.currentStep, true);
}
}
};
Expand All @@ -141,8 +144,6 @@ const LoadStacks = (props: LoadFileFormatProps) => {
//fetch all locales
const response = await getAllLocales(newMigrationData?.destination_stack?.selectedOrg?.value); //org id will always be there

console.log('getAllLocales =============', newMigrationData, response, stackData);

// const rawMappedLocalesMapped =
// validateObject(response?.data) && response?.data?.locales
// ? Object.keys(data?.locales)?.map((key) => ({
Expand Down
1 change: 0 additions & 1 deletion ui/src/components/DestinationStack/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ const DestinationStackComponent = ({
const fetchCMSData = async () => {
//check if offline CMS data field is set to true, if then read data from cms data file.
const data = await getCMSDataFromFile(CS_ENTRIES.DESTINATION_STACK);
console.log(':::::::::::::::::::::', data);

//fetch Legacy CMS Component Data from Contentstack CMS
//const data = await getEntries({ contentType: CS_ENTRIES.DESTINATION_STACK })
Expand Down
8 changes: 7 additions & 1 deletion ui/src/components/LegacyCms/Actions/LoadFileFormat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import { Button } from '@contentstack/venus-components';
import { isEmptyString, validateArray } from '../../../utilities/functions';

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

// Interface
import { ICardType, defaultCardType } from '../../../components/Common/Card/card.interface';
Expand Down Expand Up @@ -56,6 +59,9 @@ const LoadFileFormat = (props: LoadFileFormatProps) => {
updateFileFormatData(selectedOrganisation.value, projectId, {
file_format: selectedCard?.fileformat_id
});
fileformatConfirmation(selectedOrganisation?.value, projectId, {
fileformat_confirmation: isCheckedBoxChecked
});

//call for Step Change
props.handleStepChange(props.currentStep);
Expand Down
19 changes: 17 additions & 2 deletions ui/src/components/LegacyCms/Actions/LoadPrefix.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Libraries
import { ChangeEvent, useContext, useState } from 'react';
import { ChangeEvent, useContext, useEffect, useState } from 'react';
import { useParams } from 'react-router';

// Service
import { updateAffixData } from '../../../services/api/migration.service';
import { updateAffixData, affixConfirmation } from '../../../services/api/migration.service';

// Utilities
import { isEmptyString, isValidPrefix } from '../../../utilities/functions';
Expand Down Expand Up @@ -61,6 +61,9 @@ const LoadPreFix = (props: LoadSelectCmsProps) => {

//API call for saving Affix
updateAffixData(selectedOrganisation.value, projectId, { affix: prefix });
affixConfirmation(selectedOrganisation?.value, projectId, {
affix_confirmation: isCheckedBoxChecked
});

//call for Step Change
props.handleStepChange(props.currentStep);
Expand All @@ -87,9 +90,21 @@ const LoadPreFix = (props: LoadSelectCmsProps) => {
// Toggles checkbox selection
const handleCheckBoxChange = (e: ChangeEvent<HTMLInputElement>) => {
const { checked } = e.target;

const newMigrationDataObj: INewMigration = {
...newMigrationData,
legacy_cms: {
...newMigrationData.legacy_cms,
isRestictedKeywordCheckboxChecked: checked
}
};
updateNewMigrationData(newMigrationDataObj);

setIsCheckedBoxChecked(checked);
};



/**** ALL USEEffects HERE ****/

const { restricted_keyword_link = DEFAULT_URL_TYPE, restricted_keyword_checkbox_text = '' } =
Expand Down
8 changes: 6 additions & 2 deletions ui/src/components/LegacyCms/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,12 @@ const LegacyCMSComponent = ({ legacyCMSData, projectData }: LegacyCMSComponentPr
selectedFileFormat: selectedFileFormatData || defaultCardType,
uploadedFile: newMigrationData?.legacy_cms?.uploadedFile, //need to add backend data once endpoint exposed.
affix: legacyCMSData?.affix || newMigrationData?.legacy_cms?.affix || '',
isFileFormatCheckboxChecked: false, //need to add backend data once endpoint exposed.
isRestictedKeywordCheckboxChecked: false //need to add backend data once endpoint exposed.
isFileFormatCheckboxChecked:
legacyCMSData?.affix_confirmation ||
newMigrationData?.legacy_cms?.isFileFormatCheckboxChecked, //need to add backend data once endpoint exposed.
isRestictedKeywordCheckboxChecked:
legacyCMSData?.file_format_confirmation ||
newMigrationData?.legacy_cms?.isRestictedKeywordCheckboxChecked //need to add backend data once endpoint exposed.
}
});

Expand Down
4 changes: 3 additions & 1 deletion ui/src/context/app/app.provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,11 @@ const AppContextProvider: FC<IProps> = ({ children }) => {
if (!isEmptyString(authToken)) {
getUserDetails();
}
}, [authToken]);

useEffect(() => {
sessionStorage.setItem('newMigration', JSON.stringify(newMigration));
}, [authToken, newMigration]);
}, [newMigration]);

const ctxObject: IAppContext = {
authToken: authToken,
Expand Down
3 changes: 3 additions & 0 deletions ui/src/pages/MigrationEditor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ const MigrationEditor = () => {
const bodyContent = {
component: <NewMigrationWrapper />
};
<<<<<<< HEAD
=======

>>>>>>> 59a06e8ebc5cd58abbd1ba525a3d1906f2498955
/******** Function to get project ********/
const fetchProject = async () => {
const response = await getProject(selectedOrganisation?.value || '', params?.projectId || '');
Expand Down
24 changes: 24 additions & 0 deletions ui/src/services/api/migration.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,30 @@ export const updateCurrentStepData = (orgId: string, projectId: string, data: an
}
};

export const affixConfirmation = (orgId: string, projectId: string, data: any = {}) => {
try {
return putCall(
`${API_VERSION}/org/${orgId}/project/${projectId}/affix_confirmation`,
data,
options
);
} catch (error) {
return error;
}
};

export const fileformatConfirmation = (orgId: string, projectId: string, data: any = {}) => {
try {
return putCall(
`${API_VERSION}/org/${orgId}/project/${projectId}/fileformat_confirmation`,
data,
options
);
} catch (error) {
return error;
}
};

export const getContentTypes = (
projectId: string,
skip: number,
Expand Down