Skip to content
Merged

Dev #168

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
a6ec05a
refactor:updated file format to show file format of cms
AishDani Jun 27, 2024
97ac8c7
refactor:legacy cms bugs
AishDani Jun 27, 2024
c43ad23
Merge branch 'dev' of github.com:contentstack/migration-v2-node-serve…
AishDani Jun 27, 2024
44e5b20
added profile card
RohitKini Jul 2, 2024
4d7423d
added profile card
RohitKini Jul 2, 2024
cc89f4a
Merge pull request #163 from contentstack/feature/profile-design
sreeneshkini Jul 2, 2024
f861ca5
Done functionality fixes for existing content type mapping
sayalijoshi27 Jul 2, 2024
2203b2f
Merge pull request #164 from contentstack/feature/CMG-57
v1shalpatel Jul 3, 2024
417515d
Content Type status modified functionality
sayalijoshi27 Jul 3, 2024
ce6b331
Removed code for search fieldsmapping as per content type
sayalijoshi27 Jul 4, 2024
00058d3
refactor:legacy cms bugs
AishDani Jul 4, 2024
9dab0fc
Merge pull request #165 from contentstack/feature/CMG-57
v1shalpatel Jul 4, 2024
a45ee93
Merge branch 'dev' of github.com:contentstack/migration-v2-node-serve…
AishDani Jul 4, 2024
9b64a54
Merge branch 'dev' of github.com:contentstack/migration-v2-node-serve…
AishDani Jul 4, 2024
1867387
refactor:resolved legacy cms bugs
AishDani Jul 4, 2024
9e4653c
refactor:removed search from getAllProject api
AishDani Jul 4, 2024
0765dfc
Merge pull request #166 from contentstack/feature/legacy-cms
v1shalpatel Jul 4, 2024
3bec73b
added destination bugs
snehalsankhe Jul 4, 2024
ec50c84
merged from dev
snehalsankhe Jul 4, 2024
690c223
Merge pull request #167 from contentstack/layout-changes
v1shalpatel Jul 4, 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
Next Next commit
refactor:updated file format to show file format of cms
  • Loading branch information
AishDani committed Jun 27, 2024
commit a6ec05a7cad59cd185fd74041ae475e344edb9bf
74 changes: 33 additions & 41 deletions ui/src/components/LegacyCms/Actions/LoadFileFormat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ import { Icon, TextInput } from '@contentstack/venus-components';
import { useDispatch, useSelector } from 'react-redux';

// Utilities
import { isEmptyString, validateArray } from '../../../utilities/functions';
import { isEmptyString } from '../../../utilities/functions';

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

// Interface
import { ICardType, defaultCardType } from '../../../components/Common/Card/card.interface';
import { ICardType} from '../../../components/Common/Card/card.interface';


// Components
import { RootState } from '../../../store';
import { updateNewMigrationData } from '../../../store/slice/migrationDataSlice';
import { getConfig } from '../../../services/api/upload.service';

interface LoadFileFormatProps {
stepComponentProps: any;
Expand All @@ -35,15 +35,14 @@ const LoadFileFormat = (props: LoadFileFormatProps) => {
const dispatch = useDispatch();

const [selectedCard, setSelectedCard] = useState<ICardType>(
newMigrationData?.legacy_cms?.selectedFileFormat ?? defaultCardType
newMigrationData?.legacy_cms?.selectedFileFormat
);
const [isCheckedBoxChecked, setIsCheckedBoxChecked] = useState<boolean>(
newMigrationData?.legacy_cms?.isFileFormatCheckboxChecked || true
);

const [fileIcon, setFileIcon] = useState(newMigrationData?.legacy_cms?.selectedFileFormat?.title);
const { projectId = '' } = useParams();
const { allowed_file_formats = [], doc_url = { href: '', title: '' } } =
newMigrationData?.legacy_cms?.selectedCms || {};


/**** ALL METHODS HERE ****/

Expand All @@ -57,9 +56,6 @@ const LoadFileFormat = (props: LoadFileFormatProps) => {
isFileFormatCheckboxChecked: isCheckedBoxChecked
}
}));



await fileformatConfirmation(selectedOrganisation?.value, projectId, {
fileformat_confirmation: true
});
Expand All @@ -75,52 +71,48 @@ const LoadFileFormat = (props: LoadFileFormatProps) => {
setIsCheckedBoxChecked(checked);
};

