Skip to content

Commit f83930e

Browse files
committed
Enhance Legacy CMS component functionality by setting default affix and improving step completion logic
- Added logic to set a default affix value of 'cs' if not already defined in the LoadPrefix component. - Updated the LoadSelectCms component to preserve or set the default affix when selecting a CMS. - Modified the Migration page to ensure the affix is correctly assigned from project data or defaults to 'cs'. - Improved step completion checks in the LegacyCMSComponent to include affix validation.
1 parent 7b20417 commit f83930e

File tree

4 files changed

+30
-9
lines changed

4 files changed

+30
-9
lines changed

ui/src/components/LegacyCms/Actions/LoadPrefix.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,21 @@ const LoadPreFix = (props: LoadSelectCmsProps) => {
4444
fetchRestrictedKeywords();
4545
}, []);
4646

47+
// Set default affix 'cs' if not already set
48+
useEffect(() => {
49+
if (isEmptyString(newMigrationData?.legacy_cms?.affix)) {
50+
const newMigrationDataObj: INewMigration = {
51+
...newMigrationData,
52+
legacy_cms: {
53+
...newMigrationData?.legacy_cms,
54+
affix: 'cs',
55+
isRestictedKeywordCheckboxChecked: isCheckedBoxChecked
56+
}
57+
};
58+
dispatch(updateNewMigrationData(newMigrationDataObj));
59+
}
60+
}, []);
61+
4762
const fetchRestrictedKeywords = async () => {
4863
const restrictedIds = await getRestrictedKeywords();
4964

ui/src/components/LegacyCms/Actions/LoadSelectCms.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ const LoadSelectCms = (props: LoadSelectCmsProps) => {
6060
...newMigrationData,
6161
legacy_cms: {
6262
...newMigrationData.legacy_cms,
63-
selectedCms: { ...data }
63+
selectedCms: { ...data },
64+
affix: newMigrationData?.legacy_cms?.affix || 'cs' // Preserve or set default affix
6465
}
6566
};
6667
dispatch(updateNewMigrationData(newMigrationDataObj));
@@ -136,6 +137,7 @@ const LoadSelectCms = (props: LoadSelectCmsProps) => {
136137
...newMigrationData?.legacy_cms,
137138
selectedCms: newSelectedCard, // Include selectedCms in this dispatch
138139
selectedFileFormat: filteredCmsData[0].allowed_file_formats[0],
140+
affix: newMigrationData?.legacy_cms?.affix || 'cs', // Preserve or set default affix
139141
uploadedFile: {
140142
...newMigrationData?.legacy_cms?.uploadedFile,
141143
file_details: {

ui/src/components/LegacyCms/index.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,25 +197,25 @@ const LegacyCMSComponent = forwardRef(({ legacyCMSData, isCompleted, handleOnAll
197197

198198
//Make Step 2 complete
199199
if (
200-
!isEmptyString(newMigrationData?.legacy_cms?.selectedCms?.cms_id)
200+
!isEmptyString(newMigrationData?.legacy_cms?.selectedCms?.cms_id) &&
201+
!isEmptyString(newMigrationData?.legacy_cms?.affix)
201202
) {
202203
setInternalActiveStepIndex(1);
203204
}
204205

205-
if(!isEmptyString(newMigrationData?.legacy_cms?.selectedCms?.cms_id) && newMigrationData?.legacy_cms?.uploadedFile?.isValidated){
206-
setInternalActiveStepIndex(3);
207-
}
208-
setisProjectMapped(newMigrationData?.isprojectMapped)
206+
if(!isEmptyString(newMigrationData?.legacy_cms?.selectedCms?.cms_id) && newMigrationData?.legacy_cms?.uploadedFile?.isValidated){
207+
setInternalActiveStepIndex(3);
208+
}
209+
setisProjectMapped(newMigrationData?.isprojectMapped)
209210

210-
},[newMigrationData]);
211+
},[newMigrationData]);
211212

212213
useEffect(()=>{
213214
const allConditionsMet = !isEmptyString(newMigrationData?.legacy_cms?.affix)
214215
&& !isEmptyString(newMigrationData?.legacy_cms?.selectedFileFormat?.title) &&
215216
!isEmptyString(newMigrationData?.legacy_cms?.selectedCms?.title) &&
216217
newMigrationData?.legacy_cms?.uploadedFile?.isValidated;
217218

218-
219219
if(allConditionsMet){
220220
setIsAllStepsCompleted(true);
221221
handleAllStepsComplete(true);

ui/src/pages/Migration/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ const Migration = () => {
354354
...newMigrationData?.legacy_cms,
355355
selectedCms: selectedCmsData,
356356
selectedFileFormat: selectedFileFormatData,
357-
affix: projectData?.legacy_cms?.affix ,
357+
affix: projectData?.legacy_cms?.affix || newMigrationData?.legacy_cms?.affix || 'cs',
358358
uploadedFile: projectData?.legacy_cms?.is_fileValid ? {
359359
...newMigrationDataRef?.current?.legacy_cms?.uploadedFile,
360360
file_details: {
@@ -630,6 +630,10 @@ const Migration = () => {
630630
break;
631631
}
632632
if (currentIndex !== 3) {
633+
console.info('❌ Legacy CMS Step Completion Check Failed:', {
634+
currentIndex,
635+
missingStep: result
636+
});
633637
Notification({
634638
notificationContent: {
635639
text:

0 commit comments

Comments
 (0)