/**** ALL USEEffects HERE ****/
useEffect(() => {
if (validateArray(allowed_file_formats)) {
const initialFormat = {
description: allowed_file_formats?.[0]?.description,
group_name: allowed_file_formats?.[0]?.group_name,
title: allowed_file_formats?.[0]?.title,
fileformat_id: allowed_file_formats?.[0]?.fileformat_id
};
setSelectedCard(initialFormat);
const newMigrationDataObj = {
...newMigrationData,
legacy_cms: {
...newMigrationData?.legacy_cms,
selectedFileFormat: initialFormat
}
};
dispatch(updateNewMigrationData(newMigrationDataObj));
handleBtnClick();
const handleFileFormat = async() =>{
const apiRes: any = await getConfig();
const cmsType = apiRes?.data?.cmsType?.toLowerCase();

const { all_cms = [] } = migrationData?.legacyCMSData || {};
let filteredCmsData = all_cms;
if (cmsType) {
filteredCmsData = all_cms.filter((cms: any) => cms?.parent?.toLowerCase() === cmsType);
}
}, [allowed_file_formats]);

const newMigrationDataObj = {
...newMigrationData,
legacy_cms: {
...newMigrationData?.legacy_cms,
selectedFileFormat: filteredCmsData[0].allowed_file_formats[0]
}
};
setFileIcon(filteredCmsData[0].allowed_file_formats[0].title);
dispatch(updateNewMigrationData(newMigrationDataObj));
}

/**** ALL USEEffects HERE ****/
useEffect(()=>{
handleFileFormat();
handleBtnClick();
},[]);

const { file_format_checkbox_text = '' } = migrationData.legacyCMSData;

return (
<div className="row">
<div className="service_list_legacy">
{validateArray(allowed_file_formats) ? (
allowed_file_formats?.map((data: ICardType, index: number) => (
<div key={data?.fileformat_id || index}>
<TextInput
value={data?.fileformat_id}
value={newMigrationData?.legacy_cms?.selectedFileFormat?.fileformat_id}
version="v2"
isReadOnly={true}
disabled={true}
width="large"
placeholder=""
prefix={
<Icon icon={data?.title} size="medium" version='v2'/>}
<Icon icon={fileIcon} size="medium" version='v2'/>}
/>

</div>
))
) : (
<>No File formats available</>
)}
</div>
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions ui/src/components/LegacyCms/Actions/LoadPrefix.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { DEFAULT_URL_TYPE, INewMigration } from '../../../context/app/app.interf

// Style
import '../legacyCms.scss';
import { Icon, TextInput } from '@contentstack/venus-components';
import { TextInput } from '@contentstack/venus-components';
import { useDebouncer } from '../../../hooks';
import { RootState } from '../../../store';
import { updateNewMigrationData } from '../../../store/slice/migrationDataSlice';
Expand Down Expand Up @@ -109,7 +109,7 @@ const LoadPreFix = (props: LoadSelectCmsProps) => {
setIsError(false);

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

await affixConfirmation(selectedOrganisation?.value, projectId, {
affix_confirmation: true
});
Expand Down
11 changes: 9 additions & 2 deletions ui/src/components/LegacyCms/Actions/LoadSelectCms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const LoadSelectCms = (props: LoadSelectCmsProps) => {
dispatch(updateNewMigrationData(newMigrationDataObj));

//API call for saving selected CMS
await updateLegacyCMSData(selectedOrganisation.value, projectId, { legacy_cms: data?.cms_id });
//await updateLegacyCMSData(selectedOrganisation.value, projectId, { legacy_cms: data?.cms_id });

// Call for Step Change
props?.handleStepChange(props?.currentStep, true);
Expand Down Expand Up @@ -140,6 +140,14 @@ const LoadSelectCms = (props: LoadSelectCmsProps) => {
if (cmstype) {
filteredCmsData = all_cms.filter((cms: ICMSType) => cms?.parent?.toLowerCase() === cmstype?.toLowerCase());
}
const newMigrationDataObj = {
...newMigrationData,
legacy_cms: {
...newMigrationData?.legacy_cms,
selectedFileFormat: filteredCmsData[0].allowed_file_formats[0]
}
};
dispatch(updateNewMigrationData(newMigrationDataObj));

setCmsData(filteredCmsData)

Expand All @@ -162,7 +170,6 @@ const LoadSelectCms = (props: LoadSelectCmsProps) => {
} else {
newSelectedCard = DEFAULT_CMS_TYPE;
}


if (!isEmptyString(newSelectedCard?.title)) {
setSelectedCard(newSelectedCard);
Expand Down
3 changes: 2 additions & 1 deletion ui/src/pages/Migration/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { RootState } from '../../store';
import { updateMigrationData, updateNewMigrationData } from '../../store/slice/migrationDataSlice';

// Services
import { getMigrationData, updateCurrentStepData, updateLegacyCMSData, updateDestinationStack, createTestStack } from '../../services/api/migration.service';
import { getMigrationData, updateCurrentStepData, updateLegacyCMSData, updateDestinationStack, createTestStack, updateAffixData } from '../../services/api/migration.service';
import { getCMSDataFromFile } from '../../cmsData/cmsSelector';

// Utilities
Expand Down Expand Up @@ -172,6 +172,7 @@ const Migration = () => {
await updateLegacyCMSData(selectedOrganisation?.value, projectId, {
legacy_cms: newMigrationData?.legacy_cms?.selectedCms?.cms_id
});
await updateAffixData(selectedOrganisation?.value, projectId, { affix: newMigrationData?.legacy_cms?.affix });
const res = await updateCurrentStepData(selectedOrganisation.value, projectId);
handleStepChange(1);
if (res) {
Expand Down